删除配置文件写入

Test.EIImageViewer
hang 2023-04-17 11:41:06 +08:00
parent 94dc00ddec
commit b0f85fae1c
8 changed files with 404 additions and 10810 deletions

View File

@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRaCIS.Core.Infrastructure"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Start", "Start\Start.csproj", "{D96F4B52-359C-43C9-8110-BAD1437F9280}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Start", "Start\Start.csproj", "{D96F4B52-359C-43C9-8110-BAD1437F9280}"
EndProject EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -31,7 +33,6 @@ Global
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Debug|Any CPU.Build.0 = Debug|Any CPU {F15CE209-6039-46A6-AE7F-E81ADA795F28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Debug|x86.ActiveCfg = Debug|x86 {F15CE209-6039-46A6-AE7F-E81ADA795F28}.Debug|x86.ActiveCfg = Debug|x86
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|Any CPU.ActiveCfg = Release|Any CPU {F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|Any CPU.Build.0 = Release|Any CPU
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|x86.ActiveCfg = Release|x86 {F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|x86.ActiveCfg = Release|x86
{F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|x86.Build.0 = Release|x86 {F15CE209-6039-46A6-AE7F-E81ADA795F28}.Release|x86.Build.0 = Release|x86
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@ -77,6 +78,10 @@ Global
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|Any CPU.ActiveCfg = Release|Any CPU {D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.ActiveCfg = Release|x86 {D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.ActiveCfg = Release|x86
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.Build.0 = Release|x86 {D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.Build.0 = Release|x86
{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}.Debug|Any CPU.ActiveCfg = Debug
{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}.Debug|x86.ActiveCfg = Debug
{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}.Release|Any CPU.ActiveCfg = Release
{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}.Release|x86.ActiveCfg = Release
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -72,60 +72,6 @@ namespace IRaCIS.Core.API
} }
#region 数据库连接写入配置文件
var currentDicectory = AppContext.BaseDirectory;
//var rootPath = (Directory.GetParent(currentDicectory.TrimEnd('\\'))).FullName;
//var configPath = Path.Combine(rootPath, "resources/config.json");
//var initConfigJson = File.ReadAllText(configPath);
//var innitJsonObj = JObject.Parse(initConfigJson);
var dbServerName = jsonObject["server"].ToString();
var dbLoginUser = jsonObject["user"].ToString();
var dbPwd = jsonObject["password"].ToString();
var dbName= jsonObject["dbName"].ToString();
var certificateApplyPath = Path.Combine(currentDicectory, "appsettings.CertificateApply.json");
var appsettingsJson = File.ReadAllText(certificateApplyPath);
// 解析 JSON 字符串
var jObject = JObject.Parse(appsettingsJson);
// 获取 UpdateConfig 属性所在的节点
var updateConfigNode = jObject["ConnectionStrings"];
var connectionString = $"Server={dbServerName};Database={dbName};User ID={dbLoginUser};Password={dbPwd};TrustServerCertificate=true";
updateConfigNode["RemoteNew"] = connectionString;
try
{
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
File.WriteAllText(certificateApplyPath, jObject.ToString());
}
}
catch (SqlException)
{
Console.WriteLine("连接字符串错误");
}
#endregion
} }
#endregion #endregion
@ -197,43 +143,6 @@ namespace IRaCIS.Core.API
#region Nlog 废弃
//var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
//try
//{
// var ihostBuilder = CreateHostBuilder(args);
// ihostBuilder.UseEnvironment(environment);
// ihostBuilder.ConfigureAppConfiguration((hostContext, config) =>
// {
// //Console.WriteLine(hostContext.HostingEnvironment.EnvironmentName);
// config.AddJsonFile("appsettings.json", false, true)
// .AddJsonFile($"appsettings.{environment}.json", false, true);
// });
// var host = ihostBuilder.Build();
// CacheTrialStatus(host);
// host.Run();
//}
//catch (Exception exception)
//{
// //NLog: catch setup errors
// logger.Error(exception, "Stopped program because of exception");
//}
//finally
//{
// // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
// NLog.LogManager.Shutdown();
//}
#endregion
} }

File diff suppressed because it is too large Load Diff

164
Start/Main.Designer.cs generated
View File

