修改提交

Test.EIImageViewer
hang 2023-04-14 15:38:51 +08:00
parent 7e07a00844
commit 0c2951c96b
22 changed files with 649 additions and 127 deletions

View File

@ -19,8 +19,6 @@ 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", "{EDA76948-D12B-453A-A14E-93D5437C565D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -40,42 +38,36 @@ Global
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Debug|x86.ActiveCfg = Debug|x86
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Release|Any CPU.Build.0 = Release|Any CPU
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Release|x86.ActiveCfg = Release|x86
{D4DF27AC-3739-4264-BFB8-AED6DC2B84C7}.Release|x86.Build.0 = Release|x86
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Debug|x86.ActiveCfg = Debug|x86
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Release|Any CPU.Build.0 = Release|Any CPU
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Release|x86.ActiveCfg = Release|x86
{037E7DE9-0AE2-4987-8C69-F51D5B9CA19D}.Release|x86.Build.0 = Release|x86
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Debug|x86.ActiveCfg = Debug|x86
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Release|Any CPU.Build.0 = Release|Any CPU
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Release|x86.ActiveCfg = Release|x86
{7CBC76F5-3817-46B7-8D9D-79253A89B578}.Release|x86.Build.0 = Release|x86
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Debug|x86.ActiveCfg = Debug|x86
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Release|Any CPU.Build.0 = Release|Any CPU
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Release|x86.ActiveCfg = Release|x86
{3292B2B4-6E8A-43AA-84C0-AB4A391E8A2A}.Release|x86.Build.0 = Release|x86
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Debug|x86.ActiveCfg = Debug|x86
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Release|Any CPU.Build.0 = Release|Any CPU
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Release|x86.ActiveCfg = Release|x86
{6D8115E5-84D6-424B-8F8D-0C2D40347A8C}.Release|x86.Build.0 = Release|x86
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Debug|x86.ActiveCfg = Debug|x86
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Release|Any CPU.Build.0 = Release|Any CPU
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Release|x86.ActiveCfg = Release|x86
{07EED0F8-08E6-46F3-ACBE-17BC1391BD4C}.Release|x86.Build.0 = Release|x86
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@ -83,13 +75,8 @@ Global
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Debug|x86.ActiveCfg = Debug|x86
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Debug|x86.Build.0 = Debug|x86
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|Any CPU.Build.0 = Release|Any CPU
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.ActiveCfg = Release|x86
{D96F4B52-359C-43C9-8110-BAD1437F9280}.Release|x86.Build.0 = Release|x86
{EDA76948-D12B-453A-A14E-93D5437C565D}.Debug|Any CPU.ActiveCfg = Debug
{EDA76948-D12B-453A-A14E-93D5437C565D}.Debug|x86.ActiveCfg = Debug
{EDA76948-D12B-453A-A14E-93D5437C565D}.Release|Any CPU.ActiveCfg = Release
{EDA76948-D12B-453A-A14E-93D5437C565D}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<SignAssembly>false</SignAssembly>
<UserSecretsId>354572d4-9e15-4099-807c-63a2d29ff9f2</UserSecretsId>
<LangVersion>default</LangVersion>
@ -12,7 +12,7 @@
<Product>IRC影像系统EICS</Product>
<Version>1.0.1.0412</Version>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -88,7 +88,7 @@ namespace IRaCIS.Core.API
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);
@ -100,7 +100,7 @@ namespace IRaCIS.Core.API
var updateConfigNode = jObject["ConnectionStrings"];
var connectionString = $"Server={dbServerName};Database=IRaCIS;User ID={dbLoginUser};Password={dbPwd};TrustServerCertificate=true";
var connectionString = $"Server={dbServerName};Database={dbName};User ID={dbLoginUser};Password={dbPwd};TrustServerCertificate=true";
updateConfigNode["RemoteNew"] = connectionString;

View File

@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -2,14 +2,14 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\bin</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug'">
<OutputPath>..\bin</OutputPath>
</PropertyGroup>

View File

@ -7,7 +7,7 @@
<LangVersion>default</LangVersion>
<Platforms>x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

239
Start/Main.Designer.cs generated
View File

