Test.EIImageViewer
parent
7e34aa1831
commit
5e9877b642
|
@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRaCIS.Core.Infra.EFCore",
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRaCIS.Core.Infrastructure", "IRaCIS.Core.Infrastructure\IRaCIS.Core.Infrastructure.csproj", "{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Start", "Start\Start.csproj", "{D96F4B52-359C-43C9-8110-BAD1437F9280}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EI_Image_Viewer_Installer", "Start\EI_Image_Viewer_Installer.csproj", "{D96F4B52-359C-43C9-8110-BAD1437F9280}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Install", "Install\Install.csproj", "{F5820DF0-DE23-4F4A-8D49-7E22F67B784D}"
|
||||
EndProject
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<UserSecretsId>354572d4-9e15-4099-807c-63a2d29ff9f2</UserSecretsId>
|
||||
<LangVersion>default</LangVersion>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<Copyright>上海展影医疗科技有限公司版权所有</Copyright>
|
||||
<Copyright>武汉行藏科技有限公司版权所有</Copyright>
|
||||
<AssemblyVersion></AssemblyVersion>
|
||||
<FileVersion>1.0.1.0412</FileVersion>
|
||||
<Product>IRC影像系统(EICS)</Product>
|
||||
<Version>1.0.1.0412</Version>
|
||||
<FileVersion>1.0.0.001</FileVersion>
|
||||
<Product>医学影像处理软件</Product>
|
||||
<Version>1.0.0.001</Version>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<AssemblyName>EI_Image_Viewer</AssemblyName>
|
||||
|
|
|
@ -8,12 +8,19 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
<AssemblyVersion></AssemblyVersion>
|
||||
<FileVersion>1.0.0.001</FileVersion>
|
||||
<Copyright>武汉行藏科技有限公司版权所有</Copyright>
|
||||
<Product>医学影像处理软件安装程序</Product>
|
||||
<Version>1.0.0.001</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resource\EIImageViewerData.rar" />
|
||||
<None Remove="Resource\EIImageViewerService.rar" />
|
||||
<None Remove="Resource\EIImageViewerWeb.rar" />
|
||||
<None Remove="Resource\UnInstall.exe" />
|
||||
<None Remove="Resource\医学影像处理软件用户手册.pdf" />
|
||||
<None Remove="ServiceConfig.Json" />
|
||||
<None Remove="Resource\Data\data.sql" />
|
||||
<None Remove="Resource\Data\dbo.sql" />
|
||||
|
@ -37,6 +44,12 @@
|
|||
<Content Include="Resource\Data\dbo.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resource\UnInstall.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resource\医学影像处理软件用户手册.pdf">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -47,4 +60,8 @@
|
|||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -106,7 +106,6 @@
|
|||
passwordTextBox.PasswordChar = '*';
|
||||
passwordTextBox.Size = new Size(271, 23);
|
||||
passwordTextBox.TabIndex = 5;
|
||||
passwordTextBox.Text = "123456";
|
||||
//
|
||||
// usernameTextBox
|
||||
//
|
||||
|
@ -444,6 +443,7 @@
|
|||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
Name = "Main";
|
||||
Text = "安装 - EI Image Viewer V1";
|
||||
TopMost = true;
|
||||
Load += Main_Load;
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
|
|
192
Start/Main.cs
192
Start/Main.cs
|
@ -44,6 +44,8 @@ namespace Start
|
|||
|
||||
private bool isDBNameTestOK = false;
|
||||
|
||||
private bool isRuntimeTestOk = false;
|
||||
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -54,25 +56,26 @@ namespace Start
|
|||
|
||||
this.machineTextBox.Text = physicalAddressList.FirstOrDefault()?.ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG");
|
||||
//this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG");
|
||||
}
|
||||
|
||||
int apiPort = 7100;
|
||||
int vuePort = 9527;
|
||||
private void connectButton_Click(object sender, EventArgs e)
|
||||
private async void connectButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
string connectionString = $"Server={serverTextBox.Text};User Id={usernameTextBox.Text};Password={passwordTextBox.Text};";
|
||||
|
||||
|
||||
|
||||
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
connection.Open();
|
||||
});
|
||||
|
||||
WinformLog("数据库连接测试成功!", Color.Green);
|
||||
|
||||
|
@ -100,6 +103,10 @@ namespace Start
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void portBtn_Click(object sender, EventArgs e)
|
||||
|
@ -157,6 +164,96 @@ namespace Start
|
|||
isServiceTestOk = true;
|
||||
}
|
||||
|
||||
private async void testNetcoreRuntime()
|
||||
{
|
||||
|
||||
string runtimeListCommand = "dotnet --list-runtimes";
|
||||
Process process = new Process();
|
||||
process.StartInfo.FileName = "cmd.exe";
|
||||
process.StartInfo.Arguments = "/c " + runtimeListCommand;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.Start();
|
||||
|
||||
string output = process.StandardOutput.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
|
||||
bool isAspNetCoreRuntimeInstalled = false;
|
||||
bool isNETCoreRuntimeInstalled = false;
|
||||
|
||||
var lineList = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
|
||||
foreach (string line in lineList)
|
||||
{
|
||||
if (line.Contains("Microsoft.AspNetCore.App") && !line.Contains("Preview"))
|
||||
{
|
||||
string versionString = line.Split(' ')[1];
|
||||
Version version = new Version(versionString);
|
||||
if (version.Major > 6 || (version.Major == 6 && version.Minor >= 0))
|
||||
{
|
||||
// 大于等于 6.0.0 的 .NET 运行时已安装
|
||||
isAspNetCoreRuntimeInstalled = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (line.Contains("Microsoft.NETCore.App") && !line.Contains("Preview"))
|
||||
{
|
||||
string versionString = line.Split(' ')[1];
|
||||
Version version = new Version(versionString);
|
||||
if (version.Major > 6 || (version.Major == 6 && version.Minor >= 0))
|
||||
{
|
||||
// 大于等于 6.0.0 的 .NET 运行时已安装
|
||||
isNETCoreRuntimeInstalled = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isAspNetCoreRuntimeInstalled && isNETCoreRuntimeInstalled)
|
||||
{
|
||||
// 执行逻辑,表示大于等于 6.0.0 的 .NET 运行时已安装
|
||||
|
||||
WinformLog("当前系统>= 6.0.0 NetCore 运行时已安装", Color.Green);
|
||||
|
||||
isRuntimeTestOk = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
WinformLog("当前系统>= 6.0.0 NetCore 运行时未安装,请安装后,再运行该程序", Color.Red);
|
||||
|
||||
connectButton.Enabled = false;
|
||||
|
||||
//await Task.Run(() =>
|
||||
// {
|
||||
// WinformLog("现在为您启动安装Net core 运行时...", Color.Orange);
|
||||
|
||||
// string runtimePath = Path.Combine(AppContext.BaseDirectory, "Resource/NetCoreRuntime/dotnet-hosting-6.0.0-win.exe");
|
||||
|
||||
// var processInfo = new ProcessStartInfo
|
||||
// {
|
||||
// FileName = runtimePath, // 安装程序的文件名
|
||||
// Arguments = $"/S /v /qn REINSTALLMODE=vomus",
|
||||
|
||||
// UseShellExecute = false
|
||||
// };
|
||||
|
||||
// var otherProcess = new Process { StartInfo = processInfo };
|
||||
// otherProcess.Start();
|
||||
// otherProcess.WaitForExit();
|
||||
|
||||
// WinformLog("Net core 6.0.0 运行时安装完成", Color.Green);
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void testDBBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dbNameTBox.Text))
|
||||
|
@ -205,13 +302,14 @@ namespace Start
|
|||
testServicebtn_Click(null, null);
|
||||
testDBBtn_Click(null, null);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.folderPathTbox.Text) )
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.folderPathTbox.Text))
|
||||
{
|
||||
WinformLog($"请选择部署路径,测试的端口,数据库名,服务名都成功才可以进行确认", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
if(isDBNameTestOK == false || isPortTestOk == false || isServiceTestOk == false)
|
||||
if (isDBNameTestOK == false || isPortTestOk == false || isServiceTestOk == false)
|
||||
{
|
||||
WinformLog($"测试的端口,数据库名,服务名都成功才可以进行确认", Color.Red);
|
||||
return;
|
||||
|
@ -269,7 +367,7 @@ namespace Start
|
|||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(WinformLog, message, color);
|
||||
Invoke(new Action(() => WinformLog(message, color)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -318,7 +416,7 @@ namespace Start
|
|||
var serviceDisplayName = serviceDisplayNameTBox.Text;
|
||||
|
||||
var nginxServiceName = nginxServiceNameTbox.Text;
|
||||
var nginxServiceDesName=nginxServiceDisplayNameTbox.Text;
|
||||
var nginxServiceDesName = nginxServiceDisplayNameTbox.Text;
|
||||
|
||||
|
||||
var deployFoder = this.folderPathTbox.Text;
|
||||
|
@ -339,8 +437,8 @@ namespace Start
|
|||
var apiBinPath = Path.Combine(deployFoder, "EIImageViewerService/EI_Image_Viewer.exe");
|
||||
var apiJsonConfigPath = Path.Combine(deployFoder, "EIImageViewerService/appsettings.CertificateApply.json");
|
||||
|
||||
string nginxRarFilePath = Path.Combine(AppContext.BaseDirectory, $@"Resource\EIImageViewerWeb.rar");
|
||||
string apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "Resource/EIImageViewerService.rar");
|
||||
string nginxRarFilePath = Path.Combine(AppContext.BaseDirectory, $@"Resource\EIImageViewerWeb.rar");
|
||||
string apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "Resource/EIImageViewerService.rar");
|
||||
|
||||
|
||||
string dataRarFilePath = Path.Combine(AppContext.BaseDirectory, "Resource/EIImageViewerData.rar");
|
||||
|
@ -641,7 +739,7 @@ namespace Start
|
|||
nginxStartPath = nginxStartPath,
|
||||
serviceName = serviceName,
|
||||
nginxServiceName = nginxServiceName,
|
||||
nginxServiceEXEPath= nginxServiceEXEPath
|
||||
nginxServiceEXEPath = nginxServiceEXEPath
|
||||
};
|
||||
|
||||
File.WriteAllText(Path.Combine(directoryPath, "config.json"), JsonConvert.SerializeObject(configObj));
|
||||
|
@ -789,8 +887,9 @@ namespace Start
|
|||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
};
|
||||
Process.Start(start);
|
||||
var urlProcess= Process.Start(start);
|
||||
|
||||
urlProcess.WaitForExit(); // 等待进程结束
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -800,10 +899,14 @@ namespace Start
|
|||
}
|
||||
else
|
||||
{
|
||||
WinformLog($"后端服务启动失败,可以手动启动{serviceDisplayName}尝试", Color.Red);
|
||||
WinformLog($"后端服务启动失败,您可手动启动{serviceDisplayName}尝试,如若手动尝试还是无法启动,请联系技术人员确认部署环境", Color.Red);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
await Task.Delay(10000);
|
||||
Application.Exit();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -848,22 +951,65 @@ namespace Start
|
|||
.WriteTo.File("logs\\log.txt", rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
|
||||
// 检查是否安装了 SQL Server
|
||||
bool isSqlServerInstalled = false;
|
||||
RegistryKey key = null;
|
||||
|
||||
|
||||
|
||||
// Check if any version of SQL Server is installed
|
||||
RegistryKey sqlServerKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQL Server");
|
||||
|
||||
if (sqlServerKey != null)
|
||||
try
|
||||
{
|
||||
WinformLog("当前系统SQL Server 已安装", Color.Green);
|
||||
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
|
||||
if (key != null)
|
||||
isSqlServerInstalled = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
key?.Close();
|
||||
}
|
||||
|
||||
if (isSqlServerInstalled)
|
||||
{
|
||||
// 获取 SQL Server 实例列表
|
||||
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var instanceName in key.GetValueNames())
|
||||
{
|
||||
WinformLog($"当前系统SQL Server 已安装实例: {instanceName}", Color.Green);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WinformLog("SQL Server 未安装,请安装后再运行该部署程序", Color.Red);
|
||||
|
||||
}
|
||||
|
||||
key?.Close();
|
||||
|
||||
|
||||
|
||||
//// Check if any version of SQL Server is installed
|
||||
//RegistryKey sqlServerKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQL Server");
|
||||
|
||||
//if (sqlServerKey != null)
|
||||
//{
|
||||
// WinformLog("当前系统SQL Server 已安装", Color.Green);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// WinformLog("SQL Server 未安装,请安装后再运行该部署程序", Color.Red);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
testNetcoreRuntime();
|
||||
|
||||
this.TopMost = true;
|
||||
this.Activate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file is automatically generated by Visual Studio. It is
|
||||
used to store generic object data source configuration information.
|
||||
Renaming the file extension or editing the content of this file may
|
||||
cause the file to be unrecognizable by the program.
|
||||
-->
|
||||
<GenericObjectDataSource DisplayName="Main" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
|
||||
<TypeInfo>Start.Main, Start, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
|
||||
</GenericObjectDataSource>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,6 +5,7 @@ using Serilog;
|
|||
using System.Data.SqlTypes;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
async Task ProcessStandardInputAsync(Process process, string cmd, string workDirectory = "")
|
||||
{
|
||||
|
@ -32,6 +33,10 @@ void DeleteFolderContents(string path)
|
|||
|
||||
foreach (FileInfo file in directory.GetFiles())
|
||||
{
|
||||
if (file.FullName.Contains("UnInstall"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -56,12 +61,12 @@ void DeleteFolderContents(string path)
|
|||
MyLog($"File {file.FullName} cannot be deleted. {ex2.Message}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo subDirectory in directory.GetDirectories())
|
||||
|
@ -70,20 +75,21 @@ void DeleteFolderContents(string path)
|
|||
}
|
||||
}
|
||||
|
||||
void MyLog(string message)
|
||||
|
||||
void MyLog(string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
Serilog.Log.Information(message);
|
||||
//Serilog.Log.Information(message);
|
||||
}
|
||||
|
||||
|
||||
Serilog.Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.File("logs\\UninstallLog.txt", rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
//Serilog.Log.Logger = new LoggerConfiguration()
|
||||
// .WriteTo.File("logs\\UninstallLog.txt", rollingInterval: RollingInterval.Day)
|
||||
// .CreateLogger();
|
||||
|
||||
|
||||
|
||||
var startProList = Process.GetProcesses().Where(t => t.ProcessName.Contains("Start")).ToList();
|
||||
var startProList = Process.GetProcesses().Where(t => t.ProcessName.Contains("EI_Image_Viewer_Installer")).ToList();
|
||||
foreach (var item in startProList)
|
||||
{
|
||||
item.Kill();
|
||||
|
@ -92,7 +98,7 @@ foreach (var item in startProList)
|
|||
|
||||
var configFolder = $@"C:\ProgramData\.xingcang\";
|
||||
|
||||
var configPath =Path.Combine(configFolder, "config.json") ;
|
||||
var configPath = Path.Combine(configFolder, "config.json");
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
MyLog("当前系统未部署影像系统,无须卸载");
|
||||
|
@ -132,8 +138,8 @@ else
|
|||
nginxStartPath = jObject["nginxStartPath"].ToString(),
|
||||
//apiPath = jObject["apiPath"].ToString(),
|
||||
serviceName = jObject["serviceName"].ToString(),
|
||||
nginxServiceName= jObject["nginxServiceName"]?.ToString(),
|
||||
nginxServiceEXEPath= jObject["nginxServiceEXEPath"]?.ToString(),
|
||||
nginxServiceName = jObject["nginxServiceName"]?.ToString(),
|
||||
nginxServiceEXEPath = jObject["nginxServiceEXEPath"]?.ToString(),
|
||||
};
|
||||
MyLog("激活信息读取完毕,开始准备卸载...");
|
||||
|
||||
|
@ -167,7 +173,7 @@ else
|
|||
|
||||
|
||||
|
||||
MyLog("停止并卸载后端服务...");
|
||||
MyLog("停止并卸载后端服务...");
|
||||
|
||||
await ProcessStandardInputAsync(process, $"sc stop {configObj.serviceName}");
|
||||
await ProcessStandardInputAsync(process, $"sc delete {configObj.serviceName}");
|
||||
|
@ -181,27 +187,35 @@ else
|
|||
process.StandardInput.Close();
|
||||
process.WaitForExit();
|
||||
|
||||
MyLog("删除部署文件夹下的所有内容...");
|
||||
await Task.Delay(3000);
|
||||
|
||||
MyLog($"删除部署文件夹{configObj.deployFolder}下可删除的所有内容...");
|
||||
DeleteFolderContents(configObj.deployFolder);
|
||||
|
||||
|
||||
DeleteFolderContents(configFolder);
|
||||
|
||||
MyLog("删除激活信息...");
|
||||
|
||||
DeleteFolderContents(configFolder);
|
||||
MyLog("EI Image Viewer 服务卸载完成。");
|
||||
|
||||
MyLog("3s 后自动退出...");
|
||||
await Task.Delay(3000);
|
||||
|
||||
string cmdArgs = $"/C ping 127.0.0.1 -n 5 & rmdir /s /q \"{configObj.deployFolder}\"";
|
||||
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", cmdArgs);
|
||||
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
psi.CreateNoWindow = true;
|
||||
Process.Start(psi);
|
||||
|
||||
Environment.Exit(0);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
MyLog("程序出错:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
MyLog("错误:" + ex.Message);
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue