diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81ab08a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +################################################################################ +# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。 +################################################################################ + +/.vs +/bin +/obj diff --git a/FileProcessClient.csproj b/FileProcessClient.csproj new file mode 100644 index 0000000..e36e87a --- /dev/null +++ b/FileProcessClient.csproj @@ -0,0 +1,32 @@ + + + + WinExe + net8.0-windows8.0 + enable + true + enable + + + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/FileProcessClient.csproj.user b/FileProcessClient.csproj.user new file mode 100644 index 0000000..7042c14 --- /dev/null +++ b/FileProcessClient.csproj.user @@ -0,0 +1,11 @@ + + + + + Form + + + Form + + + \ No newline at end of file diff --git a/FileProcessClient.sln b/FileProcessClient.sln new file mode 100644 index 0000000..c77bde7 --- /dev/null +++ b/FileProcessClient.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34511.84 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileProcessClient", "FileProcessClient.csproj", "{C46CAAB7-521D-4487-951B-481E1CD3256B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C46CAAB7-521D-4487-951B-481E1CD3256B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C46CAAB7-521D-4487-951B-481E1CD3256B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C46CAAB7-521D-4487-951B-481E1CD3256B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C46CAAB7-521D-4487-951B-481E1CD3256B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {04556C10-FFC6-41C6-B86C-5CDBA0E61A6D} + EndGlobalSection +EndGlobal diff --git a/LoginForm.Designer.cs b/LoginForm.Designer.cs new file mode 100644 index 0000000..65b2d90 --- /dev/null +++ b/LoginForm.Designer.cs @@ -0,0 +1,203 @@ +namespace FileProcessClient +{ + partial class LoginForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + hopeForm1 = new ReaLTaiizor.Forms.HopeForm(); + hopePictureBox1 = new ReaLTaiizor.Controls.HopePictureBox(); + labelEdit1 = new ReaLTaiizor.Controls.LabelEdit(); + btnLogin = new ReaLTaiizor.Controls.HopeButton(); + chkSavePassword = new ReaLTaiizor.Controls.ForeverCheckBox(); + txtName = new ReaLTaiizor.Controls.HopeTextBox(); + txtPassword = new ReaLTaiizor.Controls.HopeTextBox(); + ((System.ComponentModel.ISupportInitialize)hopePictureBox1).BeginInit(); + SuspendLayout(); + // + // txtName + // + txtName.BackColor = Color.FromArgb(5, 15, 25); + txtName.BaseColor = Color.FromArgb(44, 55, 66); + txtName.BorderColorA = Color.FromArgb(192, 64, 0); + txtName.BorderColorB = Color.FromArgb(230, 162, 60); + txtName.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + txtName.ForeColor = Color.FromArgb(224, 224, 224); + txtName.Hint = "请输入账号"; + txtName.Location = new Point(34, 260); + txtName.MaxLength = 32767; + txtName.Multiline = false; + txtName.Name = "txtName"; + txtName.PasswordChar = '\0'; + txtName.ScrollBars = ScrollBars.None; + txtName.SelectedText = ""; + txtName.SelectionLength = 0; + txtName.SelectionStart = 0; + txtName.Size = new Size(300, 38); + txtName.TabIndex = 2; + txtName.TabStop = false; + txtName.UseSystemPasswordChar = false; + // + // txtPassword + // + txtPassword.BackColor = Color.FromArgb(5, 15, 25); + txtPassword.BaseColor = Color.FromArgb(44, 55, 66); + txtPassword.BorderColorA = Color.FromArgb(192, 64, 0); + txtPassword.BorderColorB = Color.FromArgb(230, 162, 60); + txtPassword.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + txtPassword.ForeColor = Color.FromArgb(224, 224, 224); + txtPassword.Hint = "请输入密码"; + txtPassword.Location = new Point(34, 329); + txtPassword.MaxLength = 32767; + txtPassword.Multiline = false; + txtPassword.Name = "txtPassword"; + txtPassword.PasswordChar = '*'; + txtPassword.ScrollBars = ScrollBars.None; + txtPassword.SelectedText = ""; + txtPassword.SelectionLength = 0; + txtPassword.SelectionStart = 0; + txtPassword.Size = new Size(300, 38); + txtPassword.TabIndex = 3; + txtPassword.TabStop = false; + txtPassword.UseSystemPasswordChar = false; + // + // hopeForm1 + // + hopeForm1.ControlBoxColorH = Color.FromArgb(228, 231, 237); + hopeForm1.ControlBoxColorHC = Color.FromArgb(245, 108, 108); + hopeForm1.ControlBoxColorN = Color.White; + hopeForm1.Dock = DockStyle.Top; + hopeForm1.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + hopeForm1.ForeColor = Color.FromArgb(242, 246, 252); + hopeForm1.Image = Properties.Resources.Account; + hopeForm1.Location = new Point(0, 0); + hopeForm1.MaximizeBox = false; + hopeForm1.MinimizeBox = false; + hopeForm1.Name = "hopeForm1"; + hopeForm1.Size = new Size(407, 40); + hopeForm1.TabIndex = 0; + hopeForm1.Text = "系统登录"; + hopeForm1.ThemeColor = Color.FromArgb(92, 173, 255); + // + // hopePictureBox1 + // + hopePictureBox1.BackColor = Color.FromArgb(192, 196, 204); + hopePictureBox1.BackgroundImageLayout = ImageLayout.Center; + hopePictureBox1.Image = Properties.Resources.sys_logo; + hopePictureBox1.Location = new Point(134, 67); + hopePictureBox1.Name = "hopePictureBox1"; + hopePictureBox1.PixelOffsetType = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; + hopePictureBox1.Size = new Size(101, 99); + hopePictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; + hopePictureBox1.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + hopePictureBox1.TabIndex = 1; + hopePictureBox1.TabStop = false; + hopePictureBox1.TextRenderingType = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + // + // labelEdit1 + // + labelEdit1.AutoSize = true; + labelEdit1.BackColor = Color.Transparent; + labelEdit1.Font = new Font("微软雅黑", 12F, FontStyle.Bold, GraphicsUnit.Point, 134); + labelEdit1.ForeColor = Color.White; + labelEdit1.Location = new Point(34, 403); + labelEdit1.Name = "labelEdit1"; + labelEdit1.Size = new Size(74, 22); + labelEdit1.TabIndex = 3; + labelEdit1.Text = "记住密码"; + // + // btnLogin + // + btnLogin.BorderColor = Color.FromArgb(220, 223, 230); + btnLogin.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary; + btnLogin.Cursor = Cursors.Hand; + btnLogin.DangerColor = Color.FromArgb(245, 108, 108); + btnLogin.DefaultColor = Color.FromArgb(255, 255, 255); + btnLogin.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + btnLogin.HoverTextColor = Color.FromArgb(48, 49, 51); + btnLogin.InfoColor = Color.FromArgb(144, 147, 153); + btnLogin.Location = new Point(115, 519); + btnLogin.Name = "btnLogin"; + btnLogin.PrimaryColor = Color.FromArgb(64, 158, 255); + btnLogin.Size = new Size(147, 45); + btnLogin.SuccessColor = Color.FromArgb(103, 194, 58); + btnLogin.TabIndex = 5; + btnLogin.Text = "登录"; + btnLogin.TextColor = Color.White; + btnLogin.WarningColor = Color.FromArgb(230, 162, 60); + btnLogin.Click += btnLogin_Click; + // + // chkSavePassword + // + chkSavePassword.BackColor = Color.FromArgb(60, 70, 73); + chkSavePassword.BaseColor = Color.FromArgb(45, 47, 49); + chkSavePassword.BorderColor = Color.FromArgb(35, 168, 109); + chkSavePassword.Checked = true; + chkSavePassword.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + chkSavePassword.ForeColor = Color.FromArgb(243, 243, 243); + chkSavePassword.Location = new Point(136, 403); + chkSavePassword.Name = "chkSavePassword"; + chkSavePassword.Options = ReaLTaiizor.Controls.ForeverCheckBox._Options.Style1; + chkSavePassword.Size = new Size(20, 22); + chkSavePassword.TabIndex = 4; + // + // LoginForm + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(32, 42, 52); + ClientSize = new Size(407, 646); + Controls.Add(chkSavePassword); + Controls.Add(btnLogin); + Controls.Add(labelEdit1); + Controls.Add(txtPassword); + Controls.Add(txtName); + Controls.Add(hopePictureBox1); + Controls.Add(hopeForm1); + FormBorderStyle = FormBorderStyle.None; + MaximizeBox = false; + MaximumSize = new Size(2560, 1400); + MinimizeBox = false; + MinimumSize = new Size(190, 40); + Name = "LoginForm"; + StartPosition = FormStartPosition.CenterScreen; + Activated += LoginForm_Activated; + ((System.ComponentModel.ISupportInitialize)hopePictureBox1).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ReaLTaiizor.Forms.HopeForm hopeForm1; + private ReaLTaiizor.Controls.HopePictureBox hopePictureBox1; + private ReaLTaiizor.Controls.LabelEdit labelEdit1; + private ReaLTaiizor.Controls.HopeButton btnLogin; + private ReaLTaiizor.Controls.ForeverCheckBox chkSavePassword; + private ReaLTaiizor.Controls.HopeTextBox txtName; + private ReaLTaiizor.Controls.HopeTextBox txtPassword; + } +} \ No newline at end of file diff --git a/LoginForm.cs b/LoginForm.cs new file mode 100644 index 0000000..1830b5a --- /dev/null +++ b/LoginForm.cs @@ -0,0 +1,86 @@ +using edu.huvtc.utils; +using System.Diagnostics; +using System.Xml.Linq; + +namespace FileProcessClient +{ + public partial class LoginForm : Form + { + public LoginForm() + { + InitializeComponent(); + } + + private async void btnLogin_Click(object sender, EventArgs e) + { + + string username = txtName.Text; + if (username.Length == 0) + { + MessageBox.Show("请输入账号!"); + return; + } + string password = txtPassword.Text; + if (password.Length == 0) + { + MessageBox.Show("请输入密码!"); + return; + } + + //Trace.WriteLine(password); + + Trace.WriteLine(username); + + bool flag = await HttpUtils.validateLogin(username, password); + if (!flag) + { + MessageBox.Show("用户名或密码错误,请重试"); + return; + } + + + if (chkSavePassword.Checked) + { + CommonUtils.writeToIni("userData", "userName", Convert.ToBase64String(CommonUtils.EncryptString(username))); + CommonUtils.writeToIni("userData", "password", Convert.ToBase64String(CommonUtils.EncryptString(password))); + } + + await HttpUtils.getUserInfo(); + + loadMainForm(); + } + private void loadMainForm() + { + mainForm mainForm = new mainForm(); + mainForm.Show(); + this.Hide(); + } + private async void LoginForm_Activated(object sender, EventArgs e) + { + + bool valid = await HttpUtils.getUserInfo(); + if (!valid) + { + string name = CommonUtils.readFromFile("userData", "username"); + //Trace.WriteLine(name); + if (name != null && name != "") + { + txtName.Text = CommonUtils.DecryptToString(Convert.FromBase64String(name)); + } + + string password = CommonUtils.readFromFile("userData", "password"); + //Trace.WriteLine(name); + if (password != null && password != "") + { + txtPassword.Text = CommonUtils.DecryptToString(Convert.FromBase64String(password)); + } + } + else + { + loadMainForm(); + } + + + } + } +} diff --git a/LoginForm.resx b/LoginForm.resx new file mode 100644 index 0000000..cf02749 --- /dev/null +++ b/LoginForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + False + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs new file mode 100644 index 0000000..e9c7418 --- /dev/null +++ b/MainForm.Designer.cs @@ -0,0 +1,1147 @@ +namespace FileProcessClient +{ + partial class mainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(mainForm)); + DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); + DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); + DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle(); + hopeFormMain = new ReaLTaiizor.Forms.HopeForm(); + panelToolbar = new ReaLTaiizor.Controls.Panel(); + headerLabel1 = new ReaLTaiizor.Controls.HeaderLabel(); + lblUserName = new ReaLTaiizor.Controls.SkyLabel(); + btnSysConfig = new ReaLTaiizor.Controls.Button(); + btnOpenUpload = new ReaLTaiizor.Controls.Button(); + pnlUpload = new ReaLTaiizor.Controls.Panel(); + poisonPanel6 = new ReaLTaiizor.Controls.PoisonPanel(); + fileListGrid = new DataGridView(); + no = new DataGridViewTextBoxColumn(); + path = new DataGridViewTextBoxColumn(); + status = new DataGridViewTextBoxColumn(); + colOperator = new DataGridViewCheckBoxColumn(); + panel2 = new ReaLTaiizor.Controls.Panel(); + uploadbar = new ReaLTaiizor.Controls.CyberProgressBar(); + btnUpload = new ReaLTaiizor.Controls.PoisonButton(); + poisonPanel12 = new ReaLTaiizor.Controls.PoisonPanel(); + btnAddfiles = new ReaLTaiizor.Controls.PoisonButton(); + btnSelFile = new ReaLTaiizor.Controls.PoisonButton(); + btnAddDirectory = new ReaLTaiizor.Controls.PoisonButton(); + btnSelDirectory = new ReaLTaiizor.Controls.PoisonButton(); + poisonPanel4 = new ReaLTaiizor.Controls.PoisonPanel(); + txtDirectory = new ReaLTaiizor.Controls.MetroTextBox(); + metroLabel4 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel3 = new ReaLTaiizor.Controls.PoisonPanel(); + versionList = new ReaLTaiizor.Controls.HopeComboBox(); + metroLabel1 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel1 = new ReaLTaiizor.Controls.PoisonPanel(); + cameraList = new ReaLTaiizor.Controls.HopeComboBox(); + metroLabel2 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel2 = new ReaLTaiizor.Controls.PoisonPanel(); + metroLabel3 = new ReaLTaiizor.Controls.MetroLabel(); + tooltipUpload = new ReaLTaiizor.Controls.MetroToolTip(); + btn_save = new ReaLTaiizor.Controls.PoisonButton(); + pnlConfig = new ReaLTaiizor.Controls.Panel(); + panel1 = new ReaLTaiizor.Controls.Panel(); + poisonPanel11 = new ReaLTaiizor.Controls.PoisonPanel(); + txt_ftp_password = new ReaLTaiizor.Controls.PoisonTextBox(); + metroLabel6 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel10 = new ReaLTaiizor.Controls.PoisonPanel(); + txt_ftp_user = new ReaLTaiizor.Controls.PoisonTextBox(); + metroLabel10 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel9 = new ReaLTaiizor.Controls.PoisonPanel(); + txt_server_port = new ReaLTaiizor.Controls.PoisonTextBox(); + metroLabel9 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel8 = new ReaLTaiizor.Controls.PoisonPanel(); + txt_ftp_server = new ReaLTaiizor.Controls.PoisonTextBox(); + metroLabel8 = new ReaLTaiizor.Controls.MetroLabel(); + poisonPanel7 = new ReaLTaiizor.Controls.PoisonPanel(); + txt_server_url = new ReaLTaiizor.Controls.PoisonTextBox(); + metroLabel7 = new ReaLTaiizor.Controls.MetroLabel(); + metroLabel5 = new ReaLTaiizor.Controls.MetroLabel(); + panelToolbar.SuspendLayout(); + pnlUpload.SuspendLayout(); + poisonPanel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)fileListGrid).BeginInit(); + panel2.SuspendLayout(); + poisonPanel12.SuspendLayout(); + poisonPanel4.SuspendLayout(); + poisonPanel3.SuspendLayout(); + poisonPanel1.SuspendLayout(); + poisonPanel2.SuspendLayout(); + pnlConfig.SuspendLayout(); + panel1.SuspendLayout(); + poisonPanel11.SuspendLayout(); + poisonPanel10.SuspendLayout(); + poisonPanel9.SuspendLayout(); + poisonPanel8.SuspendLayout(); + poisonPanel7.SuspendLayout(); + SuspendLayout(); + // + // hopeFormMain + // + hopeFormMain.ControlBoxColorH = Color.FromArgb(228, 231, 237); + hopeFormMain.ControlBoxColorHC = Color.FromArgb(245, 108, 108); + hopeFormMain.ControlBoxColorN = Color.White; + hopeFormMain.Dock = DockStyle.Top; + hopeFormMain.Font = new Font("Segoe UI", 12F); + hopeFormMain.ForeColor = Color.FromArgb(242, 246, 252); + hopeFormMain.Image = (Image)resources.GetObject("hopeFormMain.Image"); + hopeFormMain.Location = new Point(0, 0); + hopeFormMain.Name = "hopeFormMain"; + hopeFormMain.Size = new Size(599, 40); + hopeFormMain.TabIndex = 0; + hopeFormMain.ThemeColor = Color.FromArgb(92, 173, 255); + // + // panelToolbar + // + panelToolbar.BackColor = Color.FromArgb(39, 51, 63); + panelToolbar.Controls.Add(headerLabel1); + panelToolbar.Controls.Add(lblUserName); + panelToolbar.Controls.Add(btnSysConfig); + panelToolbar.Controls.Add(btnOpenUpload); + panelToolbar.Dock = DockStyle.Top; + panelToolbar.EdgeColor = Color.FromArgb(32, 41, 50); + panelToolbar.Location = new Point(0, 40); + panelToolbar.Name = "panelToolbar"; + panelToolbar.Padding = new Padding(5); + panelToolbar.Size = new Size(599, 50); + panelToolbar.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + panelToolbar.TabIndex = 1; + // + // headerLabel1 + // + headerLabel1.BackColor = Color.Transparent; + headerLabel1.Dock = DockStyle.Right; + headerLabel1.Font = new Font("Microsoft Sans Serif", 11F, FontStyle.Bold); + headerLabel1.ForeColor = Color.FromArgb(255, 255, 255); + headerLabel1.Image = Properties.Resources.avatar1; + headerLabel1.Location = new Point(456, 5); + headerLabel1.Name = "headerLabel1"; + headerLabel1.Size = new Size(35, 40); + headerLabel1.TabIndex = 5; + // + // lblUserName + // + lblUserName.Dock = DockStyle.Right; + lblUserName.Font = new Font("微软雅黑", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 0); + lblUserName.ForeColor = Color.FromArgb(255, 128, 128); + lblUserName.Location = new Point(491, 5); + lblUserName.Margin = new Padding(3, 10, 3, 0); + lblUserName.Name = "lblUserName"; + lblUserName.Size = new Size(103, 40); + lblUserName.TabIndex = 4; + lblUserName.Text = "用户名"; + lblUserName.TextAlign = ContentAlignment.MiddleCenter; + // + // btnSysConfig + // + btnSysConfig.BackColor = Color.Transparent; + btnSysConfig.BorderColor = Color.FromArgb(32, 34, 37); + btnSysConfig.Cursor = Cursors.Hand; + btnSysConfig.Dock = DockStyle.Left; + btnSysConfig.EnteredBorderColor = Color.FromArgb(165, 37, 37); + btnSysConfig.EnteredColor = Color.FromArgb(32, 34, 37); + btnSysConfig.Font = new Font("Microsoft Sans Serif", 12F); + btnSysConfig.Image = Properties.Resources.sys_config1; + btnSysConfig.ImageAlign = ContentAlignment.MiddleCenter; + btnSysConfig.InactiveColor = Color.FromArgb(32, 34, 37); + btnSysConfig.Location = new Point(67, 5); + btnSysConfig.Name = "btnSysConfig"; + btnSysConfig.PressedBorderColor = Color.FromArgb(165, 37, 37); + btnSysConfig.PressedColor = Color.FromArgb(165, 37, 37); + btnSysConfig.Size = new Size(42, 40); + btnSysConfig.TabIndex = 1; + btnSysConfig.TextAlignment = StringAlignment.Center; + tooltipUpload.SetToolTip(btnSysConfig, "系统配置"); + btnSysConfig.Click += btnSysConfig_Click; + // + // btnOpenUpload + // + btnOpenUpload.BackColor = Color.Transparent; + btnOpenUpload.BorderColor = Color.FromArgb(32, 34, 37); + btnOpenUpload.Cursor = Cursors.Hand; + btnOpenUpload.Dock = DockStyle.Left; + btnOpenUpload.EnteredBorderColor = Color.FromArgb(165, 37, 37); + btnOpenUpload.EnteredColor = Color.FromArgb(32, 34, 37); + btnOpenUpload.Font = new Font("Microsoft Sans Serif", 12F); + btnOpenUpload.Image = Properties.Resources.file_upload; + btnOpenUpload.ImageAlign = ContentAlignment.MiddleCenter; + btnOpenUpload.InactiveColor = Color.FromArgb(32, 34, 37); + btnOpenUpload.Location = new Point(5, 5); + btnOpenUpload.Name = "btnOpenUpload"; + btnOpenUpload.PressedBorderColor = Color.FromArgb(165, 37, 37); + btnOpenUpload.PressedColor = Color.FromArgb(165, 37, 37); + btnOpenUpload.Size = new Size(62, 40); + btnOpenUpload.TabIndex = 1; + btnOpenUpload.Tag = ""; + btnOpenUpload.TextAlignment = StringAlignment.Center; + tooltipUpload.SetToolTip(btnOpenUpload, "视频文件上传"); + btnOpenUpload.Click += btnOpenUpload_Click; + // + // pnlUpload + // + pnlUpload.BackColor = Color.White; + pnlUpload.Controls.Add(poisonPanel6); + pnlUpload.Controls.Add(panel2); + pnlUpload.Controls.Add(poisonPanel12); + pnlUpload.Controls.Add(poisonPanel4); + pnlUpload.Controls.Add(poisonPanel3); + pnlUpload.Controls.Add(poisonPanel1); + pnlUpload.Controls.Add(poisonPanel2); + pnlUpload.EdgeColor = Color.FromArgb(32, 41, 50); + pnlUpload.Location = new Point(12, 96); + pnlUpload.Name = "pnlUpload"; + pnlUpload.Padding = new Padding(5); + pnlUpload.Size = new Size(562, 676); + pnlUpload.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + pnlUpload.TabIndex = 2; + // + // poisonPanel6 + // + poisonPanel6.Controls.Add(fileListGrid); + poisonPanel6.Dock = DockStyle.Fill; + poisonPanel6.HorizontalScrollbarBarColor = true; + poisonPanel6.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel6.HorizontalScrollbarSize = 10; + poisonPanel6.Location = new Point(5, 314); + poisonPanel6.Name = "poisonPanel6"; + poisonPanel6.Size = new Size(552, 303); + poisonPanel6.TabIndex = 26; + poisonPanel6.VerticalScrollbarBarColor = true; + poisonPanel6.VerticalScrollbarHighlightOnWheel = false; + poisonPanel6.VerticalScrollbarSize = 10; + // + // fileListGrid + // + fileListGrid.AllowUserToAddRows = false; + fileListGrid.AllowUserToDeleteRows = false; + fileListGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = SystemColors.Control; + dataGridViewCellStyle1.Font = new Font("Microsoft YaHei UI", 9F); + dataGridViewCellStyle1.ForeColor = SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = DataGridViewTriState.True; + fileListGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + fileListGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + fileListGrid.Columns.AddRange(new DataGridViewColumn[] { no, path, status, colOperator }); + dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = SystemColors.Window; + dataGridViewCellStyle2.Font = new Font("Microsoft YaHei UI", 9F); + dataGridViewCellStyle2.ForeColor = SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = DataGridViewTriState.False; + fileListGrid.DefaultCellStyle = dataGridViewCellStyle2; + fileListGrid.Dock = DockStyle.Fill; + fileListGrid.Location = new Point(0, 0); + fileListGrid.Name = "fileListGrid"; + dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = SystemColors.Control; + dataGridViewCellStyle3.Font = new Font("Microsoft YaHei UI", 9F); + dataGridViewCellStyle3.ForeColor = SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True; + fileListGrid.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; + fileListGrid.Size = new Size(552, 303); + fileListGrid.TabIndex = 2; + // + // no + // + no.FillWeight = 25F; + no.HeaderText = "序号"; + no.Name = "no"; + no.ReadOnly = true; + // + // path + // + path.FillWeight = 150F; + path.HeaderText = "文件路径"; + path.Name = "path"; + path.ReadOnly = true; + // + // status + // + status.FillWeight = 30F; + status.HeaderText = "状态"; + status.Name = "status"; + status.ReadOnly = true; + // + // colOperator + // + colOperator.FillWeight = 30F; + colOperator.HeaderText = "操作"; + colOperator.Name = "colOperator"; + colOperator.Resizable = DataGridViewTriState.True; + colOperator.SortMode = DataGridViewColumnSortMode.Automatic; + // + // panel2 + // + panel2.BackColor = Color.FromArgb(39, 51, 63); + panel2.Controls.Add(uploadbar); + panel2.Controls.Add(btnUpload); + panel2.Dock = DockStyle.Bottom; + panel2.EdgeColor = Color.FromArgb(32, 41, 50); + panel2.Location = new Point(5, 617); + panel2.Name = "panel2"; + panel2.Padding = new Padding(5); + panel2.Size = new Size(552, 54); + panel2.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + panel2.TabIndex = 24; + panel2.Text = "panel2"; + // + // uploadbar + // + uploadbar.Alpha = 50; + uploadbar.BackColor = Color.Transparent; + uploadbar.Background = true; + uploadbar.Background_WidthPen = 3F; + uploadbar.BackgroundPen = true; + uploadbar.ColorBackground = Color.FromArgb(37, 52, 68); + uploadbar.ColorBackground_1 = Color.FromArgb(37, 52, 68); + uploadbar.ColorBackground_2 = Color.FromArgb(41, 63, 86); + uploadbar.ColorBackground_Pen = Color.FromArgb(29, 200, 238); + uploadbar.ColorBackground_Value_1 = Color.FromArgb(28, 200, 238); + uploadbar.ColorBackground_Value_2 = Color.FromArgb(100, 208, 232); + uploadbar.ColorLighting = Color.FromArgb(29, 200, 238); + uploadbar.ColorPen_1 = Color.FromArgb(37, 52, 68); + uploadbar.ColorPen_2 = Color.FromArgb(41, 63, 86); + uploadbar.ColorProgressBar = Color.FromArgb(29, 200, 238); + uploadbar.ColorValue_Transparency = 200; + uploadbar.CyberProgressBarStyle = ReaLTaiizor.Enum.Cyber.StateStyle.Custom; + uploadbar.Dock = DockStyle.Left; + uploadbar.Font = new Font("Arial", 11F); + uploadbar.ForeColor = Color.FromArgb(245, 245, 245); + uploadbar.Lighting = false; + uploadbar.LinearGradient_Background = false; + uploadbar.LinearGradient_Value = false; + uploadbar.LinearGradientPen = false; + uploadbar.Location = new Point(5, 5); + uploadbar.Maximum = 100; + uploadbar.Minimum = 0; + uploadbar.Name = "uploadbar"; + uploadbar.PenWidth = 10; + uploadbar.ProgressText = true; + uploadbar.RGB = false; + uploadbar.Rounding = true; + uploadbar.RoundingInt = 70; + uploadbar.Size = new Size(316, 44); + uploadbar.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + uploadbar.StartDrawingValue = 0; + uploadbar.TabIndex = 9; + uploadbar.Tag = "Cyber"; + uploadbar.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + uploadbar.Timer_RGB = 300; + uploadbar.Value = 0; + uploadbar.Visible = false; + // + // btnUpload + // + btnUpload.BackColor = Color.Transparent; + btnUpload.BackgroundImage = Properties.Resources.upload_to_server_01; + btnUpload.BackgroundImageLayout = ImageLayout.Center; + btnUpload.Cursor = Cursors.Hand; + btnUpload.Dock = DockStyle.Right; + btnUpload.Location = new Point(487, 5); + btnUpload.Name = "btnUpload"; + btnUpload.Size = new Size(60, 44); + btnUpload.TabIndex = 7; + tooltipUpload.SetToolTip(btnUpload, "全部上传"); + btnUpload.UseSelectable = true; + btnUpload.UseVisualStyleBackColor = false; + btnUpload.Click += btnUpload_Click; + // + // poisonPanel12 + // + poisonPanel12.Controls.Add(btnAddfiles); + poisonPanel12.Controls.Add(btnSelFile); + poisonPanel12.Controls.Add(btnAddDirectory); + poisonPanel12.Controls.Add(btnSelDirectory); + poisonPanel12.Dock = DockStyle.Top; + poisonPanel12.HorizontalScrollbarBarColor = true; + poisonPanel12.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel12.HorizontalScrollbarSize = 10; + poisonPanel12.Location = new Point(5, 258); + poisonPanel12.Margin = new Padding(5); + poisonPanel12.Name = "poisonPanel12"; + poisonPanel12.Padding = new Padding(10); + poisonPanel12.Size = new Size(552, 56); + poisonPanel12.TabIndex = 19; + poisonPanel12.VerticalScrollbarBarColor = true; + poisonPanel12.VerticalScrollbarHighlightOnWheel = false; + poisonPanel12.VerticalScrollbarSize = 10; + // + // btnAddfiles + // + btnAddfiles.BackgroundImage = Properties.Resources.add_files; + btnAddfiles.BackgroundImageLayout = ImageLayout.Center; + btnAddfiles.Cursor = Cursors.Hand; + btnAddfiles.Dock = DockStyle.Right; + btnAddfiles.Location = new Point(302, 10); + btnAddfiles.Name = "btnAddfiles"; + btnAddfiles.Size = new Size(60, 36); + btnAddfiles.TabIndex = 12; + tooltipUpload.SetToolTip(btnAddfiles, "添加文件"); + btnAddfiles.UseSelectable = true; + btnAddfiles.Click += btnAddfiles_Click; + // + // btnSelFile + // + btnSelFile.BackgroundImage = Properties.Resources.select_file; + btnSelFile.BackgroundImageLayout = ImageLayout.Center; + btnSelFile.Cursor = Cursors.Hand; + btnSelFile.Dock = DockStyle.Right; + btnSelFile.Location = new Point(362, 10); + btnSelFile.Name = "btnSelFile"; + btnSelFile.Size = new Size(60, 36); + btnSelFile.TabIndex = 10; + tooltipUpload.SetToolTip(btnSelFile, "选择文件"); + btnSelFile.UseSelectable = true; + btnSelFile.Click += btnSelFile_Click; + // + // btnAddDirectory + // + btnAddDirectory.BackgroundImage = Properties.Resources.folder_add; + btnAddDirectory.BackgroundImageLayout = ImageLayout.Center; + btnAddDirectory.Cursor = Cursors.Hand; + btnAddDirectory.Dock = DockStyle.Right; + btnAddDirectory.Location = new Point(422, 10); + btnAddDirectory.Name = "btnAddDirectory"; + btnAddDirectory.Size = new Size(60, 36); + btnAddDirectory.TabIndex = 11; + tooltipUpload.SetToolTip(btnAddDirectory, "添加文件夹"); + btnAddDirectory.UseSelectable = true; + btnAddDirectory.Click += btnAddDirectory_Click; + // + // btnSelDirectory + // + btnSelDirectory.BackgroundImage = Properties.Resources.open_folder; + btnSelDirectory.BackgroundImageLayout = ImageLayout.Center; + btnSelDirectory.Cursor = Cursors.Hand; + btnSelDirectory.Dock = DockStyle.Right; + btnSelDirectory.Location = new Point(482, 10); + btnSelDirectory.Name = "btnSelDirectory"; + btnSelDirectory.Size = new Size(60, 36); + btnSelDirectory.TabIndex = 9; + tooltipUpload.SetToolTip(btnSelDirectory, "选择文件夹"); + btnSelDirectory.UseSelectable = true; + btnSelDirectory.Click += btnSelDirectory_Click; + // + // poisonPanel4 + // + poisonPanel4.Controls.Add(txtDirectory); + poisonPanel4.Controls.Add(metroLabel4); + poisonPanel4.Dock = DockStyle.Top; + poisonPanel4.HorizontalScrollbarBarColor = true; + poisonPanel4.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel4.HorizontalScrollbarSize = 10; + poisonPanel4.Location = new Point(5, 202); + poisonPanel4.Margin = new Padding(5); + poisonPanel4.Name = "poisonPanel4"; + poisonPanel4.Padding = new Padding(10); + poisonPanel4.Size = new Size(552, 56); + poisonPanel4.TabIndex = 12; + poisonPanel4.VerticalScrollbarBarColor = true; + poisonPanel4.VerticalScrollbarHighlightOnWheel = false; + poisonPanel4.VerticalScrollbarSize = 10; + poisonPanel4.Visible = false; + // + // txtDirectory + // + txtDirectory.AutoCompleteCustomSource = null; + txtDirectory.AutoCompleteMode = AutoCompleteMode.None; + txtDirectory.AutoCompleteSource = AutoCompleteSource.None; + txtDirectory.BorderColor = Color.FromArgb(155, 155, 155); + txtDirectory.DisabledBackColor = Color.FromArgb(204, 204, 204); + txtDirectory.DisabledBorderColor = Color.FromArgb(155, 155, 155); + txtDirectory.DisabledForeColor = Color.FromArgb(136, 136, 136); + txtDirectory.Dock = DockStyle.Fill; + txtDirectory.Enabled = false; + txtDirectory.Font = new Font("Microsoft Sans Serif", 10F); + txtDirectory.HoverColor = Color.FromArgb(102, 102, 102); + txtDirectory.Image = null; + txtDirectory.IsDerivedStyle = true; + txtDirectory.Lines = null; + txtDirectory.Location = new Point(104, 10); + txtDirectory.MaxLength = 32767; + txtDirectory.Multiline = false; + txtDirectory.Name = "txtDirectory"; + txtDirectory.ReadOnly = false; + txtDirectory.Size = new Size(438, 36); + txtDirectory.Style = ReaLTaiizor.Enum.Metro.Style.Light; + txtDirectory.StyleManager = null; + txtDirectory.TabIndex = 6; + txtDirectory.TextAlign = HorizontalAlignment.Left; + txtDirectory.ThemeAuthor = "Taiizor"; + txtDirectory.ThemeName = "MetroLight"; + txtDirectory.UseSystemPasswordChar = false; + txtDirectory.WatermarkText = ""; + // + // metroLabel4 + // + metroLabel4.Dock = DockStyle.Left; + metroLabel4.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel4.IsDerivedStyle = true; + metroLabel4.Location = new Point(10, 10); + metroLabel4.Name = "metroLabel4"; + metroLabel4.Size = new Size(94, 36); + metroLabel4.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel4.StyleManager = null; + metroLabel4.TabIndex = 4; + metroLabel4.Text = "文件目录"; + metroLabel4.TextAlign = ContentAlignment.MiddleCenter; + metroLabel4.ThemeAuthor = "Taiizor"; + metroLabel4.ThemeName = "MetroLight"; + // + // poisonPanel3 + // + poisonPanel3.Controls.Add(versionList); + poisonPanel3.Controls.Add(metroLabel1); + poisonPanel3.Dock = DockStyle.Top; + poisonPanel3.HorizontalScrollbarBarColor = true; + poisonPanel3.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel3.HorizontalScrollbarSize = 10; + poisonPanel3.Location = new Point(5, 147); + poisonPanel3.Name = "poisonPanel3"; + poisonPanel3.Padding = new Padding(10); + poisonPanel3.Size = new Size(552, 55); + poisonPanel3.TabIndex = 11; + poisonPanel3.VerticalScrollbarBarColor = true; + poisonPanel3.VerticalScrollbarHighlightOnWheel = false; + poisonPanel3.VerticalScrollbarSize = 10; + // + // versionList + // + versionList.Dock = DockStyle.Fill; + versionList.DrawMode = DrawMode.OwnerDrawFixed; + versionList.FlatStyle = FlatStyle.Flat; + versionList.Font = new Font("Segoe UI", 12F); + versionList.FormattingEnabled = true; + versionList.ItemHeight = 30; + versionList.Location = new Point(104, 10); + versionList.Name = "versionList"; + versionList.Size = new Size(438, 36); + versionList.TabIndex = 4; + versionList.SelectedIndexChanged += versionList_SelectedIndexChanged; + versionList.Validating += versionList_Validating; + // + // metroLabel1 + // + metroLabel1.Dock = DockStyle.Left; + metroLabel1.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel1.IsDerivedStyle = true; + metroLabel1.Location = new Point(10, 10); + metroLabel1.Name = "metroLabel1"; + metroLabel1.Size = new Size(94, 35); + metroLabel1.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel1.StyleManager = null; + metroLabel1.TabIndex = 3; + metroLabel1.Text = "文件版本"; + metroLabel1.TextAlign = ContentAlignment.MiddleCenter; + metroLabel1.ThemeAuthor = "Taiizor"; + metroLabel1.ThemeName = "MetroLight"; + tooltipUpload.SetToolTip(metroLabel1, "可以输入或选择版本号"); + // + // poisonPanel1 + // + poisonPanel1.BackColor = Color.Gray; + poisonPanel1.Controls.Add(cameraList); + poisonPanel1.Controls.Add(metroLabel2); + poisonPanel1.Dock = DockStyle.Top; + poisonPanel1.HorizontalScrollbarBarColor = true; + poisonPanel1.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel1.HorizontalScrollbarSize = 10; + poisonPanel1.Location = new Point(5, 89); + poisonPanel1.Name = "poisonPanel1"; + poisonPanel1.Padding = new Padding(10); + poisonPanel1.Size = new Size(552, 58); + poisonPanel1.TabIndex = 9; + poisonPanel1.VerticalScrollbarBarColor = true; + poisonPanel1.VerticalScrollbarHighlightOnWheel = false; + poisonPanel1.VerticalScrollbarSize = 10; + // + // cameraList + // + cameraList.BackColor = Color.FromArgb(238, 238, 238); + cameraList.Dock = DockStyle.Fill; + cameraList.DrawMode = DrawMode.OwnerDrawFixed; + cameraList.FlatStyle = FlatStyle.Flat; + cameraList.Font = new Font("Segoe UI", 12F); + cameraList.FormattingEnabled = true; + cameraList.ItemHeight = 30; + cameraList.Location = new Point(104, 10); + cameraList.Name = "cameraList"; + cameraList.Size = new Size(438, 36); + cameraList.TabIndex = 3; + // + // metroLabel2 + // + metroLabel2.Dock = DockStyle.Left; + metroLabel2.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel2.IsDerivedStyle = true; + metroLabel2.Location = new Point(10, 10); + metroLabel2.Name = "metroLabel2"; + metroLabel2.Size = new Size(94, 38); + metroLabel2.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel2.StyleManager = null; + metroLabel2.TabIndex = 2; + metroLabel2.Text = "所属相机"; + metroLabel2.TextAlign = ContentAlignment.MiddleCenter; + metroLabel2.ThemeAuthor = "Taiizor"; + metroLabel2.ThemeName = "MetroLight"; + // + // poisonPanel2 + // + poisonPanel2.Controls.Add(metroLabel3); + poisonPanel2.Dock = DockStyle.Top; + poisonPanel2.HorizontalScrollbarBarColor = true; + poisonPanel2.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel2.HorizontalScrollbarSize = 10; + poisonPanel2.Location = new Point(5, 5); + poisonPanel2.Name = "poisonPanel2"; + poisonPanel2.Padding = new Padding(10); + poisonPanel2.Size = new Size(552, 84); + poisonPanel2.TabIndex = 8; + poisonPanel2.VerticalScrollbarBarColor = true; + poisonPanel2.VerticalScrollbarHighlightOnWheel = false; + poisonPanel2.VerticalScrollbarSize = 10; + // + // metroLabel3 + // + metroLabel3.Dock = DockStyle.Fill; + metroLabel3.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Bold, GraphicsUnit.Point, 134); + metroLabel3.IsDerivedStyle = true; + metroLabel3.Location = new Point(10, 10); + metroLabel3.Name = "metroLabel3"; + metroLabel3.Size = new Size(532, 64); + metroLabel3.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel3.StyleManager = null; + metroLabel3.TabIndex = 2; + metroLabel3.Text = "文件上传"; + metroLabel3.TextAlign = ContentAlignment.MiddleCenter; + metroLabel3.ThemeAuthor = "Taiizor"; + metroLabel3.ThemeName = "MetroLight"; + // + // tooltipUpload + // + tooltipUpload.BackColor = Color.White; + tooltipUpload.BorderColor = Color.FromArgb(204, 204, 204); + tooltipUpload.ForeColor = Color.FromArgb(170, 170, 170); + tooltipUpload.IsDerivedStyle = true; + tooltipUpload.OwnerDraw = true; + tooltipUpload.Style = ReaLTaiizor.Enum.Metro.Style.Light; + tooltipUpload.StyleManager = null; + tooltipUpload.ThemeAuthor = "Taiizor"; + tooltipUpload.ThemeName = "MetroLight"; + // + // btn_save + // + btn_save.BackColor = Color.Transparent; + btn_save.BackgroundImage = Properties.Resources.save_icon; + btn_save.BackgroundImageLayout = ImageLayout.Center; + btn_save.Cursor = Cursors.Hand; + btn_save.Dock = DockStyle.Right; + btn_save.Location = new Point(388, 5); + btn_save.Name = "btn_save"; + btn_save.Size = new Size(60, 50); + btn_save.TabIndex = 7; + tooltipUpload.SetToolTip(btn_save, "保存参数"); + btn_save.UseSelectable = true; + btn_save.UseVisualStyleBackColor = false; + btn_save.Click += btn_save_Click; + // + // pnlConfig + // + pnlConfig.BackColor = Color.White; + pnlConfig.Controls.Add(panel1); + pnlConfig.Controls.Add(poisonPanel11); + pnlConfig.Controls.Add(poisonPanel10); + pnlConfig.Controls.Add(poisonPanel9); + pnlConfig.Controls.Add(poisonPanel8); + pnlConfig.Controls.Add(poisonPanel7); + pnlConfig.Controls.Add(metroLabel5); + pnlConfig.EdgeColor = Color.FromArgb(32, 41, 50); + pnlConfig.Location = new Point(28, 111); + pnlConfig.Name = "pnlConfig"; + pnlConfig.Padding = new Padding(5); + pnlConfig.Size = new Size(463, 734); + pnlConfig.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + pnlConfig.TabIndex = 5; + pnlConfig.Visible = false; + pnlConfig.Click += btn_save_Click; + // + // panel1 + // + panel1.BackColor = Color.FromArgb(39, 51, 63); + panel1.Controls.Add(btn_save); + panel1.Dock = DockStyle.Bottom; + panel1.EdgeColor = Color.FromArgb(32, 41, 50); + panel1.Location = new Point(5, 669); + panel1.Name = "panel1"; + panel1.Padding = new Padding(5); + panel1.Size = new Size(453, 60); + panel1.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; + panel1.TabIndex = 17; + panel1.Text = "panel1"; + // + // poisonPanel11 + // + poisonPanel11.Controls.Add(txt_ftp_password); + poisonPanel11.Controls.Add(metroLabel6); + poisonPanel11.Dock = DockStyle.Top; + poisonPanel11.HorizontalScrollbarBarColor = true; + poisonPanel11.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel11.HorizontalScrollbarSize = 10; + poisonPanel11.Location = new Point(5, 289); + poisonPanel11.Name = "poisonPanel11"; + poisonPanel11.Padding = new Padding(10); + poisonPanel11.Size = new Size(453, 55); + poisonPanel11.TabIndex = 16; + poisonPanel11.VerticalScrollbarBarColor = true; + poisonPanel11.VerticalScrollbarHighlightOnWheel = false; + poisonPanel11.VerticalScrollbarSize = 10; + // + // txt_ftp_password + // + // + // + // + txt_ftp_password.CustomButton.Image = null; + txt_ftp_password.CustomButton.Location = new Point(282, 1); + txt_ftp_password.CustomButton.Name = ""; + txt_ftp_password.CustomButton.Size = new Size(33, 33); + txt_ftp_password.CustomButton.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Blue; + txt_ftp_password.CustomButton.TabIndex = 1; + txt_ftp_password.CustomButton.Theme = ReaLTaiizor.Enum.Poison.ThemeStyle.Light; + txt_ftp_password.CustomButton.UseSelectable = true; + txt_ftp_password.CustomButton.Visible = false; + txt_ftp_password.Dock = DockStyle.Fill; + txt_ftp_password.Font = new Font("Microsoft YaHei UI", 12F); + txt_ftp_password.FontSize = ReaLTaiizor.Extension.Poison.PoisonTextBoxSize.Medium; + txt_ftp_password.Location = new Point(127, 10); + txt_ftp_password.MaxLength = 32767; + txt_ftp_password.Name = "txt_ftp_password"; + txt_ftp_password.PasswordChar = '*'; + txt_ftp_password.ScrollBars = ScrollBars.None; + txt_ftp_password.SelectedText = ""; + txt_ftp_password.SelectionLength = 0; + txt_ftp_password.SelectionStart = 0; + txt_ftp_password.ShortcutsEnabled = true; + txt_ftp_password.Size = new Size(316, 35); + txt_ftp_password.TabIndex = 18; + txt_ftp_password.UseSelectable = true; + txt_ftp_password.WaterMarkColor = Color.FromArgb(109, 109, 109); + txt_ftp_password.WaterMarkFont = new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Pixel); + // + // metroLabel6 + // + metroLabel6.Dock = DockStyle.Left; + metroLabel6.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel6.IsDerivedStyle = true; + metroLabel6.Location = new Point(10, 10); + metroLabel6.Name = "metroLabel6"; + metroLabel6.Size = new Size(117, 35); + metroLabel6.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel6.StyleManager = null; + metroLabel6.TabIndex = 5; + metroLabel6.Text = "文件服务密码"; + metroLabel6.TextAlign = ContentAlignment.MiddleCenter; + metroLabel6.ThemeAuthor = "Taiizor"; + metroLabel6.ThemeName = "MetroLight"; + // + // poisonPanel10 + // + poisonPanel10.Controls.Add(txt_ftp_user); + poisonPanel10.Controls.Add(metroLabel10); + poisonPanel10.Dock = DockStyle.Top; + poisonPanel10.HorizontalScrollbarBarColor = true; + poisonPanel10.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel10.HorizontalScrollbarSize = 10; + poisonPanel10.Location = new Point(5, 234); + poisonPanel10.Name = "poisonPanel10"; + poisonPanel10.Padding = new Padding(10); + poisonPanel10.Size = new Size(453, 55); + poisonPanel10.TabIndex = 15; + poisonPanel10.VerticalScrollbarBarColor = true; + poisonPanel10.VerticalScrollbarHighlightOnWheel = false; + poisonPanel10.VerticalScrollbarSize = 10; + // + // txt_ftp_user + // + // + // + // + txt_ftp_user.CustomButton.Image = null; + txt_ftp_user.CustomButton.Location = new Point(282, 1); + txt_ftp_user.CustomButton.Name = ""; + txt_ftp_user.CustomButton.Size = new Size(33, 33); + txt_ftp_user.CustomButton.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Blue; + txt_ftp_user.CustomButton.TabIndex = 1; + txt_ftp_user.CustomButton.Theme = ReaLTaiizor.Enum.Poison.ThemeStyle.Light; + txt_ftp_user.CustomButton.UseSelectable = true; + txt_ftp_user.CustomButton.Visible = false; + txt_ftp_user.Dock = DockStyle.Fill; + txt_ftp_user.Font = new Font("Microsoft YaHei UI", 12F); + txt_ftp_user.FontSize = ReaLTaiizor.Extension.Poison.PoisonTextBoxSize.Medium; + txt_ftp_user.Location = new Point(127, 10); + txt_ftp_user.MaxLength = 32767; + txt_ftp_user.Name = "txt_ftp_user"; + txt_ftp_user.PasswordChar = '\0'; + txt_ftp_user.ScrollBars = ScrollBars.None; + txt_ftp_user.SelectedText = ""; + txt_ftp_user.SelectionLength = 0; + txt_ftp_user.SelectionStart = 0; + txt_ftp_user.ShortcutsEnabled = true; + txt_ftp_user.Size = new Size(316, 35); + txt_ftp_user.TabIndex = 19; + txt_ftp_user.UseSelectable = true; + txt_ftp_user.WaterMarkColor = Color.FromArgb(109, 109, 109); + txt_ftp_user.WaterMarkFont = new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Pixel); + // + // metroLabel10 + // + metroLabel10.Dock = DockStyle.Left; + metroLabel10.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel10.IsDerivedStyle = true; + metroLabel10.Location = new Point(10, 10); + metroLabel10.Name = "metroLabel10"; + metroLabel10.Size = new Size(117, 35); + metroLabel10.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel10.StyleManager = null; + metroLabel10.TabIndex = 3; + metroLabel10.Text = "文件服务账号"; + metroLabel10.TextAlign = ContentAlignment.MiddleCenter; + metroLabel10.ThemeAuthor = "Taiizor"; + metroLabel10.ThemeName = "MetroLight"; + // + // poisonPanel9 + // + poisonPanel9.Controls.Add(txt_server_port); + poisonPanel9.Controls.Add(metroLabel9); + poisonPanel9.Dock = DockStyle.Top; + poisonPanel9.HorizontalScrollbarBarColor = true; + poisonPanel9.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel9.HorizontalScrollbarSize = 10; + poisonPanel9.Location = new Point(5, 179); + poisonPanel9.Name = "poisonPanel9"; + poisonPanel9.Padding = new Padding(10); + poisonPanel9.Size = new Size(453, 55); + poisonPanel9.TabIndex = 14; + poisonPanel9.VerticalScrollbarBarColor = true; + poisonPanel9.VerticalScrollbarHighlightOnWheel = false; + poisonPanel9.VerticalScrollbarSize = 10; + // + // txt_server_port + // + // + // + // + txt_server_port.CustomButton.Image = null; + txt_server_port.CustomButton.Location = new Point(282, 1); + txt_server_port.CustomButton.Name = ""; + txt_server_port.CustomButton.Size = new Size(33, 33); + txt_server_port.CustomButton.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Blue; + txt_server_port.CustomButton.TabIndex = 1; + txt_server_port.CustomButton.Theme = ReaLTaiizor.Enum.Poison.ThemeStyle.Light; + txt_server_port.CustomButton.UseSelectable = true; + txt_server_port.CustomButton.Visible = false; + txt_server_port.Dock = DockStyle.Fill; + txt_server_port.Font = new Font("Microsoft YaHei UI", 12F); + txt_server_port.FontSize = ReaLTaiizor.Extension.Poison.PoisonTextBoxSize.Medium; + txt_server_port.Location = new Point(127, 10); + txt_server_port.MaxLength = 32767; + txt_server_port.Name = "txt_server_port"; + txt_server_port.PasswordChar = '\0'; + txt_server_port.ScrollBars = ScrollBars.None; + txt_server_port.SelectedText = ""; + txt_server_port.SelectionLength = 0; + txt_server_port.SelectionStart = 0; + txt_server_port.ShortcutsEnabled = true; + txt_server_port.Size = new Size(316, 35); + txt_server_port.TabIndex = 20; + txt_server_port.UseSelectable = true; + txt_server_port.WaterMarkColor = Color.FromArgb(109, 109, 109); + txt_server_port.WaterMarkFont = new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Pixel); + // + // metroLabel9 + // + metroLabel9.Dock = DockStyle.Left; + metroLabel9.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel9.IsDerivedStyle = true; + metroLabel9.Location = new Point(10, 10); + metroLabel9.Name = "metroLabel9"; + metroLabel9.Size = new Size(117, 35); + metroLabel9.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel9.StyleManager = null; + metroLabel9.TabIndex = 3; + metroLabel9.Text = "文件服务端口"; + metroLabel9.TextAlign = ContentAlignment.MiddleCenter; + metroLabel9.ThemeAuthor = "Taiizor"; + metroLabel9.ThemeName = "MetroLight"; + // + // poisonPanel8 + // + poisonPanel8.Controls.Add(txt_ftp_server); + poisonPanel8.Controls.Add(metroLabel8); + poisonPanel8.Dock = DockStyle.Top; + poisonPanel8.HorizontalScrollbarBarColor = true; + poisonPanel8.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel8.HorizontalScrollbarSize = 10; + poisonPanel8.Location = new Point(5, 124); + poisonPanel8.Name = "poisonPanel8"; + poisonPanel8.Padding = new Padding(10); + poisonPanel8.Size = new Size(453, 55); + poisonPanel8.TabIndex = 13; + poisonPanel8.VerticalScrollbarBarColor = true; + poisonPanel8.VerticalScrollbarHighlightOnWheel = false; + poisonPanel8.VerticalScrollbarSize = 10; + // + // txt_ftp_server + // + // + // + // + txt_ftp_server.CustomButton.Image = null; + txt_ftp_server.CustomButton.Location = new Point(282, 1); + txt_ftp_server.CustomButton.Name = ""; + txt_ftp_server.CustomButton.Size = new Size(33, 33); + txt_ftp_server.CustomButton.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Blue; + txt_ftp_server.CustomButton.TabIndex = 1; + txt_ftp_server.CustomButton.Theme = ReaLTaiizor.Enum.Poison.ThemeStyle.Light; + txt_ftp_server.CustomButton.UseSelectable = true; + txt_ftp_server.CustomButton.Visible = false; + txt_ftp_server.Dock = DockStyle.Fill; + txt_ftp_server.Font = new Font("Microsoft YaHei UI", 12F); + txt_ftp_server.FontSize = ReaLTaiizor.Extension.Poison.PoisonTextBoxSize.Medium; + txt_ftp_server.Location = new Point(127, 10); + txt_ftp_server.MaxLength = 32767; + txt_ftp_server.Name = "txt_ftp_server"; + txt_ftp_server.PasswordChar = '\0'; + txt_ftp_server.ScrollBars = ScrollBars.None; + txt_ftp_server.SelectedText = ""; + txt_ftp_server.SelectionLength = 0; + txt_ftp_server.SelectionStart = 0; + txt_ftp_server.ShortcutsEnabled = true; + txt_ftp_server.Size = new Size(316, 35); + txt_ftp_server.TabIndex = 21; + txt_ftp_server.UseSelectable = true; + txt_ftp_server.WaterMarkColor = Color.FromArgb(109, 109, 109); + txt_ftp_server.WaterMarkFont = new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Pixel); + // + // metroLabel8 + // + metroLabel8.Dock = DockStyle.Left; + metroLabel8.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel8.IsDerivedStyle = true; + metroLabel8.Location = new Point(10, 10); + metroLabel8.Name = "metroLabel8"; + metroLabel8.Size = new Size(117, 35); + metroLabel8.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel8.StyleManager = null; + metroLabel8.TabIndex = 3; + metroLabel8.Text = "文件服务地址"; + metroLabel8.TextAlign = ContentAlignment.MiddleCenter; + metroLabel8.ThemeAuthor = "Taiizor"; + metroLabel8.ThemeName = "MetroLight"; + // + // poisonPanel7 + // + poisonPanel7.Controls.Add(txt_server_url); + poisonPanel7.Controls.Add(metroLabel7); + poisonPanel7.Dock = DockStyle.Top; + poisonPanel7.HorizontalScrollbarBarColor = true; + poisonPanel7.HorizontalScrollbarHighlightOnWheel = false; + poisonPanel7.HorizontalScrollbarSize = 10; + poisonPanel7.Location = new Point(5, 69); + poisonPanel7.Name = "poisonPanel7"; + poisonPanel7.Padding = new Padding(10); + poisonPanel7.Size = new Size(453, 55); + poisonPanel7.TabIndex = 12; + poisonPanel7.VerticalScrollbarBarColor = true; + poisonPanel7.VerticalScrollbarHighlightOnWheel = false; + poisonPanel7.VerticalScrollbarSize = 10; + // + // txt_server_url + // + // + // + // + txt_server_url.CustomButton.Image = null; + txt_server_url.CustomButton.Location = new Point(282, 1); + txt_server_url.CustomButton.Name = ""; + txt_server_url.CustomButton.Size = new Size(33, 33); + txt_server_url.CustomButton.Style = ReaLTaiizor.Enum.Poison.ColorStyle.Blue; + txt_server_url.CustomButton.TabIndex = 1; + txt_server_url.CustomButton.Theme = ReaLTaiizor.Enum.Poison.ThemeStyle.Light; + txt_server_url.CustomButton.UseSelectable = true; + txt_server_url.CustomButton.Visible = false; + txt_server_url.Dock = DockStyle.Fill; + txt_server_url.Font = new Font("Microsoft YaHei UI", 12F); + txt_server_url.FontSize = ReaLTaiizor.Extension.Poison.PoisonTextBoxSize.Medium; + txt_server_url.Location = new Point(127, 10); + txt_server_url.MaxLength = 32767; + txt_server_url.Name = "txt_server_url"; + txt_server_url.PasswordChar = '\0'; + txt_server_url.ScrollBars = ScrollBars.None; + txt_server_url.SelectedText = ""; + txt_server_url.SelectionLength = 0; + txt_server_url.SelectionStart = 0; + txt_server_url.ShortcutsEnabled = true; + txt_server_url.Size = new Size(316, 35); + txt_server_url.TabIndex = 22; + txt_server_url.UseSelectable = true; + txt_server_url.WaterMarkColor = Color.FromArgb(109, 109, 109); + txt_server_url.WaterMarkFont = new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Pixel); + // + // metroLabel7 + // + metroLabel7.Dock = DockStyle.Left; + metroLabel7.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 0); + metroLabel7.IsDerivedStyle = true; + metroLabel7.Location = new Point(10, 10); + metroLabel7.Name = "metroLabel7"; + metroLabel7.Size = new Size(117, 35); + metroLabel7.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel7.StyleManager = null; + metroLabel7.TabIndex = 3; + metroLabel7.Text = "WEB服务地址"; + metroLabel7.TextAlign = ContentAlignment.MiddleCenter; + metroLabel7.ThemeAuthor = "Taiizor"; + metroLabel7.ThemeName = "MetroLight"; + // + // metroLabel5 + // + metroLabel5.Dock = DockStyle.Top; + metroLabel5.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Bold, GraphicsUnit.Point, 134); + metroLabel5.IsDerivedStyle = true; + metroLabel5.Location = new Point(5, 5); + metroLabel5.Name = "metroLabel5"; + metroLabel5.Size = new Size(453, 64); + metroLabel5.Style = ReaLTaiizor.Enum.Metro.Style.Light; + metroLabel5.StyleManager = null; + metroLabel5.TabIndex = 3; + metroLabel5.Text = "参数修改"; + metroLabel5.TextAlign = ContentAlignment.MiddleCenter; + metroLabel5.ThemeAuthor = "Taiizor"; + metroLabel5.ThemeName = "MetroLight"; + // + // mainForm + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(599, 823); + Controls.Add(pnlUpload); + Controls.Add(pnlConfig); + Controls.Add(panelToolbar); + Controls.Add(hopeFormMain); + FormBorderStyle = FormBorderStyle.None; + MaximumSize = new Size(2560, 1400); + MinimumSize = new Size(190, 40); + Name = "mainForm"; + StartPosition = FormStartPosition.CenterScreen; + FormClosed += mainForm_FormClosed; + Load += mainForm_Load; + panelToolbar.ResumeLayout(false); + pnlUpload.ResumeLayout(false); + poisonPanel6.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)fileListGrid).EndInit(); + panel2.ResumeLayout(false); + poisonPanel12.ResumeLayout(false); + poisonPanel4.ResumeLayout(false); + poisonPanel3.ResumeLayout(false); + poisonPanel1.ResumeLayout(false); + poisonPanel2.ResumeLayout(false); + pnlConfig.ResumeLayout(false); + panel1.ResumeLayout(false); + poisonPanel11.ResumeLayout(false); + poisonPanel10.ResumeLayout(false); + poisonPanel9.ResumeLayout(false); + poisonPanel8.ResumeLayout(false); + poisonPanel7.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private ReaLTaiizor.Forms.HopeForm hopeFormMain; + private ReaLTaiizor.Controls.Panel panelToolbar; + private ReaLTaiizor.Controls.Button btnOpenUpload; + private ReaLTaiizor.Controls.Button btnSysConfig; + private ReaLTaiizor.Controls.MetroToolTip tooltipUpload; + private ReaLTaiizor.Controls.SkyLabel lblUserName; + private ReaLTaiizor.Controls.HeaderLabel headerLabel1; + private ReaLTaiizor.Controls.Panel pnlUpload; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel4; + private ReaLTaiizor.Controls.MetroTextBox txtDirectory; + private ReaLTaiizor.Controls.MetroLabel metroLabel4; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel3; + private ReaLTaiizor.Controls.MetroLabel metroLabel1; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel1; + private ReaLTaiizor.Controls.HopeComboBox cameraList; + private ReaLTaiizor.Controls.MetroLabel metroLabel2; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel2; + private ReaLTaiizor.Controls.MetroLabel metroLabel3; + private ReaLTaiizor.Controls.HopeComboBox versionList; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel12; + private ReaLTaiizor.Controls.PoisonButton btnSelFile; + private ReaLTaiizor.Controls.PoisonButton btnAddDirectory; + private ReaLTaiizor.Controls.PoisonButton btnSelDirectory; + private ReaLTaiizor.Controls.PoisonButton btnAddfiles; + private ReaLTaiizor.Controls.Panel panel2; + private ReaLTaiizor.Controls.PoisonButton btnUpload; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel6; + private DataGridView fileListGrid; + private DataGridViewTextBoxColumn no; + private DataGridViewTextBoxColumn path; + private DataGridViewTextBoxColumn status; + private DataGridViewCheckBoxColumn colOperator; + private ReaLTaiizor.Controls.CyberProgressBar uploadbar; + private ReaLTaiizor.Controls.Panel pnlConfig; + private ReaLTaiizor.Controls.Panel panel1; + private ReaLTaiizor.Controls.PoisonButton btn_save; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel11; + private ReaLTaiizor.Controls.PoisonTextBox txt_ftp_password; + private ReaLTaiizor.Controls.MetroLabel metroLabel6; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel10; + private ReaLTaiizor.Controls.PoisonTextBox txt_ftp_user; + private ReaLTaiizor.Controls.MetroLabel metroLabel10; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel9; + private ReaLTaiizor.Controls.PoisonTextBox txt_server_port; + private ReaLTaiizor.Controls.MetroLabel metroLabel9; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel8; + private ReaLTaiizor.Controls.PoisonTextBox txt_ftp_server; + private ReaLTaiizor.Controls.MetroLabel metroLabel8; + private ReaLTaiizor.Controls.PoisonPanel poisonPanel7; + private ReaLTaiizor.Controls.PoisonTextBox txt_server_url; + private ReaLTaiizor.Controls.MetroLabel metroLabel7; + private ReaLTaiizor.Controls.MetroLabel metroLabel5; + } +} diff --git a/MainForm.cs b/MainForm.cs new file mode 100644 index 0000000..c4dfc7f --- /dev/null +++ b/MainForm.cs @@ -0,0 +1,486 @@ +using edu.huvtc.utils; +using FileProcessClient.domain; +using FileProcessClient.utils; +using Newtonsoft.Json.Linq; +using System.Diagnostics; +using System.Security.AccessControl; + +namespace FileProcessClient +{ + public partial class mainForm : Form + { + private static List uploadFiles; + + private static string remotePath; + + private static bool isUploading = false; + + public mainForm() + { + InitializeComponent(); + } + + private void btnUpload_MouseHover(object sender, EventArgs e) + { + + } + + private void btnOpen_Click(object sender, EventArgs e) + { + + } + + private void mainForm_FormClosed(object sender, FormClosedEventArgs e) + { + Application.Exit(); + } + + //private + + private void btnSelDirectory_Click(object sender, EventArgs e) + { + addDirectoryToList(0); + } + + private void changeButtonState(int status) + { + switch (status) + { + case 1: + btnUpload.BackgroundImage = Properties.Resources.upload_to_server; + btnUpload.Enabled = true; + break; + case 2: + btnUpload.BackgroundImage = Properties.Resources.upload_to_server_01; + btnUpload.Enabled = false; + break; + case 3: + btnSelDirectory.Enabled = false; + btnSelFile.Enabled = false; + btnUpload.Enabled = false; + uploadbar.Visible = true; + break; + case 4: + btnSelDirectory.Enabled = true; + btnSelFile.Enabled = true; + btnUpload.Enabled = false; + uploadbar.Visible = false; + break; + + + } + } + + private void addToTable(List list) + { + clearTable(); + foreach (var item in list) + { + int index = fileListGrid.Rows.Add(); + fileListGrid.Rows[index].Cells[0].Value = index + 1; + fileListGrid.Rows[index].Cells[1].Value = item; + fileListGrid.Rows[index].Cells[2].Value = "´ýÉϴ«"; + } + + } + + private void clearTable() + { + while (fileListGrid.Rows.Count != 0) + { + fileListGrid.Rows.RemoveAt(0); + } + } + + private async void loadCameraData() + { + List list = await HttpUtils.getCameraList(); + foreach (ComboboxItem item in list) + { + cameraList.Items.Add(item); + } + list = await HttpUtils.getVersionList(); + foreach (ComboboxItem item in list) + { + + versionList.Items.Add(item); + } + } + + private void getAllMediaFile(string path, List list) + { + try + { + DirectoryInfo dir = new DirectoryInfo(path); + + var allowedExtensions = new[] { ".mov", ".mp4", ".mkv", ".rmvb", ".json",".jpg",".png" }; + var files = Directory + .GetFiles(path) + .Where(file => allowedExtensions.Any(file.ToLower().EndsWith)) + .ToList(); + foreach (string file in files) + { + list.Add(file); + } + + // Get all subdirectories + DirectoryInfo[] subDirs = dir.GetDirectories(); + foreach (DirectoryInfo subDir in subDirs) + { + // Recursively list files in subdirectories + getAllMediaFile(subDir.FullName, list); + } + } + catch (Exception ex) + { + Console.WriteLine($"An error occurred: {ex.Message}"); + } + } + + private void showFileUploadProgress(int index) + { + if (uploadFiles == null || uploadFiles.Count == 0) + { + uploadbar.Value = 0; + } + else + { + int percent = (index * 100) / uploadFiles.Count; + uploadbar.Value = percent; + } + } + + private void processResponse(int index, int i) + { + showFileUploadProgress(index); + //Trace.WriteLine(i); + if (i == -1) + { + fileListGrid.Rows[index].Cells[2].Value = "Éϴ«ʧ°Ü"; + } + else if (i < 100) + { + fileListGrid.Rows[index].Cells[2].Value = "ÒÑÉϴ«" + i + "%"; + } + else + { + fileListGrid.Rows[index].Cells[2].Value = "ÒÑÍê³É"; + } + } + + private void mainForm_Load(object sender, EventArgs e) + { + DateTime now = DateTime.Now; + //txtVersion.Text = now.ToString("yyyyMMddHHmmss"); + lblUserName.Text = CommonUtils.getUser()!.Name; + btnOpenUpload_Click(sender, e); + loadCameraData(); + loadConfigData(); + } + + + + + private void btnUpload_Click(object sender, EventArgs e) + { + doUploadFiles(); + } + + private async void doUploadFiles() + { + if (uploadFiles == null || uploadFiles.Count == 0) + { + MessageBox.Show("ÇëѡÔñҪÉϴ«µÄÎļþ»òĿ¼"); + return; + } + var item = cameraList.SelectedItem; + if (item == null) + { + MessageBox.Show("ÇëѡÔñËùÊôÏà»ú"); + return; + } + + var versionItem = versionList.SelectedItem; + if (versionItem == null) + { + string str = versionList.Text; + if(str==null || str.Length == 0) + { + MessageBox.Show("ÇëѡÔñ»òÐÂÔö°汾ºÅ"); + return; + } + else + { + versionItem = new ComboboxItem(str, 0); + } + } + + if (versionItem.GetType() == typeof(string)) + { + string value = (string)versionItem; + versionItem = new ComboboxItem(value, 0); + } + + changeButtonState(3); + + ComboboxItem item1 = (ComboboxItem)item; + ComboboxItem item2 = (ComboboxItem)versionItem; + + string remotePath = "/" + item1.Text + "/" + item2.Text; + + //string remotePath = item1.Text + "/" + item2.Text; + //Trace.Write("==================" + remotePath); + + List list = getMediaFileItemList(uploadFiles, remotePath); + + bool flag = await FileUploadUtils.UploadFilesAsync(list, remotePath, processResponse); + + if (flag) + { + MediaFileInfo fileInfo = new MediaFileInfo(); + fileInfo.fileItems = list; + fileInfo.deviceId = item1.Value.ToString()!; + fileInfo.deviceName = item1.Text; + fileInfo.version = item2.Text; + //Trace.WriteLine("==============="+item2.Value); + string str = (string)item2.Value; + fileInfo.versionId = int.Parse(str==null?"0": str); + //Trace.WriteLine("========"+ fileInfo.versionId); + fileInfo.remotePath = remotePath; + await HttpUtils.saveMediaFileInfo(fileInfo); + changeButtonState(4); + } + } + + private bool isMediaFile(String name) + { + if (name.ToLower().EndsWith(".mov") || name.ToLower().EndsWith(".mp4") || name.ToLower().EndsWith(".jpg") || name.ToLower().EndsWith(".png") || name.ToLower().EndsWith(".bmp")) + { + return true; + } + else + { + return false; + } + } + + private bool isValidFile(String name) + { + if (name.ToLower().EndsWith(".json") || name.ToLower().EndsWith(".mov") || name.ToLower().EndsWith(".mp4") || name.ToLower().EndsWith(".jpg") || name.ToLower().EndsWith(".png") || name.ToLower().EndsWith(".bmp")) + { + return true; + } + else + { + return false; + } + + } + + private List getMediaFileItemList(List uploadFiles, string remotePath) + { + //remotePath = "/data5/file/xuebao" + remotePath; + List list = new List(); + foreach (string name in uploadFiles) + { + MediaFileItem item = new MediaFileItem(); + //item.fileType = FileUploadUtils.getFileExt(name); + item.fileName = name; + string filename = FileUploadUtils.getFileName(name); + bool isValid = false; + if (filename.ToLower().EndsWith(".json")) + { + item.urlPath = remotePath + "/json/" + filename; + isValid = true; + } + else if (isMediaFile(filename)) + { + item.urlPath = remotePath + "/media/" + filename; + isValid = true; + } + if (isValid) + { + item.time = FileUploadUtils.getFileCreateDataTime(name); + list.Add(item); + } + } + return list; + } + + private void addFileToList(int type) + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.Multiselect = true; + openFileDialog.Filter = "Ïà»úÎļþ|*.mp4;*.avi;*.mkv;*.mov;*.wmv;*.flv;*.json|All Files|*.*"; + openFileDialog.RestoreDirectory = true; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (uploadFiles == null) + { + uploadFiles = new List(); + } + if (type == 0) + { + uploadFiles.Clear(); + } + foreach (var fileName in openFileDialog.FileNames) + { + if (isValidFile(fileName)) + { + uploadFiles.Add(fileName); + } + } + addToTable(uploadFiles); + changeButtonState(1); + } + } + private void btnSelFile_Click(object sender, EventArgs e) + { + addFileToList(0); + } + + private void btnSysConfig_Click(object sender, EventArgs e) + { + pnlUpload.Visible = false; + pnlConfig.Dock = DockStyle.Fill; + pnlConfig.Visible = true; + } + + private void btnOpenUpload_Click(object sender, EventArgs e) + { + pnlConfig.Visible = false; + pnlUpload.Dock = DockStyle.Fill; + pnlUpload.Visible = true; + } + + private void loadConfigData() + { + string str = CommonUtils.readFromFile("common", "server_url"); + txt_server_url.Text = str; + + str = CommonUtils.readFromFile("ftp_server", "server_ip"); + txt_ftp_server.Text = str; + + str = CommonUtils.readFromFile("ftp_server", "server_port"); + txt_server_port.Text = str; + + str = CommonUtils.readFromFile("ftp_server", "ftp_user"); + txt_ftp_user.Text = CommonUtils.DecryptToString(Convert.FromBase64String(str)); + + str = CommonUtils.readFromFile("ftp_server", "ftp_password"); + txt_ftp_password.Text = CommonUtils.DecryptToString(Convert.FromBase64String(str)); + + } + + private void btn_save_Click(object sender, EventArgs e) + { + string str = txt_server_url.Text; + if (str == "") + { + MessageBox.Show("WEB·þÎñµØַ²»ÄÜΪ¿Õ"); + return; + } + CommonUtils.writeToIni("common", "server_url", str); + + str = txt_ftp_server.Text; + if (str == "") + { + MessageBox.Show("Îļþ·þÎñµØַ²»ÄÜΪ¿Õ"); + return; + } + CommonUtils.writeToIni("ftp_server", "server_ip", str); + + str = txt_server_port.Text; + if (str == "") + { + MessageBox.Show("Îļþ·þÎñ¶˿ڲ»ÄÜΪ¿Õ"); + return; + } + CommonUtils.writeToIni("ftp_server", "server_port", str); + + str = txt_ftp_user.Text; + if (str == "") + { + MessageBox.Show("Îļþ·þÎñÕ˺Ų»ÄÜΪ¿Õ"); + return; + } + str = Convert.ToBase64String(CommonUtils.EncryptString(str)); + CommonUtils.writeToIni("ftp_server", "ftp_user", str); + + str = txt_ftp_password.Text; + if (str == "") + { + MessageBox.Show("Îļþ·þÎñÃÜÂ벻ÄÜΪ¿Õ"); + return; + } + str = Convert.ToBase64String(CommonUtils.EncryptString(str)); + CommonUtils.writeToIni("ftp_server", "ftp_password", str); + MessageBox.Show("ÅäÖÃÒѱ£´æ"); + + } + + private void addDirectoryToList(int type) + { + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + if (folderBrowserDialog.ShowDialog() == DialogResult.OK) + { + string selectedDirectoryPath = folderBrowserDialog.SelectedPath; + txtDirectory.Text = selectedDirectoryPath; + if (uploadFiles == null) + { + uploadFiles = new List(); + } + if (type == 0) + { + uploadFiles.Clear(); + } + getAllMediaFile(selectedDirectoryPath, uploadFiles); + + addToTable(uploadFiles); + + if (uploadFiles.Count > 0) + { + changeButtonState(1); + } + else + { + //clearTable(); + changeButtonState(2); + } + } + } + } + + private void btnAddDirectory_Click(object sender, EventArgs e) + { + addDirectoryToList(1); + } + + private void versionList_Validating(object sender, System.ComponentModel.CancelEventArgs e) + { + if (!versionList.Items.Contains(versionList.Text) && !string.IsNullOrEmpty(versionList.Text)) + { + versionList.Items.Add(versionList.Text); + } + } + + private void versionList_SelectedIndexChanged(object sender, EventArgs e) + { + if (versionList.SelectedIndex == -1 && !versionList.Items.Contains(versionList.Text) && !string.IsNullOrEmpty(versionList.Text)) + { + ComboboxItem versionItem = new ComboboxItem(versionList.Text, 0); + versionList.Items.Add(versionItem); + versionList.SelectedItem = versionItem; + } + } + + private void btnAddfiles_Click(object sender, EventArgs e) + { + addFileToList(1); + } + } + + +} diff --git a/MainForm.resx b/MainForm.resx new file mode 100644 index 0000000..87dd442 --- /dev/null +++ b/MainForm.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAAEoAAABACAYAAAC9S+EXAAAABGdBTUEAALGPC/xhBQAAArZJREFUeF7t + mbGK1UAUhrcW7Gz0CazsrGzsbG0WZJEVLLRRudyJW2eyWIjIqg+giIoPIIgPYKVYWLnOZHVR2MZOsV5P + YIK5kzNz/8R4M9Hzw8fC7vx7h4+T4SZZywp72Bely0trS6Lyj8eywnzn+k2UNg9cJZpMm/dcv4kqzBu3 + PJpM24dc32eu7XpvUehmaN0jrt+EJH3bur171FWCyYryGtdvkX865SrBqGLvNNtl+CNRyGZuFuUZtutB + 6zZdJRh0MmnNfVeJBpnMmt6i6JK75z4vGpqUD1zf47VbHg2te+z1WqCTSfu/zvVD9BKFXybmBtf3Ufnn + k64SDDqZxEVXCQafzN/0naghN7PjKtGsejJ9+ohCN/PE67XAJ9PO/C7HwJO5QGdRw27GbLhKMLNb+8fB + ybzrKtGAk9miq6ghNwNNptL2KdNdgL5+HAw5mRywqA6bmftdjmEns7zgKsF0mEyWDhMFbkbbn3y/ibnj + KtEMfIA/83qdQEWBmzHPme4C1WReyQ+OuEowNE0Z1/f5mwd4E0yUNlezbXs2xrywl9lumx2u34TOpXPI + ZNK6l1y/RWF2uX4Xuh7m/y0iCkREgYgoEBEFIqJARBSIiAIRUSAiCkREgYwjStt39HOmtPnR+luijCXq + bXVXv5V/OUE3tq/YNYkxqqg6ars8T7/7yq5NhCREVameUVXvCtn1CZCMqDrV2+cub3BXRXKi6tC6pA77 + ZEVVSemwT1pUnRQO+0mIqjL2YT8ZUXXGOuwnJ6oO/Z+VHvaTFVVllYf99EUV5gX7GQMjlx6IHOYgkxEl + Xw+AyBfOJZFbGEAUrZOb4pgoeczShBElD+44PFHyKDiEEyUvF5Yhr6v+XUQUiIgCEVEgIgpERIGIKBAR + BSKiQEQUiIgCEVEgIgpERIGIKBARBTLXdv0X9/j2tcAXujEAAAAASUVORK5CYII= + + + + 17, 17 + + + True + + + True + + + True + + + True + + + 25 + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..f5248eb --- /dev/null +++ b/Program.cs @@ -0,0 +1,23 @@ +namespace FileProcessClient +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new LoginForm()); + if (Application.OpenForms.Count == 0) + { + return; + } + + //Application.Run(new mainForm()); + } + } +} \ No newline at end of file diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..0e0187f --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,253 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace FileProcessClient.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileProcessClient.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap Account { + get { + object obj = ResourceManager.GetObject("Account", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap add_files { + get { + object obj = ResourceManager.GetObject("add-files", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap avatar { + get { + object obj = ResourceManager.GetObject("avatar", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap avatar1 { + get { + object obj = ResourceManager.GetObject("avatar1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap file_loading { + get { + object obj = ResourceManager.GetObject("file-loading", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap file_upload { + get { + object obj = ResourceManager.GetObject("file-upload", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap folder_add { + get { + object obj = ResourceManager.GetObject("folder-add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap open_folder { + get { + object obj = ResourceManager.GetObject("open-folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap open_folder1 { + get { + object obj = ResourceManager.GetObject("open-folder1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap open_folder2 { + get { + object obj = ResourceManager.GetObject("open-folder2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap save_icon { + get { + object obj = ResourceManager.GetObject("save-icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap select_file { + get { + object obj = ResourceManager.GetObject("select-file", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap sys_config { + get { + object obj = ResourceManager.GetObject("sys-config", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap sys_config1 { + get { + object obj = ResourceManager.GetObject("sys-config1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap sys_logo { + get { + object obj = ResourceManager.GetObject("sys-logo", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap upload_file { + get { + object obj = ResourceManager.GetObject("upload-file", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap upload_to_server { + get { + object obj = ResourceManager.GetObject("upload-to-server", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap upload_to_server_01 { + get { + object obj = ResourceManager.GetObject("upload-to-server-01", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap video_icon { + get { + object obj = ResourceManager.GetObject("video-icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..8cc4ee9 --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\sys-config.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\upload-to-server-01.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\open-folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\save-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\file-loading.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\open-folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\avatar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\folder-add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sys-logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\upload-to-server.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\open-folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\avatar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\file-upload.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\video-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\upload-file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Account.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\select-file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sys-config.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\add-files.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Resources/Account.png b/Resources/Account.png new file mode 100644 index 0000000..34d2ab9 Binary files /dev/null and b/Resources/Account.png differ diff --git a/Resources/Config-local.ini b/Resources/Config-local.ini new file mode 100644 index 0000000..eefb671 --- /dev/null +++ b/Resources/Config-local.ini @@ -0,0 +1,20 @@ +[common] +server_url=http://192.168.60.245:8080 +[ApiUrls] +login_url=/login +user_info_url=/getInfo +camera_list_url=/device/baseInfo/listForSelect +file_version_list_url=/system/dict/data/fileVersionList +save_media_file_url=/media/file/save +[ftp_server] +server_ip=192.168.60.245 +server_port=8121 +user=semiftp +password=123456 +ftp_user=iy14APNXQf1k6/NEWW/SnmJpbigRw/ktWC6PpcCJrd/bHzQeYQbER9QtKG/6UmOa +ftp_password=tY0N0HgDOc2TDKPzzT9L6up5hRH5+NZ0C5aRLyCD3f1yNeyZH5BDvIz5Kpr2iA9R +[userData] +userName=SSVzGfXIf8JBOyrpAxHDzPBD5Lj1qIR8dK09qsmkxi0AWdek55dATWhgS1RA9a6+ +password=VdVRjZAunKjB0HFGnsXj1C8F1X3fSVfi41KRSWp/kV9tWpmplx6+zJpvDaaznGyp +[security] +token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQ1ZDYzM2Q3LTkyZmYtNDBiZC04ZThiLTM1NTdhYjBkMTZjNSJ9.YplKaPMNxtIfaexdchgQPrXiRc0RFvpcJo9DpmSvuCNNkZ6JBAHTTEOZODFza_85B7C5AUPI75lGlfEet2qmPA diff --git a/Resources/Config.ini b/Resources/Config.ini new file mode 100644 index 0000000..3cb901d --- /dev/null +++ b/Resources/Config.ini @@ -0,0 +1,20 @@ +[common] +server_url=http://semi-ai.tech:18093/ +[ApiUrls] +login_url=/login +user_info_url=/getInfo +camera_list_url=/device/baseInfo/listForSelect +file_version_list_url=/system/dict/data/fileVersionList +save_media_file_url=/media/file/save +[ftp_server] +server_ip=192.168.60.245 +server_port=8121 +user=semiftp +password=123456 +ftp_user=iy14APNXQf1k6/NEWW/SnmJpbigRw/ktWC6PpcCJrd/bHzQeYQbER9QtKG/6UmOa +ftp_password=tY0N0HgDOc2TDKPzzT9L6up5hRH5+NZ0C5aRLyCD3f1yNeyZH5BDvIz5Kpr2iA9R +[userData] +userName=SSVzGfXIf8JBOyrpAxHDzPBD5Lj1qIR8dK09qsmkxi0AWdek55dATWhgS1RA9a6+ +password=VdVRjZAunKjB0HFGnsXj1C8F1X3fSVfi41KRSWp/kV9tWpmplx6+zJpvDaaznGyp +[security] +token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQ1ZDYzM2Q3LTkyZmYtNDBiZC04ZThiLTM1NTdhYjBkMTZjNSJ9.YplKaPMNxtIfaexdchgQPrXiRc0RFvpcJo9DpmSvuCNNkZ6JBAHTTEOZODFza_85B7C5AUPI75lGlfEet2qmPA diff --git a/Resources/Icon1.ico b/Resources/Icon1.ico new file mode 100644 index 0000000..5d06b9f Binary files /dev/null and b/Resources/Icon1.ico differ diff --git a/Resources/add-files.png b/Resources/add-files.png new file mode 100644 index 0000000..98883b0 Binary files /dev/null and b/Resources/add-files.png differ diff --git a/Resources/avatar.png b/Resources/avatar.png new file mode 100644 index 0000000..5a834ab Binary files /dev/null and b/Resources/avatar.png differ diff --git a/Resources/file-loading.gif b/Resources/file-loading.gif new file mode 100644 index 0000000..aa6845e Binary files /dev/null and b/Resources/file-loading.gif differ diff --git a/Resources/file-upload.png b/Resources/file-upload.png new file mode 100644 index 0000000..6dd308e Binary files /dev/null and b/Resources/file-upload.png differ diff --git a/Resources/folder-add.png b/Resources/folder-add.png new file mode 100644 index 0000000..7fd1d2d Binary files /dev/null and b/Resources/folder-add.png differ diff --git a/Resources/open-folder.png b/Resources/open-folder.png new file mode 100644 index 0000000..5e8ea96 Binary files /dev/null and b/Resources/open-folder.png differ diff --git a/Resources/open-folder1.png b/Resources/open-folder1.png new file mode 100644 index 0000000..17f25c9 Binary files /dev/null and b/Resources/open-folder1.png differ diff --git a/Resources/save-icon.png b/Resources/save-icon.png new file mode 100644 index 0000000..32472b9 Binary files /dev/null and b/Resources/save-icon.png differ diff --git a/Resources/save.png b/Resources/save.png new file mode 100644 index 0000000..d7c0ce7 Binary files /dev/null and b/Resources/save.png differ diff --git a/Resources/select-file.png b/Resources/select-file.png new file mode 100644 index 0000000..31f5011 Binary files /dev/null and b/Resources/select-file.png differ diff --git a/Resources/sys-config.png b/Resources/sys-config.png new file mode 100644 index 0000000..62ecaf2 Binary files /dev/null and b/Resources/sys-config.png differ diff --git a/Resources/sys-config1.png b/Resources/sys-config1.png new file mode 100644 index 0000000..830f46e Binary files /dev/null and b/Resources/sys-config1.png differ diff --git a/Resources/sys-logo.png b/Resources/sys-logo.png new file mode 100644 index 0000000..5b108e4 Binary files /dev/null and b/Resources/sys-logo.png differ diff --git a/Resources/upload-file.png b/Resources/upload-file.png new file mode 100644 index 0000000..75186d4 Binary files /dev/null and b/Resources/upload-file.png differ diff --git a/Resources/upload-to-server-01.png b/Resources/upload-to-server-01.png new file mode 100644 index 0000000..d4f9456 Binary files /dev/null and b/Resources/upload-to-server-01.png differ diff --git a/Resources/upload-to-server.png b/Resources/upload-to-server.png new file mode 100644 index 0000000..8e1a8c5 Binary files /dev/null and b/Resources/upload-to-server.png differ diff --git a/Resources/video-icon.png b/Resources/video-icon.png new file mode 100644 index 0000000..46a60fb Binary files /dev/null and b/Resources/video-icon.png differ diff --git a/domain/ComboboxItem.cs b/domain/ComboboxItem.cs new file mode 100644 index 0000000..9d15a9c --- /dev/null +++ b/domain/ComboboxItem.cs @@ -0,0 +1,19 @@ +namespace FileProcessClient.domain +{ + internal class ComboboxItem + { + public string Text { get; set; } + public object Value { get; set; } + + public override string ToString() + { + return Text; + } + + public ComboboxItem(string text, object value) + { + Text = text; + Value = value; + } + } +} diff --git a/domain/DeviceInfo.cs b/domain/DeviceInfo.cs new file mode 100644 index 0000000..e9598ca --- /dev/null +++ b/domain/DeviceInfo.cs @@ -0,0 +1,17 @@ +namespace FileProcessClient.domain +{ + internal class DeviceInfo + { + private long _id; + private string _name=""; + private string _duid=""; + private double _lon; + private double _lat; + + public long Id { get { return _id; } set { _id = value; } } + public string Name { get { return _name; } set { _name = value; } } + public double Lon { get { return _lon; } set { _lon = value; } } + public double Lat { get { return _lat; } set { _lat = value; } } + public string Duid { get { return _duid; } set { _duid = value; } } + } +} diff --git a/domain/MediaFileInfo.cs b/domain/MediaFileInfo.cs new file mode 100644 index 0000000..98aae6c --- /dev/null +++ b/domain/MediaFileInfo.cs @@ -0,0 +1,44 @@ +using Microsoft.VisualBasic; +using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Xml.Linq; + +namespace FileProcessClient.domain +{ + internal class MediaFileInfo + { + + private int _uploadType; + + private string _deviceId; + + private string _deviceName; + + //private long userId; + + private string _version; + + private int _versionId; + + private string _remotePath; + + private List _ileItems; + public int uploadType { get { return _uploadType; } set { _uploadType = value; } } + + public string deviceId { get { return _deviceId; } set { _deviceId = value; } } + + //public long UserId { get { return userId; } set { userId = value; } } + + public string version { get { return _version; } set { _version = value; } } + + public int versionId { get { return _versionId; } set { _versionId = value; } } + + public string remotePath { get { return _remotePath; } set { _remotePath = value; } } + + + public string deviceName { get { return _deviceName; } set { _deviceName = value; } } + + public List fileItems { get { return _ileItems; } set { _ileItems = value; } } + + + } +} diff --git a/domain/MediaFileItem.cs b/domain/MediaFileItem.cs new file mode 100644 index 0000000..32717bb --- /dev/null +++ b/domain/MediaFileItem.cs @@ -0,0 +1,25 @@ +namespace FileProcessClient.domain +{ + internal class MediaFileItem + { + private string _fileName; + + //private string _fileType; + + private string _urlPath; + + private string _metaPath; + + private string _time; + + public string fileName { get { return _fileName; } set { _fileName = value; } } + + //public string fileType { get { return _fileType; } set { _fileType = value; } } + + public string urlPath { get { return _urlPath; } set { _urlPath = value; } } + + public string metaPath { get { return _metaPath; } set { _metaPath = value; } } + + public string time { get { return _time; } set { _time = value; } } + } +} diff --git a/domain/User.cs b/domain/User.cs new file mode 100644 index 0000000..d3b5644 --- /dev/null +++ b/domain/User.cs @@ -0,0 +1,28 @@ +namespace FileProcessClient.domain +{ + internal class User + { + private int id; + private string name = ""; + private string loginId = ""; + private string phone = ""; + private int deptId; + + + public int Id { get { return id; } set { id = value; } } + public string Name { get { return name; } set { name = value; } } + public string LoginId { get { return loginId; } set { loginId = value; } } + public string Phone { get { return phone; } set { phone = value; } } + + public int DeptId { get { return deptId; } set { deptId = value; } } + + public User(int id, string name, string loginId, string phone, int deptId) + { + Id = id; + Name = name; + LoginId = loginId; + Phone = phone; + DeptId = deptId; + } + } +} diff --git a/utils/CommonUtils.cs b/utils/CommonUtils.cs new file mode 100644 index 0000000..c9fd1fe --- /dev/null +++ b/utils/CommonUtils.cs @@ -0,0 +1,218 @@ +using FileProcessClient.domain; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Xml.Linq; + +namespace edu.huvtc.utils +{ + internal class CommonUtils + { + [DllImport("kernel32")] + private static extern long WritePrivateProfileString(string name, string key, string val, + string filePath); + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, string key, string def, + StringBuilder retVal, int size, + string filePath); + + private const int AesBlockByteSize = 128 / 8; + + private const int PasswordSaltByteSize = 128 / 8; + + private const int PasswordByteSize = 256 / 8; + + private const int PasswordIterationCount = 100_000; + + private static readonly Encoding StringEncoding = Encoding.UTF8; + + private static readonly RandomNumberGenerator Random = RandomNumberGenerator.Create(); + + private static String password = "from huvtc passwords 123412;,[p;[; 172634812"; + + private static string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "Config.ini"; + + private static string Token = ""; + + private static string serverUrl = ""; + + private static User user; + + public static User getUser() + { + return user; + } + + public static void setUser(User data) + { + user = data; + } + + + public static void setToken(string token) + { + writeToIni("security", "token", token); + Token = token; + } + + public static string getToken() + { + if (Token == null || Token == "") + { + Token = readFromFile("security", "token"); + } + return Token; + } + + public static void writeToIni(string name, string key, string value) + { + WritePrivateProfileString(name, key, value, INIPath); + } + + public static string readFromFile(string name, string key) + { + StringBuilder builder = new StringBuilder(255); + int ini = GetPrivateProfileString(name, key, "", builder, 255, INIPath); + return builder.ToString(); + } + + + public static byte[] EncryptString(string toEncrypt) + { + using (var aes = Aes.Create()) + { + var keySalt = GenerateRandomBytes(PasswordSaltByteSize); + var key = GetKey(keySalt); + var iv = GenerateRandomBytes(AesBlockByteSize); + + using (var encryptor = aes.CreateEncryptor(key, iv)) + { + var plainText = StringEncoding.GetBytes(toEncrypt); + var cipherText = encryptor + .TransformFinalBlock(plainText, 0, plainText.Length); + + var result = MergeArrays(keySalt, iv, cipherText); + return result; + } + } + } + + + public static string DecryptToString(byte[] encryptedData) + { + using (var aes = Aes.Create()) + { + var keySalt = encryptedData.Take(PasswordSaltByteSize).ToArray(); + var key = GetKey(keySalt); + var iv = encryptedData + .Skip(PasswordSaltByteSize).Take(AesBlockByteSize).ToArray(); + var cipherText = encryptedData + .Skip(PasswordSaltByteSize + AesBlockByteSize).ToArray(); + + using (var encryptor = aes.CreateDecryptor(key, iv)) + { + var decryptedBytes = encryptor + .TransformFinalBlock(cipherText, 0, cipherText.Length); + return StringEncoding.GetString(decryptedBytes); + } + } + } + + private static byte[] GetKey(byte[] passwordSalt) + { + var keyBytes = StringEncoding.GetBytes(password); + + using (var derivator = new Rfc2898DeriveBytes( + keyBytes, passwordSalt, + PasswordIterationCount, HashAlgorithmName.SHA256)) + { + return derivator.GetBytes(PasswordByteSize); + } + } + + private static byte[] GenerateRandomBytes(int numberOfBytes) + { + var randomBytes = new byte[numberOfBytes]; + Random.GetBytes(randomBytes); + return randomBytes; + } + + private static byte[] MergeArrays(params byte[][] arrays) + { + var merged = new byte[arrays.Sum(a => a.Length)]; + var mergeIndex = 0; + for (int i = 0; i < arrays.GetLength(0); i++) + { + arrays[i].CopyTo(merged, mergeIndex); + mergeIndex += arrays[i].Length; + } + + return merged; + } + + public static string getServerUrl() + { + if (serverUrl == null || serverUrl.Length == 0) + { + serverUrl = readFromFile("common", "server_url"); + } + return serverUrl; + } + + public static string getTokenFormIni() + { + return readFromFile("security", "token"); + } + + public static void savePassword(string username, string password) + { + username = Convert.ToBase64String(CommonUtils.EncryptString(username)); + + password = Convert.ToBase64String(CommonUtils.EncryptString(password)); + + writeToIni("userData", "userName", username); + + writeToIni("userData", "password", password); + } + + public static string getApiUrl(string name) + { + return readFromFile("ApiUrls", name); + + } + + public static string getFtpServer() + { + return readFromFile("ftp_server", "server_ip"); + } + + public static string getFtpUsr() + { + return getDecryptValue("ftp_server", "ftp_user"); + } + + public static string getFtpPassword() + { + return getDecryptValue("ftp_server", "ftp_password"); + + } + + private static string getDecryptValue(string name, string item) + { + string str = readFromFile(name, item); + if (str == null) + { + return ""; + } + else + { + return DecryptToString(Convert.FromBase64String(str)); + } + } + + public static int getFtpServerPort() + { + return int.Parse(readFromFile("ftp_server", "server_port")); + } + } +} diff --git a/utils/FileUploadUtils.cs b/utils/FileUploadUtils.cs new file mode 100644 index 0000000..a28054b --- /dev/null +++ b/utils/FileUploadUtils.cs @@ -0,0 +1,163 @@ +using edu.huvtc.utils; +using FileProcessClient.domain; +using FluentFTP; +using System.Diagnostics; + +namespace FileProcessClient.utils +{ + internal class FileUploadUtils + { + public static async Task UploadFileAsync(string localPath, string remoteFilePath, Action callback) + { + var token = new CancellationToken(); + using (var conn = new AsyncFtpClient(CommonUtils.getFtpServer(), CommonUtils.getFtpUsr(), CommonUtils.getFtpPassword(), CommonUtils.getFtpServerPort(), config: new FtpConfig + { + DataConnectionType = FtpDataConnectionType.PORT + })) + { + try + { + await conn.Connect(token); + Progress progress = new Progress(p => + { + callback((int)(p.Progress)); + //Trace.WriteLine(p.Progress); + }); + await conn.UploadFile(localPath, remoteFilePath, FtpRemoteExists.Overwrite, false, FtpVerify.None, progress, token); + } + catch (Exception ex) + { + callback(-1); + //Trace.WriteLine(ex.ToString()); + } + finally + { + await conn.Disconnect(); + } + } + } + + + public static async Task UploadFilesAsync(List list, string remoteRootPath, Action callback) + { + var token = new CancellationToken(); + using (var conn = new AsyncFtpClient(CommonUtils.getFtpServer(), CommonUtils.getFtpUsr(), CommonUtils.getFtpPassword(), CommonUtils.getFtpServerPort(), config: new FtpConfig + { + DataConnectionType = FtpDataConnectionType.PASV, + ConnectTimeout = 60000, + ReadTimeout = 60000 + })) + { + int index = 0; + try + { + await conn.Connect(token); + + //conn.AutoDetect(FtpDataConnectionType.PORT); + Progress progress = new Progress(p => + { + //Trace.WriteLine(p.Progress); + callback(index, (int)(p.Progress)); + + }); + + bool pathExits = await conn.DirectoryExists(remoteRootPath + "/json", token); + if (!pathExits) + { + await conn.CreateDirectory(remoteRootPath + "/json", true, token); + } + + pathExits = await conn.DirectoryExists(remoteRootPath + "/media", token); + if (!pathExits) + { + await conn.CreateDirectory(remoteRootPath + "/media", true, token); + } + + foreach (MediaFileItem file in list) + { + //Trace.WriteLine(file.fileName); + //Trace.WriteLine(file.urlPath); + await conn.UploadFile(file.fileName, file.urlPath, FtpRemoteExists.Overwrite, false, FtpVerify.None, progress, token); + index++; + } + return true; + } + catch (Exception ex) + { + callback(index, -1); + Trace.WriteLine(ex.ToString()); + //return false; + } + finally + { + await conn.Disconnect(); + } + return false; + } + } + + public static async Task UploadFilesAsync(List localFiles, string remoteRootPath, Action callback) + { + var token = new CancellationToken(); + using (var conn = new AsyncFtpClient(CommonUtils.getFtpServer(), CommonUtils.getFtpUsr(), CommonUtils.getFtpPassword(), CommonUtils.getFtpServerPort(), config: new FtpConfig + { + DataConnectionType = FtpDataConnectionType.PORT + })) + { + int index = 0; + try + { + await conn.Connect(token); + Progress progress = new Progress(p => + { + callback(index, (int)(p.Progress)); + + }); + bool pathExits = await conn.DirectoryExists(remoteRootPath, token); + if (!pathExits) + { + await conn.CreateDirectory(remoteRootPath, true, token); + } + foreach (var file in localFiles) + { + //Trace.WriteLine(file); + //Trace.WriteLine(remoteRootPath + "/" + getFileName(file)); + await conn.UploadFile(file, remoteRootPath + "/" + getFileName(file), FtpRemoteExists.Overwrite, false, FtpVerify.None, progress, token); + index++; + } + return true; + + } + catch (Exception ex) + { + callback(index, -1); + return false; + //Trace.WriteLine(ex.ToString()); + } + finally + { + await conn.Disconnect(); + } + } + } + + public static string getFileName(string fullPath) + { + string[] arr = fullPath.Split(Path.DirectorySeparatorChar); + return arr[arr.Length - 1]; + } + + public static string getFileExt(string fullPath) + { + string[] arr = fullPath.Split("\\."); + return arr[arr.Length - 1]; + } + + + public static string getFileCreateDataTime(string filePath) + { + FileInfo fileInfo = new FileInfo(filePath); + return fileInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"); + } + } +} diff --git a/utils/HttpUtils.cs b/utils/HttpUtils.cs new file mode 100644 index 0000000..d9a25b2 --- /dev/null +++ b/utils/HttpUtils.cs @@ -0,0 +1,247 @@ +using FileProcessClient.domain; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Diagnostics; +using System.Net; +using System.Net.Http.Headers; +using System.Text.Json.Nodes; + +namespace edu.huvtc.utils +{ + internal class HttpUtils + { + + public static async Task HttpClientPost(string url, string data) + { + string token = CommonUtils.getToken(); + + var handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.None }; + + handler.ServerCertificateCustomValidationCallback = (message, cert, chain, error) => true; + + string serverUrl = CommonUtils.getServerUrl(); + + using (var httpclient = new HttpClient(handler)) + { + try + { + httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + + httpclient.BaseAddress = new Uri(serverUrl + url); + + HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json"); + + content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + + var response = await httpclient.PostAsync(url, content); + + string responseString = await response.Content.ReadAsStringAsync(); + + //Trace.WriteLine(responseString); + + return responseString; + } + catch (HttpRequestException e) + { + // 捕获 HttpRequestException 异常以处理网络错误 + //Console.WriteLine($"请求异常: {e.Message}"); + MessageBox.Show("网络异常,请确认是否联网!"); + return ""; + } + catch (TaskCanceledException e) + { + MessageBox.Show("请求超时!"); + return ""; + } + catch (Exception e) + { + // 捕获其他异常 + //Console.WriteLine($"其他异常: {e.Message}"); + MessageBox.Show("发生未知错误"); + return "503"; + } + } + + } + + public static async Task HttpClientGet(string url, string query) + { + string token = CommonUtils.getToken(); + + url = CommonUtils.getServerUrl() + url; + + Trace.WriteLine(url); + + using (HttpClient client = new HttpClient()) + { + try + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + + var builder = new UriBuilder(url); + + //var query = System.Web.HttpUtility.ParseQueryString(builder.Query); + //query["param1"] = "value1"; + //query["param2"] = "value2"; + + builder.Query = query; + + string str_url = builder.ToString(); + + HttpResponseMessage response = await client.GetAsync(str_url); + + + return await response.Content.ReadAsStringAsync(); + } + catch (HttpRequestException e) + { + // 捕获 HttpRequestException 异常以处理网络错误 + //Console.WriteLine($"请求异常: {e.Message}"); + MessageBox.Show("网络或服务器异常!"); + return ""; + } + catch (TaskCanceledException e) + { + MessageBox.Show("请求超时!"); + return ""; + } + catch (Exception e) + { + // 捕获其他异常 + //Console.WriteLine($"其他异常: {e.Message}"); + MessageBox.Show("发生未知错误"); + return ""; + } + + } + + } + + public static async Task getUserInfo() + { + string token = CommonUtils.getToken(); + //Trace.WriteLine(token); + if (token != null && token != "") + { + string url = CommonUtils.getApiUrl("user_info_url"); + string result = await HttpUtils.HttpClientGet(url, ""); + + //Trace.WriteLine(result); + if (result == "") + { + return false; + } + JObject jsonObject = JObject.Parse(result); + int code = (int)jsonObject["code"]!; + if (code != 200) + { + return false; + } + else + { + string strUser = jsonObject["user"]!.ToString(); + + //Trace.WriteLine(strUser); + + JObject obj = JObject.Parse(strUser); + int id = (int)obj["userId"]!; + string loginId = (string)obj["userName"]!; + string phone = (string)obj["phonenumber"]!; + string name = (string)obj["nickName"]!; + int deptId = (int)obj["deptId"]!; + User user = new User(id, name, loginId, phone, deptId); + CommonUtils.setUser(user); + return true; + } + } + else + { + return false; + } + } + + public static async Task saveMediaFileInfo(MediaFileInfo mediaFileInfo) + { + var jsonString = JsonConvert.SerializeObject(mediaFileInfo); + //Trace.WriteLine(jsonString); + string url = CommonUtils.getApiUrl("save_media_file_url"); + string res = await HttpClientPost(url, jsonString); + if (res == "") + { + return false; + } + return true; + } + + public static async Task> getVersionList() + { + string url = CommonUtils.getApiUrl("file_version_list_url"); + + string res = await HttpUtils.HttpClientGet(url, ""); + //Trace.WriteLine(res); + if (res == null) + { + return new List(); + } + + List list = new List(); + JArray array = JArray.Parse(res); + + foreach (var item in array) + { + list.Add(new ComboboxItem(item["dictLabel"]!.ToString(), item["dictCode"]!.ToString())); + } + + return list; + } + + public static async Task> getCameraList() + { + string url = CommonUtils.getApiUrl("camera_list_url"); + + string res = await HttpUtils.HttpClientGet(url, ""); + if (res == null) + { + return new List(); + } + + List list = new List(); + + JArray array = JArray.Parse(res); + + foreach (var item in array) + { + list.Add(new ComboboxItem(item["duid"]!.ToString(), item["id"]!.ToString())); + } + + return list; + } + + public static async Task validateLogin(string username, string password) + { + JsonObject obj = new JsonObject(); + obj.Add("username", username); + obj.Add("password", password); + obj.Add("loginType", 1); + string result = await HttpUtils.HttpClientPost("/login", obj.ToString()); + Trace.WriteLine("==================="+result); + if (result == "") + { + return false; + } + JObject jsonObject = JObject.Parse(result); + + int code = (int)jsonObject["code"]!; + if (code == 200) + { + string token = (string)jsonObject["token"]!; + CommonUtils.setToken(token); + return true; + } + else + { + return false; + } + } + } +}