@ -38,8 +38,6 @@
label1 = new Label(); label1 = new Label();
groupBox2 = new GroupBox(); groupBox2 = new GroupBox();
confimDeployBtn = new Button(); confimDeployBtn = new Button();
testDBBtn = new Button();
testServicebtn = new Button();
serviceDisplayNameTBox = new TextBox(); serviceDisplayNameTBox = new TextBox();
serviceNameTBox = new TextBox(); serviceNameTBox = new TextBox();
label11 = new Label(); label11 = new Label();
@ -49,12 +47,12 @@
label9 = new Label(); label9 = new Label();
dbNameTBox = new TextBox(); dbNameTBox = new TextBox();
label8 = new Label(); label8 = new Label();
portBtn = new Button();
apiPortTBox = new TextBox(); apiPortTBox = new TextBox();
nginxPortTBox = new TextBox(); nginxPortTBox = new TextBox();
label4 = new Label(); label4 = new Label();
label5 = new Label(); label5 = new Label();
groupBox3 = new GroupBox(); groupBox3 = new GroupBox();
btnCopy = new Button();
activeBtn = new Button(); activeBtn = new Button();
KeySecreteTextBox = new TextBox(); KeySecreteTextBox = new TextBox();
machineTextBox = new TextBox(); machineTextBox = new TextBox();
@ -81,16 +79,16 @@
groupBox1.Controls.Add(label1); groupBox1.Controls.Add(label1);
groupBox1.Location = new Point(24, 25); groupBox1.Location = new Point(24, 25);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(570, 187); groupBox1.Size = new Size(570, 230);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "第一步:数据库"; groupBox1.Text = "第一步:验证数据库";
// //
// connectButton // connectButton
// //
connectButton.Location = new Point(418, 69); connectButton.Location = new Point(195, 168);
connectButton.Name = "connectButton"; connectButton.Name = "connectButton";
connectButton.Size = new Size(128, 49); connectButton.Size = new Size(128, 40);
connectButton.TabIndex = 6; connectButton.TabIndex = 6;
connectButton.Text = "测试连接"; connectButton.Text = "测试连接";
connectButton.UseVisualStyleBackColor = true; connectButton.UseVisualStyleBackColor = true;
@ -98,15 +96,16 @@
// //
// passwordTextBox // passwordTextBox
// //
passwordTextBox.Location = new Point(120, 134); passwordTextBox.Location = new Point(154, 129);
passwordTextBox.Name = "passwordTextBox"; passwordTextBox.Name = "passwordTextBox";
passwordTextBox.PasswordChar = '*';
passwordTextBox.Size = new Size(271, 23); passwordTextBox.Size = new Size(271, 23);
passwordTextBox.TabIndex = 5; passwordTextBox.TabIndex = 5;
passwordTextBox.Text = "123456"; passwordTextBox.Text = "123456";
// //
// usernameTextBox // usernameTextBox
// //
usernameTextBox.Location = new Point(120, 89); usernameTextBox.Location = new Point(156, 82);
usernameTextBox.Name = "usernameTextBox"; usernameTextBox.Name = "usernameTextBox";
usernameTextBox.Size = new Size(271, 23); usernameTextBox.Size = new Size(271, 23);
usernameTextBox.TabIndex = 4; usernameTextBox.TabIndex = 4;
@ -114,7 +113,7 @@
// //
// serverTextBox // serverTextBox
// //
serverTextBox.Location = new Point(120, 41); serverTextBox.Location = new Point(156, 37);
serverTextBox.Name = "serverTextBox"; serverTextBox.Name = "serverTextBox";
serverTextBox.Size = new Size(271, 23); serverTextBox.Size = new Size(271, 23);
serverTextBox.TabIndex = 3; serverTextBox.TabIndex = 3;
@ -123,7 +122,7 @@
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(26, 131); label3.Location = new Point(107, 131);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(32, 17); label3.Size = new Size(32, 17);
label3.TabIndex = 2; label3.TabIndex = 2;
@ -132,7 +131,7 @@
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(26, 85); label2.Location = new Point(101, 83);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(44, 17); label2.Size = new Size(44, 17);
label2.TabIndex = 1; label2.TabIndex = 1;
@ -141,7 +140,7 @@
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(26, 35); label1.Location = new Point(95, 38);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(56, 17); label1.Size = new Size(56, 17);
label1.TabIndex = 0; label1.TabIndex = 0;
@ -150,8 +149,6 @@
// groupBox2 // groupBox2
// //
groupBox2.Controls.Add(confimDeployBtn); groupBox2.Controls.Add(confimDeployBtn);
groupBox2.Controls.Add(testDBBtn);
groupBox2.Controls.Add(testServicebtn);
groupBox2.Controls.Add(serviceDisplayNameTBox); groupBox2.Controls.Add(serviceDisplayNameTBox);
groupBox2.Controls.Add(serviceNameTBox); groupBox2.Controls.Add(serviceNameTBox);
groupBox2.Controls.Add(label11); groupBox2.Controls.Add(label11);
@ -161,71 +158,48 @@
groupBox2.Controls.Add(label9); groupBox2.Controls.Add(label9);
groupBox2.Controls.Add(dbNameTBox); groupBox2.Controls.Add(dbNameTBox);
groupBox2.Controls.Add(label8); groupBox2.Controls.Add(label8);
groupBox2.Controls.Add(portBtn);
groupBox2.Controls.Add(apiPortTBox); groupBox2.Controls.Add(apiPortTBox);
groupBox2.Controls.Add(nginxPortTBox); groupBox2.Controls.Add(nginxPortTBox);
groupBox2.Controls.Add(label4); groupBox2.Controls.Add(label4);
groupBox2.Controls.Add(label5); groupBox2.Controls.Add(label5);
groupBox2.Location = new Point(24, 231); groupBox2.Location = new Point(24, 280);
groupBox2.Name = "groupBox2"; groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(570, 439); groupBox2.Size = new Size(570, 418);
groupBox2.TabIndex = 1; groupBox2.TabIndex = 1;
groupBox2.TabStop = false; groupBox2.TabStop = false;
groupBox2.Text = "第二步: 部署配置"; groupBox2.Text = "第二步: 部署参数配置";
// //
// confimDeployBtn // confimDeployBtn
// //
confimDeployBtn.Enabled = false; confimDeployBtn.Enabled = false;
confimDeployBtn.Location = new Point(220, 369); confimDeployBtn.Location = new Point(195, 353);
confimDeployBtn.Name = "confimDeployBtn"; confimDeployBtn.Name = "confimDeployBtn";
confimDeployBtn.Size = new Size(128, 49); confimDeployBtn.Size = new Size(128, 40);
confimDeployBtn.TabIndex = 19; confimDeployBtn.TabIndex = 19;
confimDeployBtn.Text = "确认部署配置"; confimDeployBtn.Text = "确认部署配置";
confimDeployBtn.UseVisualStyleBackColor = true; confimDeployBtn.UseVisualStyleBackColor = true;
confimDeployBtn.Click += confimDeployBtn_Click; confimDeployBtn.Click += confimDeployBtn_Click;
// //
// testDBBtn
//
testDBBtn.Enabled = false;
testDBBtn.Location = new Point(417, 196);
testDBBtn.Name = "testDBBtn";
testDBBtn.Size = new Size(128, 49);
testDBBtn.TabIndex = 18;
testDBBtn.Text = "测试数据库名";
testDBBtn.UseVisualStyleBackColor = true;
testDBBtn.Click += testDBBtn_Click;
//
// testServicebtn
//
testServicebtn.Enabled = false;
testServicebtn.Location = new Point(417, 276);
testServicebtn.Name = "testServicebtn";
testServicebtn.Size = new Size(128, 49);
testServicebtn.TabIndex = 17;
testServicebtn.Text = "测试服务名称";
testServicebtn.UseVisualStyleBackColor = true;
testServicebtn.Click += testServicebtn_Click;
//
// serviceDisplayNameTBox // serviceDisplayNameTBox
// //
serviceDisplayNameTBox.Location = new Point(197, 308); serviceDisplayNameTBox.Location = new Point(152, 303);
serviceDisplayNameTBox.Name = "serviceDisplayNameTBox"; serviceDisplayNameTBox.Name = "serviceDisplayNameTBox";
serviceDisplayNameTBox.Size = new Size(197, 23); serviceDisplayNameTBox.Size = new Size(259, 23);
serviceDisplayNameTBox.TabIndex = 16; serviceDisplayNameTBox.TabIndex = 16;
serviceDisplayNameTBox.Text = "EI_Image_Viewer_DisplayName"; serviceDisplayNameTBox.Text = "EI_Image_Viewer_DisplayName";
// //
// serviceNameTBox // serviceNameTBox
// //
serviceNameTBox.Location = new Point(197, 251); serviceNameTBox.Location = new Point(152, 248);
serviceNameTBox.Name = "serviceNameTBox"; serviceNameTBox.Name = "serviceNameTBox";
serviceNameTBox.Size = new Size(197, 23); serviceNameTBox.Size = new Size(259, 23);
serviceNameTBox.TabIndex = 15; serviceNameTBox.TabIndex = 15;
serviceNameTBox.Text = "EI_Image_Viewer"; serviceNameTBox.Text = "EI_Image_Viewer";
// //
// label11 // label11
// //
label11.AutoSize = true; label11.AutoSize = true;
label11.Location = new Point(20, 308); label11.Location = new Point(11, 304);
label11.Name = "label11"; label11.Name = "label11";
label11.Size = new Size(128, 17); label11.Size = new Size(128, 17);
label11.TabIndex = 14; label11.TabIndex = 14;
@ -234,7 +208,7 @@
// label10 // label10
// //
label10.AutoSize = true; label10.AutoSize = true;
label10.Location = new Point(20, 254); label10.Location = new Point(35, 250);
label10.Name = "label10"; label10.Name = "label10";
label10.Size = new Size(104, 17); label10.Size = new Size(104, 17);
label10.TabIndex = 13; label10.TabIndex = 13;
@ -243,79 +217,68 @@
// selectPathBtn // selectPathBtn
// //
selectPathBtn.Enabled = false; selectPathBtn.Enabled = false;
selectPathBtn.Location = new Point(417, 44); selectPathBtn.Location = new Point(429, 43);
selectPathBtn.Name = "selectPathBtn"; selectPathBtn.Name = "selectPathBtn";
selectPathBtn.Size = new Size(128, 31); selectPathBtn.Size = new Size(118, 27);
selectPathBtn.TabIndex = 12; selectPathBtn.TabIndex = 12;
selectPathBtn.Text = "选择部署路径"; selectPathBtn.Text = "选择";
selectPathBtn.UseVisualStyleBackColor = true; selectPathBtn.UseVisualStyleBackColor = true;
selectPathBtn.Click += selectPathBtn_Click; selectPathBtn.Click += selectPathBtn_Click;
// //
// folderPathTbox // folderPathTbox
// //
folderPathTbox.Enabled = false; folderPathTbox.Enabled = false;
folderPathTbox.Location = new Point(119, 48); folderPathTbox.Location = new Point(152, 43);
folderPathTbox.Name = "folderPathTbox"; folderPathTbox.Name = "folderPathTbox";
folderPathTbox.Size = new Size(271, 23); folderPathTbox.Size = new Size(259, 23);
folderPathTbox.TabIndex = 11; folderPathTbox.TabIndex = 11;
// //
// label9 // label9
// //
label9.AutoSize = true; label9.AutoSize = true;
label9.Location = new Point(20, 51); label9.Location = new Point(83, 43);
label9.Name = "label9"; label9.Name = "label9";
label9.Size = new Size(92, 17); label9.Size = new Size(56, 17);
label9.TabIndex = 10; label9.TabIndex = 10;
label9.Text = "网站部署文件夹"; label9.Text = "部署路径";
// //
// dbNameTBox // dbNameTBox
// //
dbNameTBox.Location = new Point(198, 196); dbNameTBox.Location = new Point(152, 191);
dbNameTBox.Name = "dbNameTBox"; dbNameTBox.Name = "dbNameTBox";
dbNameTBox.Size = new Size(197, 23); dbNameTBox.Size = new Size(259, 23);
dbNameTBox.TabIndex = 9; dbNameTBox.TabIndex = 9;
dbNameTBox.Text = "IRaCIS"; dbNameTBox.Text = "IRaCIS";
// //
// label8 // label8
// //
label8.AutoSize = true; label8.AutoSize = true;
label8.Location = new Point(20, 201); label8.Location = new Point(47, 197);
label8.Name = "label8"; label8.Name = "label8";
label8.Size = new Size(92, 17); label8.Size = new Size(92, 17);
label8.TabIndex = 8; label8.TabIndex = 8;
label8.Text = "部署数据库名称"; label8.Text = "部署数据库名称";
// //
// portBtn
//
portBtn.Enabled = false;
portBtn.Location = new Point(417, 114);
portBtn.Name = "portBtn";
portBtn.Size = new Size(128, 49);
portBtn.TabIndex = 7;
portBtn.Text = "测试端口";
portBtn.UseVisualStyleBackColor = true;
portBtn.Click += portBtn_Click;
//
// apiPortTBox // apiPortTBox
// //
apiPortTBox.Location = new Point(198, 151); apiPortTBox.Location = new Point(152, 146);
apiPortTBox.Name = "apiPortTBox"; apiPortTBox.Name = "apiPortTBox";
apiPortTBox.Size = new Size(197, 23); apiPortTBox.Size = new Size(259, 23);
apiPortTBox.TabIndex = 5; apiPortTBox.TabIndex = 5;
apiPortTBox.Text = "7100"; apiPortTBox.Text = "7100";
// //
// nginxPortTBox // nginxPortTBox
// //
nginxPortTBox.Location = new Point(197, 103); nginxPortTBox.Location = new Point(152, 98);
nginxPortTBox.Name = "nginxPortTBox"; nginxPortTBox.Name = "nginxPortTBox";
nginxPortTBox.Size = new Size(197, 23); nginxPortTBox.Size = new Size(259, 23);
nginxPortTBox.TabIndex = 4; nginxPortTBox.TabIndex = 4;
nginxPortTBox.Text = "9520"; nginxPortTBox.Text = "9520";
// //
// label4 // label4
// //
label4.AutoSize = true; label4.AutoSize = true;
label4.Location = new Point(20, 157); label4.Location = new Point(11, 153);
label4.Name = "label4"; label4.Name = "label4";
label4.Size = new Size(128, 17); label4.Size = new Size(128, 17);
label4.TabIndex = 3; label4.TabIndex = 3;
@ -324,7 +287,7 @@
// label5 // label5
// //
label5.AutoSize = true; label5.AutoSize = true;
label5.Location = new Point(20, 107); label5.Location = new Point(35, 100);
label5.Name = "label5"; label5.Name = "label5";
label5.Size = new Size(104, 17); label5.Size = new Size(104, 17);
label5.TabIndex = 2; label5.TabIndex = 2;
@ -332,25 +295,36 @@
// //
// groupBox3 // groupBox3
// //
groupBox3.Controls.Add(btnCopy);
groupBox3.Controls.Add(activeBtn); groupBox3.Controls.Add(activeBtn);
groupBox3.Controls.Add(KeySecreteTextBox); groupBox3.Controls.Add(KeySecreteTextBox);
groupBox3.Controls.Add(machineTextBox); groupBox3.Controls.Add(machineTextBox);
groupBox3.Controls.Add(machineCodeLB); groupBox3.Controls.Add(machineCodeLB);
groupBox3.Controls.Add(label6); groupBox3.Controls.Add(label6);
groupBox3.Controls.Add(label7); groupBox3.Controls.Add(label7);
groupBox3.Location = new Point(12, 693); groupBox3.Location = new Point(24, 713);
groupBox3.Name = "groupBox3"; groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(582, 183); groupBox3.Size = new Size(570, 221);
groupBox3.TabIndex = 2; groupBox3.TabIndex = 2;
groupBox3.TabStop = false; groupBox3.TabStop = false;
groupBox3.Text = "第三部:激活码"; groupBox3.Text = "第三步:激活与部署";
//
// btnCopy
//
btnCopy.Location = new Point(429, 51);
btnCopy.Name = "btnCopy";
btnCopy.Size = new Size(118, 27);
btnCopy.TabIndex = 13;
btnCopy.Text = "复制";
btnCopy.UseVisualStyleBackColor = true;
btnCopy.Click += btnCopy_Click;
// //
// activeBtn // activeBtn
// //
activeBtn.Enabled = false; activeBtn.Enabled = false;
activeBtn.Location = new Point(430, 69); activeBtn.Location = new Point(195, 146);
activeBtn.Name = "activeBtn"; activeBtn.Name = "activeBtn";
activeBtn.Size = new Size(128, 49); activeBtn.Size = new Size(128, 40);
activeBtn.TabIndex = 9; activeBtn.TabIndex = 9;
activeBtn.Text = "激活并部署"; activeBtn.Text = "激活并部署";
activeBtn.UseVisualStyleBackColor = true; activeBtn.UseVisualStyleBackColor = true;
@ -358,18 +332,17 @@
// //
// KeySecreteTextBox // KeySecreteTextBox
// //
KeySecreteTextBox.Location = new Point(131, 101); KeySecreteTextBox.Location = new Point(152, 101);
KeySecreteTextBox.Multiline = true;
KeySecreteTextBox.Name = "KeySecreteTextBox"; KeySecreteTextBox.Name = "KeySecreteTextBox";
KeySecreteTextBox.Size = new Size(271, 42); KeySecreteTextBox.Size = new Size(259, 23);
KeySecreteTextBox.TabIndex = 8; KeySecreteTextBox.TabIndex = 8;
// //
// machineTextBox // machineTextBox
// //
machineTextBox.Location = new Point(132, 45); machineTextBox.Location = new Point(152, 51);
machineTextBox.Name = "machineTextBox"; machineTextBox.Name = "machineTextBox";
machineTextBox.ReadOnly = true; machineTextBox.ReadOnly = true;
machineTextBox.Size = new Size(271, 23); machineTextBox.Size = new Size(259, 23);
machineTextBox.TabIndex = 7; machineTextBox.TabIndex = 7;
// //
// machineCodeLB // machineCodeLB
@ -383,7 +356,7 @@
// label6 // label6
// //
label6.AutoSize = true; label6.AutoSize = true;
label6.Location = new Point(26, 101); label6.Location = new Point(95, 101);
label6.Name = "label6"; label6.Name = "label6";
label6.Size = new Size(44, 17); label6.Size = new Size(44, 17);
label6.TabIndex = 5; label6.TabIndex = 5;
@ -392,7 +365,7 @@
// label7 // label7
// //
label7.AutoSize = true; label7.AutoSize = true;
label7.Location = new Point(26, 51); label7.Location = new Point(95, 51);
label7.Name = "label7"; label7.Name = "label7";
label7.Size = new Size(44, 17); label7.Size = new Size(44, 17);
label7.TabIndex = 4; label7.TabIndex = 4;
@ -403,16 +376,16 @@
groupBox4.Controls.Add(logTBox); groupBox4.Controls.Add(logTBox);
groupBox4.Location = new Point(618, 25); groupBox4.Location = new Point(618, 25);
groupBox4.Name = "groupBox4"; groupBox4.Name = "groupBox4";
groupBox4.Size = new Size(391, 851); groupBox4.Size = new Size(391, 890);
groupBox4.TabIndex = 4; groupBox4.TabIndex = 4;
groupBox4.TabStop = false; groupBox4.TabStop = false;
groupBox4.Text = "部署提示日志"; groupBox4.Text = "部署日志";
// //
// logTBox // logTBox
// //
logTBox.Location = new Point(6, 22); logTBox.Location = new Point(6, 22);
logTBox.Name = "logTBox"; logTBox.Name = "logTBox";
logTBox.Size = new Size(359, 816); logTBox.Size = new Size(359, 862);
logTBox.TabIndex = 0; logTBox.TabIndex = 0;
logTBox.Text = ""; logTBox.Text = "";
// //
@ -420,13 +393,14 @@
// //
AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1021, 914); ClientSize = new Size(1021, 946);
Controls.Add(groupBox4); Controls.Add(groupBox4);
Controls.Add(groupBox3); Controls.Add(groupBox3);
Controls.Add(groupBox2); Controls.Add(groupBox2);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "Main"; Name = "Main";
Text = "EI Image Viewer"; Text = "EI Image Viewer";
Load += Main_Load;
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);
groupBox1.PerformLayout(); groupBox1.PerformLayout();
groupBox2.ResumeLayout(false); groupBox2.ResumeLayout(false);
@ -453,7 +427,6 @@
private Label label4; private Label label4;
private Label label5; private Label label5;
private GroupBox groupBox3; private GroupBox groupBox3;
private Button portBtn;
private Label machineCodeLB; private Label machineCodeLB;
private Label label6; private Label label6;
private Label label7; private Label label7;
@ -472,8 +445,7 @@
private TextBox serviceNameTBox; private TextBox serviceNameTBox;
private Label label11; private Label label11;
private Label label10; private Label label10;
private Button testDBBtn;
private Button testServicebtn;
private Button confimDeployBtn; private Button confimDeployBtn;
private Button btnCopy;
} }
} }