@ -37,6 +37,17 @@
label2 = new Label();
label1 = new Label();
groupBox2 = new GroupBox();
testDBBtn = new Button();
testServicebtn = new Button();
serviceDisplayNameTBox = new TextBox();
serviceNameTBox = new TextBox();
label11 = new Label();
label10 = new Label();
selectPathBtn = new Button();
folderPathTbox = new TextBox();
label9 = new Label();
dbNameTBox = new TextBox();
label8 = new Label();
portBtn = new Button();
apiPortTBox = new TextBox();
nginxPortTBox = new TextBox();
@ -49,9 +60,14 @@
machineCodeLB = new Label();
label6 = new Label();
label7 = new Label();
groupBox4 = new GroupBox();
logTBox = new RichTextBox();
folderBrowserDialog1 = new FolderBrowserDialog();
confimDeployBtn = new Button();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
groupBox3.SuspendLayout();
groupBox4.SuspendLayout();
SuspendLayout();
//
// groupBox1
@ -65,14 +81,14 @@
groupBox1.Controls.Add(label1);
groupBox1.Location = new Point(24, 25);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(738, 220);
groupBox1.Size = new Size(570, 187);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "数据库";
groupBox1.Text = "第一步:数据库";
//
// connectButton
//
connectButton.Location = new Point(531, 86);
connectButton.Location = new Point(418, 69);
connectButton.Name = "connectButton";
connectButton.Size = new Size(128, 49);
connectButton.TabIndex = 6;
@ -82,7 +98,7 @@
//
// passwordTextBox
//
passwordTextBox.Location = new Point(193, 144);
passwordTextBox.Location = new Point(120, 134);
passwordTextBox.Name = "passwordTextBox";
passwordTextBox.Size = new Size(271, 23);
passwordTextBox.TabIndex = 5;
@ -90,7 +106,7 @@
//
// usernameTextBox
//
usernameTextBox.Location = new Point(193, 99);
usernameTextBox.Location = new Point(120, 89);
usernameTextBox.Name = "usernameTextBox";
usernameTextBox.Size = new Size(271, 23);
usernameTextBox.TabIndex = 4;
@ -98,7 +114,7 @@
//
// serverTextBox
//
serverTextBox.Location = new Point(193, 51);
serverTextBox.Location = new Point(120, 41);
serverTextBox.Name = "serverTextBox";
serverTextBox.Size = new Size(271, 23);
serverTextBox.TabIndex = 3;
@ -107,7 +123,7 @@
// label3
//
label3.AutoSize = true;
label3.Location = new Point(26, 141);
label3.Location = new Point(26, 131);
label3.Name = "label3";
label3.Size = new Size(32, 17);
label3.TabIndex = 2;
@ -116,7 +132,7 @@
// label2
//
label2.AutoSize = true;
label2.Location = new Point(26, 95);
label2.Location = new Point(26, 85);
label2.Name = "label2";
label2.Size = new Size(44, 17);
label2.TabIndex = 1;
@ -125,7 +141,7 @@
// label1
//
label1.AutoSize = true;
label1.Location = new Point(26, 45);
label1.Location = new Point(26, 35);
label1.Name = "label1";
label1.Size = new Size(56, 17);
label1.TabIndex = 0;
@ -133,21 +149,131 @@
//
// 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);
groupBox2.Controls.Add(label10);
groupBox2.Controls.Add(selectPathBtn);
groupBox2.Controls.Add(folderPathTbox);
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, 266);
groupBox2.Location = new Point(24, 231);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(738, 206);
groupBox2.Size = new Size(570, 439);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Nginx";
groupBox2.Text = "第二步: 部署配置";
//
// testDBBtn
//
testDBBtn.Location = new Point(423, 191);
testDBBtn.Name = "testDBBtn";
testDBBtn.Size = new Size(128, 49);
testDBBtn.TabIndex = 18;
testDBBtn.Text = "测试数据库名";
testDBBtn.UseVisualStyleBackColor = true;
testDBBtn.Click += testDBBtn_Click;
//
// testServicebtn
//
testServicebtn.Location = new Point(418, 271);
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(198, 303);
serviceDisplayNameTBox.Name = "serviceDisplayNameTBox";
serviceDisplayNameTBox.Size = new Size(197, 23);
serviceDisplayNameTBox.TabIndex = 16;
serviceDisplayNameTBox.Text = "EI_Image_Viewer_DisplayName";
//
// serviceNameTBox
//
serviceNameTBox.Location = new Point(198, 246);
serviceNameTBox.Name = "serviceNameTBox";
serviceNameTBox.Size = new Size(197, 23);
serviceNameTBox.TabIndex = 15;
serviceNameTBox.Text = "EI_Image_Viewer";
//
// label11
//
label11.AutoSize = true;
label11.Location = new Point(21, 303);
label11.Name = "label11";
label11.Size = new Size(128, 17);
label11.TabIndex = 14;
label11.Text = "网站后端服务显示名称";
//
// label10
//
label10.AutoSize = true;
label10.Location = new Point(21, 249);
label10.Name = "label10";
label10.Size = new Size(104, 17);
label10.TabIndex = 13;
label10.Text = "网站后端服务名称";
//
// selectPathBtn
//
selectPathBtn.Location = new Point(418, 39);
selectPathBtn.Name = "selectPathBtn";
selectPathBtn.Size = new Size(128, 31);
selectPathBtn.TabIndex = 12;
selectPathBtn.Text = "选择部署路径";
selectPathBtn.UseVisualStyleBackColor = true;
selectPathBtn.Click += selectPathBtn_Click;
//
// folderPathTbox
//
folderPathTbox.Enabled = false;
folderPathTbox.Location = new Point(120, 43);
folderPathTbox.Name = "folderPathTbox";
folderPathTbox.Size = new Size(271, 23);
folderPathTbox.TabIndex = 11;
//
// label9
//
label9.AutoSize = true;
label9.Location = new Point(21, 46);
label9.Name = "label9";
label9.Size = new Size(92, 17);
label9.TabIndex = 10;
label9.Text = "网站部署文件夹";
//
// dbNameTBox
//
dbNameTBox.Location = new Point(199, 191);
dbNameTBox.Name = "dbNameTBox";
dbNameTBox.Size = new Size(197, 23);
dbNameTBox.TabIndex = 9;
dbNameTBox.Text = "IRaCIS";
//
// label8
//
label8.AutoSize = true;
label8.Location = new Point(21, 196);
label8.Name = "label8";
label8.Size = new Size(92, 17);
label8.TabIndex = 8;
label8.Text = "部署数据库名称";
//
// portBtn
//
portBtn.Location = new Point(531, 86);
portBtn.Location = new Point(423, 109);
portBtn.Name = "portBtn";
portBtn.Size = new Size(128, 49);
portBtn.TabIndex = 7;
@ -157,37 +283,37 @@
//
// apiPortTBox
//
apiPortTBox.Location = new Point(218, 112);
apiPortTBox.Location = new Point(199, 146);
apiPortTBox.Name = "apiPortTBox";
apiPortTBox.Size = new Size(100, 23);
apiPortTBox.Size = new Size(197, 23);
apiPortTBox.TabIndex = 5;
apiPortTBox.Text = "7100";
//
// nginxPortTBox
//
nginxPortTBox.Location = new Point(217, 64);
nginxPortTBox.Location = new Point(198, 98);
nginxPortTBox.Name = "nginxPortTBox";
nginxPortTBox.Size = new Size(100, 23);
nginxPortTBox.Size = new Size(197, 23);
nginxPortTBox.TabIndex = 4;
nginxPortTBox.Text = "9527";
nginxPortTBox.Text = "9520";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(26, 113);
label4.Location = new Point(21, 152);
label4.Name = "label4";
label4.Size = new Size(80, 17);
label4.Size = new Size(128, 17);
label4.TabIndex = 3;
label4.Text = "服务启动端口";
label4.Text = "网站后端服务启动端口";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(26, 63);
label5.Location = new Point(21, 102);
label5.Name = "label5";
label5.Size = new Size(90, 17);
label5.Size = new Size(104, 17);
label5.TabIndex = 2;
label5.Text = "Nginx启动端口";
label5.Text = "网站前端访问端口";
//
// groupBox3
//
@ -197,33 +323,34 @@
groupBox3.Controls.Add(machineCodeLB);
groupBox3.Controls.Add(label6);
groupBox3.Controls.Add(label7);
groupBox3.Location = new Point(24, 502);
groupBox3.Location = new Point(12, 693);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(738, 172);
groupBox3.Size = new Size(582, 183);
groupBox3.TabIndex = 2;
groupBox3.TabStop = false;
groupBox3.Text = "激活码";
groupBox3.Text = "第三部:激活码";
//
// activeBtn
//
activeBtn.Location = new Point(531, 75);
activeBtn.Location = new Point(430, 69);
activeBtn.Name = "activeBtn";
activeBtn.Size = new Size(128, 49);
activeBtn.TabIndex = 9;
activeBtn.Text = "激活";
activeBtn.Text = "激活并部署";
activeBtn.UseVisualStyleBackColor = true;
activeBtn.Click += activeBtn_Click;
//
// KeySecreteTextBox
//
KeySecreteTextBox.Location = new Point(193, 101);
KeySecreteTextBox.Location = new Point(131, 101);
KeySecreteTextBox.Multiline = true;
KeySecreteTextBox.Name = "KeySecreteTextBox";
KeySecreteTextBox.Size = new Size(271, 23);
KeySecreteTextBox.Size = new Size(271, 42);
KeySecreteTextBox.TabIndex = 8;
//
// machineTextBox
//
machineTextBox.Location = new Point(193, 51);
machineTextBox.Location = new Point(132, 45);
machineTextBox.Name = "machineTextBox";
machineTextBox.ReadOnly = true;
machineTextBox.Size = new Size(271, 23);
@ -255,22 +382,53 @@
label7.TabIndex = 4;
label7.Text = "机器码";
//
// groupBox4
//
groupBox4.Controls.Add(logTBox);
groupBox4.Location = new Point(618, 32);
groupBox4.Name = "groupBox4";
groupBox4.Size = new Size(391, 791);
groupBox4.TabIndex = 4;
groupBox4.TabStop = false;
groupBox4.Text = "运行日志";
//
// logTBox
//
logTBox.Location = new Point(6, 35);
logTBox.Name = "logTBox";
logTBox.Size = new Size(359, 738);
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);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 798);
ClientSize = new Size(1021, 914);
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);
groupBox2.PerformLayout();
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
groupBox4.ResumeLayout(false);
ResumeLayout(false);
}
@ -297,5 +455,20 @@
private Button activeBtn;
private TextBox KeySecreteTextBox;
private TextBox machineTextBox;
private GroupBox groupBox4;
private RichTextBox logTBox;
private TextBox dbNameTBox;
private Label label8;
private Button selectPathBtn;
private TextBox folderPathTbox;
private Label label9;
private FolderBrowserDialog folderBrowserDialog1;
private TextBox serviceDisplayNameTBox;
private TextBox serviceNameTBox;
private Label label11;
private Label label10;
private Button testDBBtn;
private Button testServicebtn;
private Button confimDeployBtn;
}
}

