Skip to content

Commit

Permalink
prepair version 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
balbarak committed Jan 31, 2021
1 parent 03b0ecd commit 16eebfc
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 77 deletions.
32 changes: 29 additions & 3 deletions src/ScanX.InstallHelpers/MainInstallerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
using System.Windows;
Expand Down Expand Up @@ -32,28 +33,45 @@ protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);

var zipPath = Path.Combine(GetPath(), "Scanx.zip");

string path = GetPath();
var protocolFolderPath = GetProtocolFolderPath();

string servicePath = Path.Combine(path,"ScanX.Protocol.exe");
ZipFile.ExtractToDirectory(zipPath, protocolFolderPath);


string servicePath = Path.Combine(protocolFolderPath, "ScanX.Protocol.exe");

ServiceHelper.InstallService(servicePath);
ServiceHelper.StartService();
}

protected override void OnBeforeUninstall(IDictionary savedState)
{

ServiceHelper.StopService();

base.OnBeforeUninstall(savedState);

}

protected override void OnAfterUninstall(IDictionary savedState)
{
base.OnAfterUninstall(savedState);


ServiceHelper.DeleteService();

try
{
var path = GetProtocolFolderPath();

if (Directory.Exists(path))
Directory.Delete(path, true);
}
catch (Exception)
{

}
}

private string GetPath()
Expand All @@ -62,6 +80,14 @@ private string GetPath()

return result;
}
private string GetProtocolFolderPath()
{
var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

var result = Path.Combine(baseDir, "Protocol");

return result;
}

private void CleanUp()
{
Expand Down
10 changes: 9 additions & 1 deletion src/ScanX.InstallHelpers/ScanX.InstallHelpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScanX.InstallHelpers</RootNamespace>
<AssemblyName>ScanX.InstallHelpers</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down Expand Up @@ -37,6 +37,11 @@
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -63,5 +68,8 @@
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion src/ScanX.InstallHelpers/ServiceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void StopService()
ProcessStartInfo startupInfo = new ProcessStartInfo()
{
FileName = "cmd.exe",
Arguments = $"/C sc stop {_serviceName}",
Arguments = $"/C net stop {_serviceName}",
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
};
Expand Down
4 changes: 4 additions & 0 deletions src/ScanX.InstallHelpers/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net46" />
</packages>
12 changes: 12 additions & 0 deletions src/ScanX.Protocol/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "5.0.2",
"commands": [
"dotnet-ef"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\netcoreapp3.1\publish\</PublishUrl>
<PublishUrl>bin\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down
6 changes: 6 additions & 0 deletions src/ScanX.Protocol/ScanX.Protocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>93bd8854-3168-49ce-990f-de49830ac2f8</UserSecretsId>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,4 +14,9 @@
<ProjectReference Include="..\ScanX.Core\ScanX.Core.csproj" />
</ItemGroup>


<ItemGroup>
<Folder Include="Properties\PublishProfiles\" />
</ItemGroup>

</Project>
Loading

0 comments on commit 16eebfc

Please sign in to comment.