View File

@ -25,6 +25,8 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Security.Policy; using System.Security.Policy;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar; using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
using System.Data.SqlTypes; using System.Data.SqlTypes;
using Serilog;
using System.Xml.Linq;
namespace Start namespace Start
{ {
@ -47,6 +49,10 @@ namespace Start
this.machineTextBox.Text = physicalAddressList.FirstOrDefault()?.ToString(); this.machineTextBox.Text = physicalAddressList.FirstOrDefault()?.ToString();
this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG"); this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG");
} }
@ -61,7 +67,7 @@ namespace Start
{ {
connection.Open(); connection.Open();
Log("数据库连接测试成功!", Color.Green); WinformLog("数据库连接测试成功!", Color.Green);
isCanDBConfig = false; isCanDBConfig = false;
serverTextBox.Enabled = isCanDBConfig; serverTextBox.Enabled = isCanDBConfig;
@ -71,16 +77,16 @@ namespace Start
selectPathBtn.Enabled = true; selectPathBtn.Enabled = true;
portBtn.Enabled = true; //portBtn.Enabled = true;
testDBBtn.Enabled = true; //testDBBtn.Enabled = true;
testServicebtn.Enabled = true; //testServicebtn.Enabled = true;
confimDeployBtn.Enabled = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log($"数据库连接测试失败:{ex.Message}", Color.Red); WinformLog($"数据库连接测试失败:{ex.Message}", Color.Red);
} }
finally finally
@ -89,31 +95,31 @@ namespace Start
} }
} }
private async void portBtn_Click(object sender, EventArgs e) private void portBtn_Click(object sender, EventArgs e)
{ {
if (int.TryParse(nginxPortTBox.Text, out vuePort) == false || int.TryParse(apiPortTBox.Text, out apiPort) == false) if (int.TryParse(nginxPortTBox.Text, out vuePort) == false || int.TryParse(apiPortTBox.Text, out apiPort) == false)
{ {
Log($"请输入合法的端口", Color.Red); WinformLog($"请输入合法的端口", Color.Red);
return; return;
} }
if (IsPortInUse(vuePort)) if (IsPortInUse(vuePort))
{ {
Log($"服务设置的前端端口被占用,请选择其他端口", Color.Red); WinformLog($"服务设置的前端端口被占用,请选择其他端口", Color.Red);
return; return;
} }
if (IsPortInUse(apiPort)) if (IsPortInUse(apiPort))
{ {
Log($"服务设置的后端端口被占用,请选择其他端口", Color.Red); WinformLog($"服务设置的后端端口被占用,请选择其他端口", Color.Red);
return; return;
} }
Log("端口测试成功!", Color.Green); WinformLog("端口测试成功!", Color.Green);
isPortTestOk = true; isPortTestOk = true;
@ -127,11 +133,11 @@ namespace Start
{ {
if (ServiceController.GetServices().Any(t => t.ServiceName == serviceNameTBox.Text)) if (ServiceController.GetServices().Any(t => t.ServiceName == serviceNameTBox.Text))
{ {
Log($"当前服务名称已存在,请更换", Color.Red); WinformLog($"当前服务名称已存在,请更换", Color.Red);
return; return;
} }
Log($"测试服务名称成功", Color.Green); WinformLog($"测试服务名称成功", Color.Green);
isServiceTestOk = true; isServiceTestOk = true;
} }
@ -139,7 +145,7 @@ namespace Start
{ {
if (string.IsNullOrWhiteSpace(dbNameTBox.Text)) if (string.IsNullOrWhiteSpace(dbNameTBox.Text))
{ {
Log($"请输入部署的数据库名称", Color.Red); WinformLog($"请输入部署的数据库名称", Color.Red);
return; return;
} }
@ -161,14 +167,14 @@ namespace Start
if (rowCount > 0) if (rowCount > 0)
{ {
Log($"{dbNameTBox.Text.Trim()}该数据库已存在。", Color.Red); WinformLog($"{dbNameTBox.Text.Trim()}该数据库已存在。", Color.Red);
return; return;
} }
} }
Log($"数据库名称测试成功", Color.Green); WinformLog($"数据库名称测试成功", Color.Green);
isDBNameTestOK = true; isDBNameTestOK = true;
@ -176,25 +182,30 @@ namespace Start
private void confimDeployBtn_Click(object sender, EventArgs e) private async void confimDeployBtn_Click(object sender, EventArgs e)
{ {
portBtn_Click(null, null);
testServicebtn_Click(null, null);
testDBBtn_Click(null, null);
if (string.IsNullOrWhiteSpace(this.folderPathTbox.Text) || isDBNameTestOK == false || isPortTestOk == false || isServiceTestOk == false) if (string.IsNullOrWhiteSpace(this.folderPathTbox.Text) || isDBNameTestOK == false || isPortTestOk == false || isServiceTestOk == false)
{ {
Log($"请选择部署路径,并分别测试端口,数据库名,服务名都成功才可以进行确认", Color.Red); WinformLog($"请选择部署路径,测试端口,数据库名,服务名都成功才可以进行确认", Color.Red);
return; return;
} }
Log($"部署配置确认成功", Color.Green); WinformLog($"部署配置确认成功", Color.Green);
activeBtn.Enabled = true; activeBtn.Enabled = true;
confimDeployBtn.Enabled = false; confimDeployBtn.Enabled = false;
portBtn.Enabled = false;
selectPathBtn.Enabled = false; selectPathBtn.Enabled = false;
testDBBtn.Enabled = false; //portBtn.Enabled = false;
testServicebtn.Enabled = false; //testDBBtn.Enabled = false;
//testServicebtn.Enabled = false;
nginxPortTBox.Enabled = false; nginxPortTBox.Enabled = false;
@ -230,17 +241,19 @@ namespace Start
return sb.ToString(); return sb.ToString();
} }
} }
private void Log(string message, Color color) private void WinformLog(string message, Color color)
{ {
if (InvokeRequired) if (InvokeRequired)
{ {
Invoke(Log, message, color); Invoke(WinformLog, message, color);
return; return;
} }
logTBox.SelectionColor = color; logTBox.SelectionColor = color;
logTBox.AppendText(message + Environment.NewLine); logTBox.AppendText($"{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")}: {message}" + Environment.NewLine);
Serilog.Log.Information(message);
} }
private async Task ProcessStandardInputAsync(Process process, string cmd, string workDirectory = "") private async Task ProcessStandardInputAsync(Process process, string cmd, string workDirectory = "")
@ -259,7 +272,7 @@ namespace Start
{ {
if (Md5($"{machineTextBox.Text}_XINGCANG") != KeySecreteTextBox.Text.Trim()) if (Md5($"{machineTextBox.Text}_XINGCANG") != KeySecreteTextBox.Text.Trim())
{ {
Log($"秘钥不正确,请联系供应商", Color.Red); WinformLog($"秘钥不正确,请联系供应商", Color.Red);
return; return;
} }
@ -282,6 +295,7 @@ namespace Start
var apiBinPath = Path.Combine(deployFoder, "APIPublish/IRacIS.Core.API.exe"); var apiBinPath = Path.Combine(deployFoder, "APIPublish/IRacIS.Core.API.exe");
var apiJsonConfigPath = Path.Combine(deployFoder, "APIPublish/appsettings.CertificateApply.json");
string nginxRarFilePath = Path.Combine(AppContext.BaseDirectory, $@"deploy\nginx-1.20.1.rar"); // 要解压缩的RAR文件路径 string nginxRarFilePath = Path.Combine(AppContext.BaseDirectory, $@"deploy\nginx-1.20.1.rar"); // 要解压缩的RAR文件路径
string apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "deploy/net6.0.rar"); // 要解压缩的RAR文件路径 string apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "deploy/net6.0.rar"); // 要解压缩的RAR文件路径
@ -307,7 +321,7 @@ namespace Start
#region 解压nginx 和前端部署的文件 #region 解压nginx 和前端部署的文件
Log($"开始解压 nginx 及前端部署 RAR文件", Color.Green); WinformLog($"开始解压 nginx 及前端部署 RAR文件", Color.Green);
await Task.Run(() => await Task.Run(() =>
@ -335,7 +349,7 @@ namespace Start
} }
Log($"nginx 及前端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green); WinformLog($"nginx 及前端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green);
@ -349,7 +363,7 @@ namespace Start
#region 解压后端部署的文件 #region 解压后端部署的文件
Log($"开始解压 后端部署 RAR文件", Color.Green); WinformLog($"开始解压 后端部署 RAR文件", Color.Green);
await Task.Run(() => await Task.Run(() =>
{ {
@ -373,7 +387,7 @@ namespace Start
} }
Log($"后端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green); WinformLog($"后端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green);
@ -390,7 +404,7 @@ namespace Start
if (!File.Exists(nginxConfigPath)) if (!File.Exists(nginxConfigPath))
{ {
MessageBox.Show("预设路径不存在nginx"); WinformLog("预设路径不存在nginx", Color.Red);
} }
var nginxConfig = File.ReadAllText(nginxConfigPath); var nginxConfig = File.ReadAllText(nginxConfigPath);
@ -411,7 +425,7 @@ namespace Start
// 指定工作目录即进入nginx.exe所在的目录 // 指定工作目录即进入nginx.exe所在的目录
psi.WorkingDirectory = nginxStartPath; psi.WorkingDirectory = nginxStartPath;
Log(" 开始启动 nginx 服务...", Color.Green); WinformLog(" 开始启动 nginx 服务...", Color.Green);
// 启动可执行文件 // 启动可执行文件
Process.Start(psi); Process.Start(psi);
@ -420,11 +434,11 @@ namespace Start
if (Process.GetProcesses().Any(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxStartPath))) if (Process.GetProcesses().Any(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxStartPath)))
{ {
Log(" nginx 服务启动成功", Color.Green); WinformLog(" nginx 服务启动成功", Color.Green);
} }
else else
{ {
Log(" nginx 服务启动失败", Color.Red); WinformLog(" nginx 服务启动失败", Color.Red);
return; return;
} }
#endregion #endregion
@ -441,7 +455,48 @@ namespace Start
File.WriteAllText($@"C:\ProgramData\.xingcang\config.json", JsonConvert.SerializeObject(configObj)); File.WriteAllText($@"C:\ProgramData\.xingcang\config.json", JsonConvert.SerializeObject(configObj));
Log("写入激活秘钥完成", Color.Green); WinformLog("写入激活秘钥完成", Color.Green);
#region 部署网站配置文件写入
WinformLog("开始写入部署网站服务配置文件...", Color.Green);
var appsettingsJson = File.ReadAllText(apiJsonConfigPath);
// 解析 JSON 字符串
var jObject = JObject.Parse(appsettingsJson);
// 获取 UpdateConfig 属性所在的节点
var updateConfigNode = jObject["ConnectionStrings"];
var connectionString = $"Server={serverTextBox.Text};Database={dbNameTBox.Text};User ID={usernameTextBox.Text};Password={passwordTextBox.Text};TrustServerCertificate=true";
updateConfigNode["RemoteNew"] = connectionString;
try
{
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
File.WriteAllText(apiJsonConfigPath, jObject.ToString());
}
}
catch (SqlException)
{
Console.WriteLine("连接字符串错误");
WinformLog($"连接字符串错误", Color.Red);
return;
}
WinformLog("部署网站服务配置文件写入并测试OK", Color.Green);
#endregion
var createStr = $@"sc create {serviceName} binPath= ""{apiBinPath} --urls=""http://127.0.0.1:{apiPort}"" --env CertificateApply"" DisplayName= ""{serviceDisplayName}"" start= auto"; var createStr = $@"sc create {serviceName} binPath= ""{apiBinPath} --urls=""http://127.0.0.1:{apiPort}"" --env CertificateApply"" DisplayName= ""{serviceDisplayName}"" start= auto";
@ -461,10 +516,10 @@ namespace Start
// 执行 sc create 命令来创建服务 // 执行 sc create 命令来创建服务
await ProcessStandardInputAsync(process, createStr); await ProcessStandardInputAsync(process, createStr);
Log($"创建服务{serviceName}...", Color.Green); WinformLog($"创建服务{serviceName}...", Color.Green);
Log($"执行初始化数据库脚本...", Color.Green); WinformLog($"执行初始化数据库脚本...", Color.Green);
//执行数据库脚本 //执行数据库脚本
//await ProcessStandardInputAsync(process, Path.Combine(AppContext.BaseDirectory, "deploy/sql/bin.bat")); //await ProcessStandardInputAsync(process, Path.Combine(AppContext.BaseDirectory, "deploy/sql/bin.bat"));
@ -474,11 +529,11 @@ namespace Start
await ProcessStandardInputAsync(process, $@" SQLCMD -v dbName = ""{dbNameTBox.Text}"" -i {AppContext.BaseDirectory}deploy\sql\data.sql "); await ProcessStandardInputAsync(process, $@" SQLCMD -v dbName = ""{dbNameTBox.Text}"" -i {AppContext.BaseDirectory}deploy\sql\data.sql ");
Log($"初始化数据库脚本执行结束", Color.Green); WinformLog($"初始化数据库脚本执行结束", Color.Green);
// 执行 sc start 启动服务 // 执行 sc start 启动服务
Log($"启动部署的后端服务...", Color.Green); WinformLog($"启动部署的后端服务...", Color.Green);
await ProcessStandardInputAsync(process, $"sc start {serviceName}"); await ProcessStandardInputAsync(process, $"sc start {serviceName}");
// 关闭进程流并等待进程退出 // 关闭进程流并等待进程退出
@ -488,14 +543,14 @@ namespace Start
ServiceController sc = new ServiceController(serviceName); ServiceController sc = new ServiceController(serviceName);
if (sc.Status == ServiceControllerStatus.Running) if (sc.Status == ServiceControllerStatus.Running)
{ {
Log($"后端服务启动成功", Color.Green); WinformLog($"后端服务启动成功", Color.Green);
Log($"部署工作已完成", Color.Green); WinformLog($"部署工作已完成", Color.Green);
try try
{ {
Log($"现在打开浏览器...", Color.Green); WinformLog($"现在打开浏览器...", Color.Green);
// Use ProcessStartInfo class // Use ProcessStartInfo class
var start = new ProcessStartInfo($"http://127.0.0.1:{vuePort}") var start = new ProcessStartInfo($"http://127.0.0.1:{vuePort}")
{ {
@ -512,7 +567,7 @@ namespace Start
} }
else else
{ {
Log($"后端服务启动失败", Color.Red); WinformLog($"后端服务启动失败", Color.Red);
} }
@ -530,7 +585,9 @@ namespace Start
{ {
folderPathTbox.Text = dialog.SelectedPath; folderPathTbox.Text = dialog.SelectedPath;
Log($"部署路径选择成功", Color.Green); confimDeployBtn.Enabled = true;
WinformLog($"部署路径选择成功", Color.Green);
#region 测试 停止Nginx #region 测试 停止Nginx
@ -570,6 +627,18 @@ namespace Start
} }
} }
private void btnCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(machineTextBox.Text);
WinformLog("机器码拷贝到剪切板成功!", Color.Green);
}
private void Main_Load(object sender, EventArgs e)
{
Serilog.Log.Logger = new LoggerConfiguration()
.WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
}
} }
} }