View File

@ -14,11 +14,31 @@ using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using Microsoft.VisualBasic.Logging;
using System.IO.Compression;
using SharpCompress.Archives.Rar;
using SharpCompress.Common;
using SharpCompress.Archives;
using System.Diagnostics.Eventing.Reader;
using System.ServiceProcess;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Security.Policy;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
using System.Data.SqlTypes;
namespace Start
{
public partial class Main : Form
{
private bool isCanDBConfig = true;
private bool isPortTestOk = false;
private bool isServiceTestOk=false;
private bool isDBNameTestOK=false;
public Main()
{
InitializeComponent();
@ -31,6 +51,33 @@ namespace Start
}
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)
@ -41,11 +88,23 @@ namespace Start
try
{
connection.Open();
MessageBox.Show("连接成功!");
Log("数据库连接成功!", Color.Green);
isCanDBConfig = false;
serverTextBox.Enabled = isCanDBConfig;
usernameTextBox.Enabled = isCanDBConfig;
passwordTextBox.Enabled = isCanDBConfig;
connectButton.Enabled = false;
portBtn.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show($"连接失败:{ex.Message}");
Log($"数据库连接失败:{ex.Message}", Color.Red);
}
finally
{
@ -53,26 +112,135 @@ namespace Start
}
}
private void portBtn_Click(object sender, EventArgs e)
private async void portBtn_Click(object sender, EventArgs e)
{
nginxPortTBox.Text.Trim();
#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)
{
MessageBox.Show("请输入合法的端口");
Log($"请输入合法的端口", Color.Red);
return;
}
if (IsPortInUse(vuePort))
{
MessageBox.Show("服务设置的前端端口被占用,请选择其他端口");
Log($"服务设置的前端端口被占用,请选择其他端口", Color.Red);
return;
}
if (IsPortInUse(apiPort))
{
MessageBox.Show("服务设置的后端端口被占用,请选择其他端口");
Log($"服务设置的后端端口被占用,请选择其他端口", Color.Red);
return;
}
Log("端口测试成功!", Color.Green);
isPortTestOk = true;
}
private void testServicebtn_Click(object sender, EventArgs e)
{
if (ServiceController.GetServices().Any(t => t.ServiceName == serviceNameTBox.Text))
{
Log($"当前服务名称已存在,请更换", Color.Red);
return;
}
isServiceTestOk = true;
}
private void testDBBtn_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(dbNameTBox.Text))
{
Log($"请输入部署的数据库名称", Color.Red);
return;
}
string connectionString = $"Server={serverTextBox.Text};User Id={usernameTextBox.Text};Password={passwordTextBox.Text};";
string sql = $"SELECT COUNT(*) FROM sys.databases WHERE name = '{dbNameTBox.Text.Trim()}';";
// 创建连接对象和命令对象
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand(sql, connection))
{
// 打开连接
connection.Open();
// 执行查询,返回结果行数
int rowCount = (int)command.ExecuteScalar();
// 判断结果是否大于0即是否存在该数据库
if (rowCount > 0)
{
Log($"{dbNameTBox.Text.Trim()}该数据库已存在。", Color.Red);
return;
}
}
isDBNameTestOK = true;
}
private void confimDeployBtn_Click(object sender, EventArgs e)
{
activeBtn.Enabled = true;
nginxPortTBox.Enabled = false;
apiPortTBox.Enabled = false;
portBtn.Enabled = false;
dbNameTBox.Enabled = false;
}
private static bool IsPortInUse(int port)
@ -101,14 +269,156 @@ namespace Start
return sb.ToString();
}
}
private void activeBtn_Click(object sender, EventArgs e)
private void Log(string message, Color color)
{
if (InvokeRequired)
{
Invoke(Log, message, color);
return;
}
logTBox.SelectionColor = color;
logTBox.AppendText(message + Environment.NewLine);
}
private async Task ProcessStandardInputAsync(Process process, string cmd, string workDirectory = "")
{
if (!string.IsNullOrWhiteSpace(workDirectory))
{
process.StartInfo.WorkingDirectory = workDirectory;
}
await process.StandardInput.WriteLineAsync(cmd);
await process.StandardInput.FlushAsync();
}
private async void activeBtn_Click(object sender, EventArgs e)
{
this.activeBtn.Enabled = false;
var serviceName = serviceNameTBox.Text;
var serviceDisplayName = serviceDisplayNameTBox.Text;
var deployFoder = this.folderPathTbox.Text;
string nginxExtractName = "nginx-1.20.1";
string apiExtractName = "APIPublish";
string nginxStartPath = Path.Combine(deployFoder, @$"{nginxExtractName}\");
var nginxConfigPath = Path.Combine(nginxStartPath, @$"conf\nginx.conf");
var apiBinPath = Path.Combine(deployFoder, "APIPublish/IRacIS.Core.API.exe");
string nginxRarFilePath = Path.Combine(AppContext.BaseDirectory, $@"deploy\nginx-1.20.1.rar"); // 要解压缩的RAR文件路径
string apiRarFilePath = Path.Combine(AppContext.BaseDirectory, "deploy/net6.0.rar"); // 要解压缩的RAR文件路径
#region 创建进程执行命令
var startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe"; // 指定要启动的应用程序
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
//startInfo.CreateNoWindow = true;
// 创建新进程并启动
var process = new Process();
process.StartInfo = startInfo;
process.Start();
#endregion
#region 解压nginx 和前端部署的文件
Log($"开始解压 nginx 及前端部署 RAR文件", Color.Green);
await Task.Run(() =>
{
string extractPath = Path.Combine(deployFoder, nginxExtractName);
if (!Directory.Exists(extractPath))
{
Directory.CreateDirectory(extractPath);
}
using (var archive = RarArchive.Open(nginxRarFilePath))
{
foreach (var entry in archive.Entries)
{
if (!entry.IsDirectory)
{
entry.WriteToDirectory(extractPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
}
else
{
string directoryPath = Path.Combine(extractPath, entry.Key);
Directory.CreateDirectory(directoryPath);
}
}
}
Log($"nginx 及前端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green);
});
#endregion
#region 解压后端部署的文件
Log($"开始解压 后端部署 RAR文件", Color.Green);
await Task.Run(() =>
{
string extractPath = Path.Combine(deployFoder, apiExtractName);
if (!Directory.Exists(extractPath))
{
Directory.CreateDirectory(extractPath);
}
using (var archive = RarArchive.Open(apiRarFilePath))
{
foreach (var entry in archive.Entries)
{
if (!entry.IsDirectory)
{
entry.WriteToDirectory(extractPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
}
}
}
Log($"后端部署 RAR文件已成功解压缩到 + {extractPath}", Color.Green);
});
#endregion
#region 修改 nginx 配置文件 启动nginx
var nginxConfigPath = Path.Combine(AppContext.BaseDirectory, @$"nginx-1.20.1\conf\nginx.conf");
if (!File.Exists(nginxConfigPath))
{
@ -117,8 +427,8 @@ namespace Start
var nginxConfig = File.ReadAllText(nginxConfigPath);
nginxConfig= nginxConfig.Replace("9527", vuePort.ToString());
nginxConfig= nginxConfig.Replace("7100", apiPort.ToString());
nginxConfig = nginxConfig.Replace("9520", vuePort.ToString());
nginxConfig = nginxConfig.Replace("7100", apiPort.ToString());
@ -127,22 +437,30 @@ namespace Start
// 获取nginx.exe所在的目录
string nginxPath = Path.Combine(AppContext.BaseDirectory, @$"nginx-1.20.1\");
// 创建ProcessStartInfo对象指定要启动的可执行文件及其参数
ProcessStartInfo psi = new ProcessStartInfo(nginxPath + "nginx.exe");
ProcessStartInfo psi = new ProcessStartInfo(nginxStartPath + "nginx.exe");
// 指定工作目录即进入nginx.exe所在的目录
psi.WorkingDirectory = nginxPath;
psi.WorkingDirectory = nginxStartPath;
Log(" 开始启动 nginx 服务...", Color.Green);
// 启动可执行文件
Process.Start(psi);
if (Process.GetProcesses().Any(t => t.ProcessName.Contains("nginx") && t.MainModule.FileName.Contains(nginxStartPath)))
{
Log(" nginx 服务启动成功", Color.Green);
}
else
{
Log(" nginx 服务启动失败", Color.Red);
return;
}
#endregion
var configObj = new
{
key = this.machineTextBox.Text,
@ -150,73 +468,98 @@ namespace Start
user = usernameTextBox.Text,
server = serverTextBox.Text,
password = passwordTextBox.Text,
database = string.Empty
dbName = dbNameTBox.Text,
};
File.WriteAllText($@"C:\ProgramData\.xingcang\config.json", JsonConvert.SerializeObject(configObj));
var serviceConfig = File.ReadAllText("ServiceConfig.json");
Log("写入激活秘钥完成", Color.Green);
var jObject = JObject.Parse(serviceConfig);
var binPath = Path.Combine(AppContext.BaseDirectory, jObject["binPath"].ToString().TrimStart('/'));
var createStr = $@"sc create {jObject["serviceName"].ToString()} binPath= ""{binPath} --urls=""http://127.0.0.1:{apiPort}"" --env CertificateApply"" DisplayName= ""{jObject["serviceDisplayName"].ToString()}"" start= auto";
var createStr = $@"sc create {serviceName} binPath= ""{apiBinPath} --urls=""http://127.0.0.1:{apiPort}"" --env CertificateApply"" DisplayName= ""{serviceDisplayName}"" start= auto";
#region 创建服务
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
//process.StandardInput.WriteLine(Path.Combine(AppContext.BaseDirectory, "startNginx.bat"));
// 删除已存在的服务
process.StandardInput.WriteLine($"sc delete {jObject["serviceName"].ToString()}");
await ProcessStandardInputAsync(process, $"sc delete {serviceName}");
Log($"删除服务{serviceName}...", Color.Green);
// 执行 sc create 命令来创建服务
process.StandardInput.WriteLine(createStr);
await ProcessStandardInputAsync(process, createStr);
Log($"创建服务{serviceName}...", Color.Green);
process.Exited += (sender, e) =>
{
int exitCode = process.ExitCode;
if (exitCode == 0)
{
// 执行成功
MessageBox.Show("Batch file executed successfully.");
}
else
{
// 执行失败
MessageBox.Show("Batch file execution failed with error code: " + exitCode);
}
};
Log($"执行初始化数据库脚本...", Color.Green);
//执行数据库脚本
process.StandardInput.WriteLine(Path.Combine(AppContext.BaseDirectory, "sql/bin.bat"));
//await ProcessStandardInputAsync(process, Path.Combine(AppContext.BaseDirectory, "deploy/sql/bin.bat"));
await ProcessStandardInputAsync(process, $@" SQLCMD -v dbName = ""{dbNameTBox.Text}"" -i {AppContext.BaseDirectory}deploy\sql\dbo.sql ");
await ProcessStandardInputAsync(process, $@" SQLCMD -v dbName = ""{dbNameTBox.Text}"" -i {AppContext.BaseDirectory}deploy\sql\data.sql ");
Log($"初始化数据库脚本执行结束", Color.Green);
// 执行 sc start 启动服务
process.StandardInput.WriteLine($"sc start {jObject["serviceName"].ToString()}");
Log($"启动部署的后端服务...", Color.Green);
await ProcessStandardInputAsync(process, $"sc start {serviceName}");
// 关闭进程流并等待进程退出
process.StandardInput.Flush();
process.StandardInput.Close();
process.WaitForExit();
ServiceController sc = new ServiceController(serviceName);
if (sc.Status == ServiceControllerStatus.Running)
{
Log($"后端服务启动成功", Color.Green);
try
{
// Use ProcessStartInfo class
var start = new ProcessStartInfo($"http://127.0.0.1:{vuePort}")
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(start);
}
catch (Exception ex)
{
// Handle exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
Log($"后端服务启动失败", Color.Red);
}
#endregion
}
private void selectPathBtn_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
folderPathTbox.Text = dialog.SelectedPath;
}
}
}
}

View File

@ -57,4 +57,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,10 @@
<?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>

View File

@ -10,34 +10,41 @@
</PropertyGroup>
<ItemGroup>
<None Remove="deploy\net6.0.rar" />
<None Remove="deploy\nginx-1.20.1.rar" />
<None Remove="ServiceConfig.Json" />
<None Remove="sql\bin.bat" />
<None Remove="sql\data.sql" />
<None Remove="sql\dbo.sql" />
<None Remove="sql\startNginx.bat" />
<None Remove="deploy\sql\bin.bat" />
<None Remove="deploy\sql\data.sql" />
<None Remove="deploy\sql\dbo.sql" />
<None Remove="deploy\sql\startNginx.bat" />
</ItemGroup>
<ItemGroup>
<Content Include="ServiceConfig.Json">
<Content Include="deploy\net6.0.rar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="sql\bin.bat">
<Content Include="deploy\nginx-1.20.1.rar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="sql\data.sql">
<Content Include="deploy\ServiceConfig.Json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="sql\dbo.sql">
<Content Include="deploy\sql\bin.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="startNginx.bat">
<Content Include="deploy\sql\data.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="deploy\sql\dbo.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<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" />
</ItemGroup>
</Project>

View File

@ -1,5 +1,5 @@
{
"serviceName": "CertificateApply.NetCore.Api",
"serviceDisplayName": "CertificateApplyServiceDisplayName",
"binPath": "/IRacIS.NetCore.API/IRacIS.Core.API.exe"
"binPath": "/IRacIS.Core.API.exe"
}

BIN
Start/deploy/net6.0.rar Normal file

Binary file not shown.

Binary file not shown.

3
Start/deploy/sql/bin.bat Normal file
View File

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

View File

@ -1,2 +0,0 @@
SQLCMD -i %~dp0\dbo.sql
SQLCMD -i %~dp0\data.sql

View File

@ -1,2 +0,0 @@
cd /d %~dp0\nginx-1.4.7
start nginx.exe