From 94dc00ddec427ac093f207642604d8d5891193ef Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 17 Apr 2023 08:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Production.json | 39 ----- .../Service/Management/UserService.cs | 10 +- Start/Main.Designer.cs | 71 ++++---- Start/Main.cs | 158 ++++++++++-------- Start/Start.csproj | 3 - Start/deploy/ServiceConfig.Json | 5 - 6 files changed, 128 insertions(+), 158 deletions(-) delete mode 100644 IRaCIS.Core.API/appsettings.Production.json delete mode 100644 Start/deploy/ServiceConfig.Json diff --git a/IRaCIS.Core.API/appsettings.Production.json b/IRaCIS.Core.API/appsettings.Production.json deleted file mode 100644 index 7daa550e..00000000 --- a/IRaCIS.Core.API/appsettings.Production.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - //"RootUrl": "http://123.56.181.144:8060/", - "ConnectionStrings": { - "RemoteNew": "Server=101.132.193.237,1433;Database=IRaCIS.Production;User ID=sa;Password=zhanying2021;TrustServerCertificate=true", - "Hangfire": "Server=101.132.193.237,1433;Database=Hangfire.IRaCIS.Production;User ID=sa;Password=zhanying2021;TrustServerCertificate=true" - }, - "BasicSystemConfig": { - - "OpenUserComplexPassword": true, - - "OpenSignDocumentBeforeWork": true, - - "OpenLoginLimit": true - }, - //"SystemEmailSendConfig": { - // "Port": 465, - // "Host": "smtp.163.com", - // "FromEmail": "zhou941003@qq.com", - // "FromName": "hangZhou", - // "AuthorizationCode": "sqfhlpfdvnexbcab" - //} - - "SystemEmailSendConfig": { - "Port": 465, - "Host": "smtp.qiye.aliyun.com", - "FromEmail": "IRC@extimaging.com", - "FromName": "IRC", - "AuthorizationCode": "ExtImg@2022" - } - - -} diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 2ae546c0..fbbe9b11 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -541,10 +541,12 @@ namespace IRaCIS.Application.Services _mapper.Map(model, user); - if (user.IsZhiZhun) - { - user.OrganizationName = AppSettings.DefaultInternalOrganizationName; - } + //if (user.IsZhiZhun) + //{ + // user.OrganizationName = AppSettings.DefaultInternalOrganizationName; + //} + + var success = await _userRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); diff --git a/Start/Main.Designer.cs b/Start/Main.Designer.cs index 81cad015..88fe107b 100644 --- a/Start/Main.Designer.cs +++ b/Start/Main.Designer.cs @@ -37,6 +37,7 @@ label2 = new Label(); label1 = new Label(); groupBox2 = new GroupBox(); + confimDeployBtn = new Button(); testDBBtn = new Button(); testServicebtn = new Button(); serviceDisplayNameTBox = new TextBox(); @@ -63,7 +64,6 @@ groupBox4 = new GroupBox(); logTBox = new RichTextBox(); folderBrowserDialog1 = new FolderBrowserDialog(); - confimDeployBtn = new Button(); groupBox1.SuspendLayout(); groupBox2.SuspendLayout(); groupBox3.SuspendLayout(); @@ -173,9 +173,21 @@ groupBox2.TabStop = false; groupBox2.Text = "第二步: 部署配置"; // + // confimDeployBtn + // + confimDeployBtn.Enabled = false; + confimDeployBtn.Location = new Point(220, 369); + confimDeployBtn.Name = "confimDeployBtn"; + confimDeployBtn.Size = new Size(128, 49); + confimDeployBtn.TabIndex = 19; + confimDeployBtn.Text = "确认部署配置"; + confimDeployBtn.UseVisualStyleBackColor = true; + confimDeployBtn.Click += confimDeployBtn_Click; + // // testDBBtn // - testDBBtn.Location = new Point(423, 191); + testDBBtn.Enabled = false; + testDBBtn.Location = new Point(417, 196); testDBBtn.Name = "testDBBtn"; testDBBtn.Size = new Size(128, 49); testDBBtn.TabIndex = 18; @@ -185,7 +197,8 @@ // // testServicebtn // - testServicebtn.Location = new Point(418, 271); + testServicebtn.Enabled = false; + testServicebtn.Location = new Point(417, 276); testServicebtn.Name = "testServicebtn"; testServicebtn.Size = new Size(128, 49); testServicebtn.TabIndex = 17; @@ -195,7 +208,7 @@ // // serviceDisplayNameTBox // - serviceDisplayNameTBox.Location = new Point(198, 303); + serviceDisplayNameTBox.Location = new Point(197, 308); serviceDisplayNameTBox.Name = "serviceDisplayNameTBox"; serviceDisplayNameTBox.Size = new Size(197, 23); serviceDisplayNameTBox.TabIndex = 16; @@ -203,7 +216,7 @@ // // serviceNameTBox // - serviceNameTBox.Location = new Point(198, 246); + serviceNameTBox.Location = new Point(197, 251); serviceNameTBox.Name = "serviceNameTBox"; serviceNameTBox.Size = new Size(197, 23); serviceNameTBox.TabIndex = 15; @@ -212,7 +225,7 @@ // label11 // label11.AutoSize = true; - label11.Location = new Point(21, 303); + label11.Location = new Point(20, 308); label11.Name = "label11"; label11.Size = new Size(128, 17); label11.TabIndex = 14; @@ -221,7 +234,7 @@ // label10 // label10.AutoSize = true; - label10.Location = new Point(21, 249); + label10.Location = new Point(20, 254); label10.Name = "label10"; label10.Size = new Size(104, 17); label10.TabIndex = 13; @@ -229,7 +242,8 @@ // // selectPathBtn // - selectPathBtn.Location = new Point(418, 39); + selectPathBtn.Enabled = false; + selectPathBtn.Location = new Point(417, 44); selectPathBtn.Name = "selectPathBtn"; selectPathBtn.Size = new Size(128, 31); selectPathBtn.TabIndex = 12; @@ -240,7 +254,7 @@ // folderPathTbox // folderPathTbox.Enabled = false; - folderPathTbox.Location = new Point(120, 43); + folderPathTbox.Location = new Point(119, 48); folderPathTbox.Name = "folderPathTbox"; folderPathTbox.Size = new Size(271, 23); folderPathTbox.TabIndex = 11; @@ -248,7 +262,7 @@ // label9 // label9.AutoSize = true; - label9.Location = new Point(21, 46); + label9.Location = new Point(20, 51); label9.Name = "label9"; label9.Size = new Size(92, 17); label9.TabIndex = 10; @@ -256,7 +270,7 @@ // // dbNameTBox // - dbNameTBox.Location = new Point(199, 191); + dbNameTBox.Location = new Point(198, 196); dbNameTBox.Name = "dbNameTBox"; dbNameTBox.Size = new Size(197, 23); dbNameTBox.TabIndex = 9; @@ -265,7 +279,7 @@ // label8 // label8.AutoSize = true; - label8.Location = new Point(21, 196); + label8.Location = new Point(20, 201); label8.Name = "label8"; label8.Size = new Size(92, 17); label8.TabIndex = 8; @@ -273,7 +287,8 @@ // // portBtn // - portBtn.Location = new Point(423, 109); + portBtn.Enabled = false; + portBtn.Location = new Point(417, 114); portBtn.Name = "portBtn"; portBtn.Size = new Size(128, 49); portBtn.TabIndex = 7; @@ -283,7 +298,7 @@ // // apiPortTBox // - apiPortTBox.Location = new Point(199, 146); + apiPortTBox.Location = new Point(198, 151); apiPortTBox.Name = "apiPortTBox"; apiPortTBox.Size = new Size(197, 23); apiPortTBox.TabIndex = 5; @@ -291,7 +306,7 @@ // // nginxPortTBox // - nginxPortTBox.Location = new Point(198, 98); + nginxPortTBox.Location = new Point(197, 103); nginxPortTBox.Name = "nginxPortTBox"; nginxPortTBox.Size = new Size(197, 23); nginxPortTBox.TabIndex = 4; @@ -300,7 +315,7 @@ // label4 // label4.AutoSize = true; - label4.Location = new Point(21, 152); + label4.Location = new Point(20, 157); label4.Name = "label4"; label4.Size = new Size(128, 17); label4.TabIndex = 3; @@ -309,7 +324,7 @@ // label5 // label5.AutoSize = true; - label5.Location = new Point(21, 102); + label5.Location = new Point(20, 107); label5.Name = "label5"; label5.Size = new Size(104, 17); label5.TabIndex = 2; @@ -332,6 +347,7 @@ // // activeBtn // + activeBtn.Enabled = false; activeBtn.Location = new Point(430, 69); activeBtn.Name = "activeBtn"; activeBtn.Size = new Size(128, 49); @@ -385,31 +401,21 @@ // groupBox4 // groupBox4.Controls.Add(logTBox); - groupBox4.Location = new Point(618, 32); + groupBox4.Location = new Point(618, 25); groupBox4.Name = "groupBox4"; - groupBox4.Size = new Size(391, 791); + groupBox4.Size = new Size(391, 851); groupBox4.TabIndex = 4; groupBox4.TabStop = false; - groupBox4.Text = "运行日志"; + groupBox4.Text = "部署提示日志"; // // logTBox // - logTBox.Location = new Point(6, 35); + logTBox.Location = new Point(6, 22); logTBox.Name = "logTBox"; - logTBox.Size = new Size(359, 738); + logTBox.Size = new Size(359, 816); logTBox.TabIndex = 0; logTBox.Text = ""; // - // confimDeployBtn - // - confimDeployBtn.Location = new Point(198, 370); - confimDeployBtn.Name = "confimDeployBtn"; - confimDeployBtn.Size = new Size(128, 49); - confimDeployBtn.TabIndex = 19; - confimDeployBtn.Text = "确认部署配置"; - confimDeployBtn.UseVisualStyleBackColor = true; - confimDeployBtn.Click += confimDeployBtn_Click; - // // Main // AutoScaleDimensions = new SizeF(7F, 17F); @@ -421,7 +427,6 @@ Controls.Add(groupBox1); Name = "Main"; Text = "EI Image Viewer"; - Load += Main_Load; groupBox1.ResumeLayout(false); groupBox1.PerformLayout(); groupBox2.ResumeLayout(false); diff --git a/Start/Main.cs b/Start/Main.cs index a769a986..f2b6ab91 100644 --- a/Start/Main.cs +++ b/Start/Main.cs @@ -35,9 +35,9 @@ namespace Start private bool isPortTestOk = false; - private bool isServiceTestOk=false; + private bool isServiceTestOk = false; - private bool isDBNameTestOK=false; + private bool isDBNameTestOK = false; public Main() { @@ -50,34 +50,6 @@ namespace Start this.KeySecreteTextBox.Text = Md5($"{this.machineTextBox.Text}_XINGCANG"); } - - - - private void Main_Load(object sender, EventArgs e) - { - portBtn.Enabled = false; - activeBtn.Enabled = false; - - //serverTextBox.DataBindings.Add(new Binding("Enabled", this, "isCanDBConfig")); - //usernameTextBox.DataBindings.Add(new Binding("Enabled", this, "isCanDBConfig")); - //passwordTextBox.DataBindings.Add(new Binding("Enabled", this, "isCanDBConfig")); - - - - //nginxPortTBox.DataBindings.Add(new Binding("Enabled", this, "isCanServerConfig")); - //apiPortTBox.DataBindings.Add(new Binding("Enabled", this, "isCanServerConfig")); - //dbNameTBox.DataBindings.Add(new Binding("Enabled", this, "isCanServerConfig")); - - - - //connectButton.DataBindings.Add(new Binding("Enabled", this, "isCanDBConfig")); - - - } - - - - int apiPort = 7100; int vuePort = 9527; private void connectButton_Click(object sender, EventArgs e) @@ -89,7 +61,7 @@ namespace Start { connection.Open(); - Log("数据库连接成功!", Color.Green); + Log("数据库连接测试成功!", Color.Green); isCanDBConfig = false; serverTextBox.Enabled = isCanDBConfig; @@ -97,13 +69,18 @@ namespace Start passwordTextBox.Enabled = isCanDBConfig; connectButton.Enabled = false; + + selectPathBtn.Enabled = true; portBtn.Enabled = true; + testDBBtn.Enabled = true; + testServicebtn.Enabled = true; + confimDeployBtn.Enabled = true; } catch (Exception ex) { - Log($"数据库连接失败:{ex.Message}", Color.Red); + Log($"数据库连接测试失败:{ex.Message}", Color.Red); } finally @@ -114,39 +91,6 @@ namespace Start private async void portBtn_Click(object sender, EventArgs e) { - #region 测试 停止Nginx - string nginxPath = Path.Combine(AppContext.BaseDirectory, @$"deploy\nginx-1.20.1\"); - - var serviceConfig = await File.ReadAllTextAsync("deploy/ServiceConfig.json"); - - var jObject = JObject.Parse(serviceConfig); - - #region 创建进程执行命令 - - Process process = new Process(); - process.StartInfo.FileName = "cmd.exe"; - process.StartInfo.RedirectStandardInput = true; - process.StartInfo.UseShellExecute = false; - process.StartInfo.CreateNoWindow = true; // 不创建新窗口 - process.Start(); - - var proList = Process.GetProcesses().Where(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxPath)); - - foreach (var item in proList) - { - item.Kill(); - } - - - await ProcessStandardInputAsync(process, $"sc stop {jObject["serviceName"].ToString()}"); - - process.StandardInput.Close(); - process.WaitForExit(); - - #endregion - - #endregion - if (int.TryParse(nginxPortTBox.Text, out vuePort) == false || int.TryParse(apiPortTBox.Text, out apiPort) == false) { @@ -187,7 +131,7 @@ namespace Start return; } - + Log($"测试服务名称成功", Color.Green); isServiceTestOk = true; } @@ -224,9 +168,10 @@ namespace Start } + Log($"数据库名称测试成功", Color.Green); isDBNameTestOK = true; - + } @@ -234,13 +179,29 @@ namespace Start private void confimDeployBtn_Click(object sender, EventArgs e) { + if (string.IsNullOrWhiteSpace(this.folderPathTbox.Text) || isDBNameTestOK == false || isPortTestOk == false || isServiceTestOk == false) + { + Log($"请选择部署路径,并分别测试端口,数据库名,服务名都成功才可以进行确认", Color.Red); + + return; + } + + Log($"部署配置确认成功", Color.Green); + activeBtn.Enabled = true; + confimDeployBtn.Enabled = false; + portBtn.Enabled = false; + selectPathBtn.Enabled = false; + testDBBtn.Enabled = false; + testServicebtn.Enabled = false; + + nginxPortTBox.Enabled = false; apiPortTBox.Enabled = false; - portBtn.Enabled = false; - dbNameTBox.Enabled = false; + serviceNameTBox.Enabled = false; + serviceDisplayNameTBox.Enabled = false; } private static bool IsPortInUse(int port) @@ -296,6 +257,13 @@ namespace Start private async void activeBtn_Click(object sender, EventArgs e) { + if (Md5($"{machineTextBox.Text}_XINGCANG") != KeySecreteTextBox.Text.Trim()) + { + Log($"秘钥不正确,请联系供应商", Color.Red); + return; + } + + this.activeBtn.Enabled = false; @@ -326,7 +294,7 @@ namespace Start startInfo.FileName = "cmd.exe"; // 指定要启动的应用程序 startInfo.RedirectStandardInput = true; startInfo.UseShellExecute = false; - //startInfo.CreateNoWindow = true; + startInfo.CreateNoWindow = true; // 创建新进程并启动 var process = new Process(); @@ -487,9 +455,9 @@ namespace Start // 删除已存在的服务 - await ProcessStandardInputAsync(process, $"sc delete {serviceName}"); + //await ProcessStandardInputAsync(process, $"sc delete {serviceName}"); - Log($"删除服务{serviceName}...", Color.Green); + //Log($"删除服务{serviceName}...", Color.Green); // 执行 sc create 命令来创建服务 await ProcessStandardInputAsync(process, createStr); @@ -522,8 +490,12 @@ namespace Start { Log($"后端服务启动成功", Color.Green); + + Log($"部署工作已完成", Color.Green); + try { + Log($"现在打开浏览器...", Color.Green); // Use ProcessStartInfo class var start = new ProcessStartInfo($"http://127.0.0.1:{vuePort}") { @@ -551,15 +523,53 @@ namespace Start #endregion } - private void selectPathBtn_Click(object sender, EventArgs e) + private async void selectPathBtn_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { folderPathTbox.Text = dialog.SelectedPath; + + Log($"部署路径选择成功", Color.Green); + + #region 测试 停止Nginx + + var deployFoder = this.folderPathTbox.Text; + + string nginxExtractName = "nginx-1.20.1"; + + string nginxStartPath = Path.Combine(deployFoder, @$"{nginxExtractName}\"); + + + #region 创建进程执行命令 + + Process process = new Process(); + process.StartInfo.FileName = "cmd.exe"; + process.StartInfo.RedirectStandardInput = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.CreateNoWindow = true; // 不创建新窗口 + process.Start(); + + var proList = Process.GetProcesses().Where(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxStartPath)); + + foreach (var item in proList) + { + item.Kill(); + } + + + await ProcessStandardInputAsync(process, $"sc stop {serviceNameTBox.Text}"); + await ProcessStandardInputAsync(process, $"sc delete {serviceNameTBox.Text}"); + + process.StandardInput.Close(); + process.WaitForExit(); + + #endregion + + #endregion } } - + } } diff --git a/Start/Start.csproj b/Start/Start.csproj index e53de32c..dbd44491 100644 --- a/Start/Start.csproj +++ b/Start/Start.csproj @@ -26,9 +26,6 @@ Always - - Always - Always diff --git a/Start/deploy/ServiceConfig.Json b/Start/deploy/ServiceConfig.Json deleted file mode 100644 index d60f16d4..00000000 --- a/Start/deploy/ServiceConfig.Json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "serviceName": "CertificateApply.NetCore.Api", - "serviceDisplayName": "CertificateApplyServiceDisplayName", - "binPath": "/IRacIS.Core.API.exe" -}