删除配置文件写入
parent
94dc00ddec
commit
b0f85fae1c
|
@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IRaCIS.Core.Infrastructure"
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Start", "Start\Start.csproj", "{D96F4B52-359C-43C9-8110-BAD1437F9280}"
|
||||
EndProject
|
||||
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{D9570CE2-B58C-4EBA-B4F8-9AB14AB2E1F1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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|x86.ActiveCfg = Debug|x86
|
||||
{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.Build.0 = Release|x86
|
||||
{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|x86.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
10787
Setup/Setup.vdproj
10787
Setup/Setup.vdproj
File diff suppressed because it is too large
Load Diff
|
@ -38,8 +38,6 @@
|
|||
label1 = new Label();
|
||||
groupBox2 = new GroupBox();
|
||||
confimDeployBtn = new Button();
|
||||
testDBBtn = new Button();
|
||||
testServicebtn = new Button();
|
||||
serviceDisplayNameTBox = new TextBox();
|
||||
serviceNameTBox = new TextBox();
|
||||
label11 = new Label();
|
||||
|
@ -49,12 +47,12 @@
|
|||
label9 = new Label();
|
||||
dbNameTBox = new TextBox();
|
||||
label8 = new Label();
|
||||
portBtn = new Button();
|
||||
apiPortTBox = new TextBox();
|
||||
nginxPortTBox = new TextBox();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
groupBox3 = new GroupBox();
|
||||
btnCopy = new Button();
|
||||
activeBtn = new Button();
|
||||
KeySecreteTextBox = new TextBox();
|
||||
machineTextBox = new TextBox();
|
||||
|
@ -81,16 +79,16 @@
|
|||
groupBox1.Controls.Add(label1);
|
||||
groupBox1.Location = new Point(24, 25);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(570, 187);
|
||||
groupBox1.Size = new Size(570, 230);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "第一步:数据库";
|
||||
groupBox1.Text = "第一步:验证数据库";
|
||||
//
|
||||
// connectButton
|
||||
//
|
||||
connectButton.Location = new Point(418, 69);
|
||||
connectButton.Location = new Point(195, 168);
|
||||
connectButton.Name = "connectButton";
|
||||
connectButton.Size = new Size(128, 49);
|
||||
connectButton.Size = new Size(128, 40);
|
||||
connectButton.TabIndex = 6;
|
||||
connectButton.Text = "测试连接";
|
||||
connectButton.UseVisualStyleBackColor = true;
|
||||
|
@ -98,15 +96,16 @@
|
|||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
passwordTextBox.Location = new Point(120, 134);
|
||||
passwordTextBox.Location = new Point(154, 129);
|
||||
passwordTextBox.Name = "passwordTextBox";
|
||||
passwordTextBox.PasswordChar = '*';
|
||||
passwordTextBox.Size = new Size(271, 23);
|
||||
passwordTextBox.TabIndex = 5;
|
||||
passwordTextBox.Text = "123456";
|
||||
//
|
||||
// usernameTextBox
|
||||
//
|
||||
usernameTextBox.Location = new Point(120, 89);
|
||||
usernameTextBox.Location = new Point(156, 82);
|
||||
usernameTextBox.Name = "usernameTextBox";
|
||||
usernameTextBox.Size = new Size(271, 23);
|
||||
usernameTextBox.TabIndex = 4;
|
||||
|
@ -114,7 +113,7 @@
|
|||
//
|
||||
// serverTextBox
|
||||
//
|
||||
serverTextBox.Location = new Point(120, 41);
|
||||
serverTextBox.Location = new Point(156, 37);
|
||||
serverTextBox.Name = "serverTextBox";
|
||||
serverTextBox.Size = new Size(271, 23);
|
||||
serverTextBox.TabIndex = 3;
|
||||
|
@ -123,7 +122,7 @@
|
|||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(26, 131);
|
||||
label3.Location = new Point(107, 131);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(32, 17);
|
||||
label3.TabIndex = 2;
|
||||
|
@ -132,7 +131,7 @@
|
|||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(26, 85);
|
||||
label2.Location = new Point(101, 83);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(44, 17);
|
||||
label2.TabIndex = 1;
|
||||
|
@ -141,7 +140,7 @@
|
|||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(26, 35);
|
||||
label1.Location = new Point(95, 38);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(56, 17);
|
||||
label1.TabIndex = 0;
|
||||
|
@ -150,8 +149,6 @@
|
|||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(confimDeployBtn);
|
||||
groupBox2.Controls.Add(testDBBtn);
|
||||
groupBox2.Controls.Add(testServicebtn);
|
||||
groupBox2.Controls.Add(serviceDisplayNameTBox);
|
||||
groupBox2.Controls.Add(serviceNameTBox);
|
||||
groupBox2.Controls.Add(label11);
|
||||
|
@ -161,71 +158,48 @@
|
|||
groupBox2.Controls.Add(label9);
|
||||
groupBox2.Controls.Add(dbNameTBox);
|
||||
groupBox2.Controls.Add(label8);
|
||||
groupBox2.Controls.Add(portBtn);
|
||||
groupBox2.Controls.Add(apiPortTBox);
|
||||
groupBox2.Controls.Add(nginxPortTBox);
|
||||
groupBox2.Controls.Add(label4);
|
||||
groupBox2.Controls.Add(label5);
|
||||
groupBox2.Location = new Point(24, 231);
|
||||
groupBox2.Location = new Point(24, 280);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(570, 439);
|
||||
groupBox2.Size = new Size(570, 418);
|
||||
groupBox2.TabIndex = 1;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "第二步: 部署配置";
|
||||
groupBox2.Text = "第二步: 部署参数配置";
|
||||
//
|
||||
// confimDeployBtn
|
||||
//
|
||||
confimDeployBtn.Enabled = false;
|
||||
confimDeployBtn.Location = new Point(220, 369);
|
||||
confimDeployBtn.Location = new Point(195, 353);
|
||||
confimDeployBtn.Name = "confimDeployBtn";
|
||||
confimDeployBtn.Size = new Size(128, 49);
|
||||
confimDeployBtn.Size = new Size(128, 40);
|
||||
confimDeployBtn.TabIndex = 19;
|
||||
confimDeployBtn.Text = "确认部署配置";
|
||||
confimDeployBtn.UseVisualStyleBackColor = true;
|
||||
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.Location = new Point(197, 308);
|
||||
serviceDisplayNameTBox.Location = new Point(152, 303);
|
||||
serviceDisplayNameTBox.Name = "serviceDisplayNameTBox";
|
||||
serviceDisplayNameTBox.Size = new Size(197, 23);
|
||||
serviceDisplayNameTBox.Size = new Size(259, 23);
|
||||
serviceDisplayNameTBox.TabIndex = 16;
|
||||
serviceDisplayNameTBox.Text = "EI_Image_Viewer_DisplayName";
|
||||
//
|
||||
// serviceNameTBox
|
||||
//
|
||||
serviceNameTBox.Location = new Point(197, 251);
|
||||
serviceNameTBox.Location = new Point(152, 248);
|
||||
serviceNameTBox.Name = "serviceNameTBox";
|
||||
serviceNameTBox.Size = new Size(197, 23);
|
||||
serviceNameTBox.Size = new Size(259, 23);
|
||||
serviceNameTBox.TabIndex = 15;
|
||||
serviceNameTBox.Text = "EI_Image_Viewer";
|
||||
//
|
||||
// label11
|
||||
//
|
||||
label11.AutoSize = true;
|
||||
label11.Location = new Point(20, 308);
|
||||
label11.Location = new Point(11, 304);
|
||||
label11.Name = "label11";
|
||||
label11.Size = new Size(128, 17);
|
||||
label11.TabIndex = 14;
|
||||
|
@ -234,7 +208,7 @@
|
|||
// label10
|
||||
//
|
||||
label10.AutoSize = true;
|
||||
label10.Location = new Point(20, 254);
|
||||
label10.Location = new Point(35, 250);
|
||||
label10.Name = "label10";
|
||||
label10.Size = new Size(104, 17);
|
||||
label10.TabIndex = 13;
|
||||
|
@ -243,79 +217,68 @@
|
|||
// selectPathBtn
|
||||
//
|
||||
selectPathBtn.Enabled = false;
|
||||
selectPathBtn.Location = new Point(417, 44);
|
||||
selectPathBtn.Location = new Point(429, 43);
|
||||
selectPathBtn.Name = "selectPathBtn";
|
||||
selectPathBtn.Size = new Size(128, 31);
|
||||
selectPathBtn.Size = new Size(118, 27);
|
||||
selectPathBtn.TabIndex = 12;
|
||||
selectPathBtn.Text = "选择部署路径";
|
||||
selectPathBtn.Text = "选择";
|
||||
selectPathBtn.UseVisualStyleBackColor = true;
|
||||
selectPathBtn.Click += selectPathBtn_Click;
|
||||
//
|
||||
// folderPathTbox
|
||||
//
|
||||
folderPathTbox.Enabled = false;
|
||||
folderPathTbox.Location = new Point(119, 48);
|
||||
folderPathTbox.Location = new Point(152, 43);
|
||||
folderPathTbox.Name = "folderPathTbox";
|
||||
folderPathTbox.Size = new Size(271, 23);
|
||||
folderPathTbox.Size = new Size(259, 23);
|
||||
folderPathTbox.TabIndex = 11;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
label9.AutoSize = true;
|
||||
label9.Location = new Point(20, 51);
|
||||
label9.Location = new Point(83, 43);
|
||||
label9.Name = "label9";
|
||||
label9.Size = new Size(92, 17);
|
||||
label9.Size = new Size(56, 17);
|
||||
label9.TabIndex = 10;
|
||||
label9.Text = "网站部署文件夹";
|
||||
label9.Text = "部署路径";
|
||||
//
|
||||
// dbNameTBox
|
||||
//
|
||||
dbNameTBox.Location = new Point(198, 196);
|
||||
dbNameTBox.Location = new Point(152, 191);
|
||||
dbNameTBox.Name = "dbNameTBox";
|
||||
dbNameTBox.Size = new Size(197, 23);
|
||||
dbNameTBox.Size = new Size(259, 23);
|
||||
dbNameTBox.TabIndex = 9;
|
||||
dbNameTBox.Text = "IRaCIS";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
label8.AutoSize = true;
|
||||
label8.Location = new Point(20, 201);
|
||||
label8.Location = new Point(47, 197);
|
||||
label8.Name = "label8";
|
||||
label8.Size = new Size(92, 17);
|
||||
label8.TabIndex = 8;
|
||||
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.Location = new Point(198, 151);
|
||||
apiPortTBox.Location = new Point(152, 146);
|
||||
apiPortTBox.Name = "apiPortTBox";
|
||||
apiPortTBox.Size = new Size(197, 23);
|
||||
apiPortTBox.Size = new Size(259, 23);
|
||||
apiPortTBox.TabIndex = 5;
|
||||
apiPortTBox.Text = "7100";
|
||||
//
|
||||
// nginxPortTBox
|
||||
//
|
||||
nginxPortTBox.Location = new Point(197, 103);
|
||||
nginxPortTBox.Location = new Point(152, 98);
|
||||
nginxPortTBox.Name = "nginxPortTBox";
|
||||
nginxPortTBox.Size = new Size(197, 23);
|
||||
nginxPortTBox.Size = new Size(259, 23);
|
||||
nginxPortTBox.TabIndex = 4;
|
||||
nginxPortTBox.Text = "9520";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(20, 157);
|
||||
label4.Location = new Point(11, 153);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(128, 17);
|
||||
label4.TabIndex = 3;
|
||||
|
@ -324,7 +287,7 @@
|
|||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(20, 107);
|
||||
label5.Location = new Point(35, 100);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(104, 17);
|
||||
label5.TabIndex = 2;
|
||||
|
@ -332,25 +295,36 @@
|
|||
//
|
||||
// groupBox3
|
||||
//
|
||||
groupBox3.Controls.Add(btnCopy);
|
||||
groupBox3.Controls.Add(activeBtn);
|
||||
groupBox3.Controls.Add(KeySecreteTextBox);
|
||||
groupBox3.Controls.Add(machineTextBox);
|
||||
groupBox3.Controls.Add(machineCodeLB);
|
||||
groupBox3.Controls.Add(label6);
|
||||
groupBox3.Controls.Add(label7);
|
||||
groupBox3.Location = new Point(12, 693);
|
||||
groupBox3.Location = new Point(24, 713);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Size = new Size(582, 183);
|
||||
groupBox3.Size = new Size(570, 221);
|
||||
groupBox3.TabIndex = 2;
|
||||
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.Enabled = false;
|
||||
activeBtn.Location = new Point(430, 69);
|
||||
activeBtn.Location = new Point(195, 146);
|
||||
activeBtn.Name = "activeBtn";
|
||||
activeBtn.Size = new Size(128, 49);
|
||||
activeBtn.Size = new Size(128, 40);
|
||||
activeBtn.TabIndex = 9;
|
||||
activeBtn.Text = "激活并部署";
|
||||
activeBtn.UseVisualStyleBackColor = true;
|
||||
|
@ -358,18 +332,17 @@
|
|||
//
|
||||
// KeySecreteTextBox
|
||||
//
|
||||
KeySecreteTextBox.Location = new Point(131, 101);
|
||||
KeySecreteTextBox.Multiline = true;
|
||||
KeySecreteTextBox.Location = new Point(152, 101);
|
||||
KeySecreteTextBox.Name = "KeySecreteTextBox";
|
||||
KeySecreteTextBox.Size = new Size(271, 42);
|
||||
KeySecreteTextBox.Size = new Size(259, 23);
|
||||
KeySecreteTextBox.TabIndex = 8;
|
||||
//
|
||||
// machineTextBox
|
||||
//
|
||||
machineTextBox.Location = new Point(132, 45);
|
||||
machineTextBox.Location = new Point(152, 51);
|
||||
machineTextBox.Name = "machineTextBox";
|
||||
machineTextBox.ReadOnly = true;
|
||||
machineTextBox.Size = new Size(271, 23);
|
||||
machineTextBox.Size = new Size(259, 23);
|
||||
machineTextBox.TabIndex = 7;
|
||||
//
|
||||
// machineCodeLB
|
||||
|
@ -383,7 +356,7 @@
|
|||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(26, 101);
|
||||
label6.Location = new Point(95, 101);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(44, 17);
|
||||
label6.TabIndex = 5;
|
||||
|
@ -392,7 +365,7 @@
|
|||
// label7
|
||||
//
|
||||
label7.AutoSize = true;
|
||||
label7.Location = new Point(26, 51);
|
||||
label7.Location = new Point(95, 51);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(44, 17);
|
||||
label7.TabIndex = 4;
|
||||
|
@ -403,16 +376,16 @@
|
|||
groupBox4.Controls.Add(logTBox);
|
||||
groupBox4.Location = new Point(618, 25);
|
||||
groupBox4.Name = "groupBox4";
|
||||
groupBox4.Size = new Size(391, 851);
|
||||
groupBox4.Size = new Size(391, 890);
|
||||
groupBox4.TabIndex = 4;
|
||||
groupBox4.TabStop = false;
|
||||
groupBox4.Text = "部署提示日志";
|
||||
groupBox4.Text = "部署日志";
|
||||
//
|
||||
// logTBox
|
||||
//
|
||||
logTBox.Location = new Point(6, 22);
|
||||
logTBox.Name = "logTBox";
|
||||
logTBox.Size = new Size(359, 816);
|
||||
logTBox.Size = new Size(359, 862);
|
||||
logTBox.TabIndex = 0;
|
||||
logTBox.Text = "";
|
||||
//
|
||||
|
@ -420,13 +393,14 @@
|
|||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1021, 914);
|
||||
ClientSize = new Size(1021, 946);
|
||||
Controls.Add(groupBox4);
|
||||
Controls.Add(groupBox3);
|
||||
Controls.Add(groupBox2);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "Main";
|
||||
Text = "EI Image Viewer";
|
||||
Load += Main_Load;
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
groupBox2.ResumeLayout(false);
|
||||
|
@ -453,7 +427,6 @@
|
|||
private Label label4;
|
||||
private Label label5;
|
||||
private GroupBox groupBox3;
|
||||
private Button portBtn;
|
||||
private Label machineCodeLB;
|
||||
private Label label6;
|
||||
private Label label7;
|
||||
|
@ -472,8 +445,7 @@
|
|||
private TextBox serviceNameTBox;
|
||||
private Label label11;
|
||||
private Label label10;
|
||||
private Button testDBBtn;
|
||||
private Button testServicebtn;
|
||||
private Button confimDeployBtn;
|
||||
private Button btnCopy;
|
||||
}
|
||||
}
|
157
Start/Main.cs
157
Start/Main.cs
|
@ -25,6 +25,8 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|||
using System.Security.Policy;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
|
||||
using System.Data.SqlTypes;
|
||||
using Serilog;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Start
|
||||
{
|
||||
|
@ -47,6 +49,10 @@ namespace Start
|
|||
|
||||
this.machineTextBox.Text = physicalAddressList.FirstOrDefault()?.ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG");
|
||||
}
|
||||
|
||||
|
@ -61,7 +67,7 @@ namespace Start
|
|||
{
|
||||
connection.Open();
|
||||
|
||||
Log("数据库连接测试成功!", Color.Green);
|
||||
WinformLog("数据库连接测试成功!", Color.Green);
|
||||
|
||||
isCanDBConfig = false;
|
||||
serverTextBox.Enabled = isCanDBConfig;
|
||||
|
@ -71,16 +77,16 @@ namespace Start
|
|||
|
||||
|
||||
selectPathBtn.Enabled = true;
|
||||
portBtn.Enabled = true;
|
||||
testDBBtn.Enabled = true;
|
||||
testServicebtn.Enabled = true;
|
||||
confimDeployBtn.Enabled = true;
|
||||
//portBtn.Enabled = true;
|
||||
//testDBBtn.Enabled = true;
|
||||
//testServicebtn.Enabled = true;
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log($"数据库连接测试失败:{ex.Message}", Color.Red);
|
||||
WinformLog($"数据库连接测试失败:{ex.Message}", Color.Red);
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
Log($"请输入合法的端口", Color.Red);
|
||||
WinformLog($"请输入合法的端口", Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsPortInUse(vuePort))
|
||||
{
|
||||
Log($"服务设置的前端端口被占用,请选择其他端口", Color.Red);
|
||||
WinformLog($"服务设置的前端端口被占用,请选择其他端口", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
if (IsPortInUse(apiPort))
|
||||
{
|
||||
Log($"服务设置的后端端口被占用,请选择其他端口", Color.Red);
|
||||
WinformLog($"服务设置的后端端口被占用,请选择其他端口", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log("端口测试成功!", Color.Green);
|
||||
WinformLog("端口测试成功!", Color.Green);
|
||||
|
||||
isPortTestOk = true;
|
||||
|
||||
|
@ -127,11 +133,11 @@ namespace Start
|
|||
{
|
||||
if (ServiceController.GetServices().Any(t => t.ServiceName == serviceNameTBox.Text))
|
||||
{
|
||||
Log($"当前服务名称已存在,请更换", Color.Red);
|
||||
WinformLog($"当前服务名称已存在,请更换", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
Log($"测试服务名称成功", Color.Green);
|
||||
WinformLog($"测试服务名称成功", Color.Green);
|
||||
isServiceTestOk = true;
|
||||
}
|
||||
|
||||
|
@ -139,7 +145,7 @@ namespace Start
|
|||
{
|
||||
if (string.IsNullOrWhiteSpace(dbNameTBox.Text))
|
||||
{
|
||||
Log($"请输入部署的数据库名称", Color.Red);
|
||||
WinformLog($"请输入部署的数据库名称", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -161,14 +167,14 @@ namespace Start
|
|||
if (rowCount > 0)
|
||||
{
|
||||
|
||||
Log($"{dbNameTBox.Text.Trim()}该数据库已存在。", Color.Red);
|
||||
WinformLog($"{dbNameTBox.Text.Trim()}该数据库已存在。", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Log($"数据库名称测试成功", Color.Green);
|
||||
WinformLog($"数据库名称测试成功", Color.Green);
|
||||
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)
|
||||
{
|
||||
Log($"请选择部署路径,并分别测试端口,数据库名,服务名都成功才可以进行确认", Color.Red);
|
||||
WinformLog($"请选择部署路径,测试的端口,数据库名,服务名都成功才可以进行确认", Color.Red);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Log($"部署配置确认成功", Color.Green);
|
||||
WinformLog($"部署配置确认成功", Color.Green);
|
||||
|
||||
activeBtn.Enabled = true;
|
||||
|
||||
confimDeployBtn.Enabled = false;
|
||||
portBtn.Enabled = false;
|
||||
|
||||
selectPathBtn.Enabled = false;
|
||||
testDBBtn.Enabled = false;
|
||||
testServicebtn.Enabled = false;
|
||||
//portBtn.Enabled = false;
|
||||
//testDBBtn.Enabled = false;
|
||||
//testServicebtn.Enabled = false;
|
||||
|
||||
|
||||
nginxPortTBox.Enabled = false;
|
||||
|
@ -230,17 +241,19 @@ namespace Start
|
|||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
private void Log(string message, Color color)
|
||||
private void WinformLog(string message, Color color)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(Log, message, color);
|
||||
Invoke(WinformLog, message, color);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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 = "")
|
||||
|
@ -259,7 +272,7 @@ namespace Start
|
|||
{
|
||||
if (Md5($"{machineTextBox.Text}_XINGCANG") != KeySecreteTextBox.Text.Trim())
|
||||
{
|
||||
Log($"秘钥不正确,请联系供应商", Color.Red);
|
||||
WinformLog($"秘钥不正确,请联系供应商", Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -282,6 +295,7 @@ namespace Start
|
|||
|
||||
|
||||
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 apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "deploy/net6.0.rar"); // 要解压缩的RAR文件路径
|
||||
|
@ -307,7 +321,7 @@ namespace Start
|
|||
|
||||
#region 解压nginx 和前端部署的文件
|
||||
|
||||
Log($"开始解压 nginx 及前端部署 RAR文件", Color.Green);
|
||||
WinformLog($"开始解压 nginx 及前端部署 RAR文件", Color.Green);
|
||||
|
||||
|
||||
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 解压后端部署的文件
|
||||
|
||||
Log($"开始解压 后端部署 RAR文件", Color.Green);
|
||||
WinformLog($"开始解压 后端部署 RAR文件", Color.Green);
|
||||
|
||||
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))
|
||||
{
|
||||
MessageBox.Show("预设路径不存在nginx");
|
||||
WinformLog("预设路径不存在nginx", Color.Red);
|
||||
}
|
||||
|
||||
var nginxConfig = File.ReadAllText(nginxConfigPath);
|
||||
|
@ -411,7 +425,7 @@ namespace Start
|
|||
// 指定工作目录,即进入nginx.exe所在的目录
|
||||
psi.WorkingDirectory = nginxStartPath;
|
||||
|
||||
Log(" 开始启动 nginx 服务...", Color.Green);
|
||||
WinformLog(" 开始启动 nginx 服务...", Color.Green);
|
||||
// 启动可执行文件
|
||||
Process.Start(psi);
|
||||
|
||||
|
@ -420,11 +434,11 @@ namespace Start
|
|||
|
||||
if (Process.GetProcesses().Any(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxStartPath)))
|
||||
{
|
||||
Log(" nginx 服务启动成功", Color.Green);
|
||||
WinformLog(" nginx 服务启动成功", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(" nginx 服务启动失败", Color.Red);
|
||||
WinformLog(" nginx 服务启动失败", Color.Red);
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
@ -441,7 +455,48 @@ namespace Start
|
|||
|
||||
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";
|
||||
|
@ -461,10 +516,10 @@ namespace Start
|
|||
|
||||
// 执行 sc create 命令来创建服务
|
||||
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"));
|
||||
|
@ -474,11 +529,11 @@ namespace Start
|
|||
await ProcessStandardInputAsync(process, $@" SQLCMD -v dbName = ""{dbNameTBox.Text}"" -i {AppContext.BaseDirectory}deploy\sql\data.sql ");
|
||||
|
||||
|
||||
Log($"初始化数据库脚本执行结束", Color.Green);
|
||||
WinformLog($"初始化数据库脚本执行结束", Color.Green);
|
||||
|
||||
// 执行 sc start 启动服务
|
||||
|
||||
Log($"启动部署的后端服务...", Color.Green);
|
||||
WinformLog($"启动部署的后端服务...", Color.Green);
|
||||
await ProcessStandardInputAsync(process, $"sc start {serviceName}");
|
||||
|
||||
// 关闭进程流并等待进程退出
|
||||
|
@ -488,14 +543,14 @@ namespace Start
|
|||
ServiceController sc = new ServiceController(serviceName);
|
||||
if (sc.Status == ServiceControllerStatus.Running)
|
||||
{
|
||||
Log($"后端服务启动成功", Color.Green);
|
||||
WinformLog($"后端服务启动成功", Color.Green);
|
||||
|
||||
|
||||
Log($"部署工作已完成", Color.Green);
|
||||
WinformLog($"部署工作已完成", Color.Green);
|
||||
|
||||
try
|
||||
{
|
||||
Log($"现在打开浏览器...", Color.Green);
|
||||
WinformLog($"现在打开浏览器...", Color.Green);
|
||||
// Use ProcessStartInfo class
|
||||
var start = new ProcessStartInfo($"http://127.0.0.1:{vuePort}")
|
||||
{
|
||||
|
@ -512,7 +567,7 @@ namespace Start
|
|||
}
|
||||
else
|
||||
{
|
||||
Log($"后端服务启动失败", Color.Red);
|
||||
WinformLog($"后端服务启动失败", Color.Red);
|
||||
}
|
||||
|
||||
|
||||
|
@ -530,7 +585,9 @@ namespace Start
|
|||
{
|
||||
folderPathTbox.Text = dialog.SelectedPath;
|
||||
|
||||
Log($"部署路径选择成功", Color.Green);
|
||||
confimDeployBtn.Enabled = true;
|
||||
|
||||
WinformLog($"部署路径选择成功", Color.Green);
|
||||
|
||||
#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<None Remove="deploy\net6.0.rar" />
|
||||
<None Remove="deploy\nginx-1.20.1.rar" />
|
||||
<None Remove="ServiceConfig.Json" />
|
||||
<None Remove="deploy\sql\bin.bat" />
|
||||
<None Remove="deploy\sql\data.sql" />
|
||||
<None Remove="deploy\sql\dbo.sql" />
|
||||
<None Remove="deploy\sql\startNginx.bat" />
|
||||
|
@ -26,9 +25,6 @@
|
|||
<Content Include="deploy\nginx-1.20.1.rar">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="deploy\sql\bin.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="deploy\sql\data.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
@ -39,6 +35,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<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="System.Data.SqlClient" Version="4.8.3" />
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
|
||||
|
|
|
@ -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.
Loading…
Reference in New Issue