View File

@ -13,7 +13,6 @@
<None Remove="deploy\net6.0.rar" /> <None Remove="deploy\net6.0.rar" />
<None Remove="deploy\nginx-1.20.1.rar" /> <None Remove="deploy\nginx-1.20.1.rar" />
<None Remove="ServiceConfig.Json" /> <None Remove="ServiceConfig.Json" />
<None Remove="deploy\sql\bin.bat" />
<None Remove="deploy\sql\data.sql" /> <None Remove="deploy\sql\data.sql" />
<None Remove="deploy\sql\dbo.sql" /> <None Remove="deploy\sql\dbo.sql" />
<None Remove="deploy\sql\startNginx.bat" /> <None Remove="deploy\sql\startNginx.bat" />
@ -26,9 +25,6 @@
<Content Include="deploy\nginx-1.20.1.rar"> <Content Include="deploy\nginx-1.20.1.rar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="deploy\sql\bin.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="deploy\sql\data.sql"> <Content Include="deploy\sql\data.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
@ -39,6 +35,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharpCompress" Version="0.32.2" /> <PackageReference Include="SharpCompress" Version="0.32.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" /> <PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />

View File

@ -1,3 +0,0 @@
SQLCMD -i %~dp0\dbo.sql -v dbName="IRACISSSS"
pause
SQLCMD -i %~dp0\data.sql -v dbName="IRACISSSS"

Binary file not shown.