大幅度重构代码,还需要完善测试【A large number of changes, need coding】

This commit is contained in:
dathlin
2017-05-04 11:43:50 +08:00
parent 119eafd6b2
commit f8c17d882e
34 changed files with 3611 additions and 911 deletions

View File

@@ -1,4 +1,6 @@
namespace CommonLibrary
using HslCommunication.Controls;
namespace CommonLibrary
{
partial class FormAccountManage
{
@@ -30,8 +32,8 @@
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.userButton2 = new BasicFramework.UserButton();
this.userButton1 = new BasicFramework.UserButton();
this.userButton2 = new UserButton();
this.userButton1 = new UserButton();
this.SuspendLayout();
//
// textBox1

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CommonLibrary
{
/// <summary>
/// 维护变更的窗口,用来维护服务器的状态,有可能处于维护中
/// </summary>
public partial class FormMaintenance : Form
{
/// <summary>
/// 实例化一个窗口对象,用来更改系统的维护状态,然后进行保存
/// </summary>
/// <param name="settings">服务器的参数对象</param>
public FormMaintenance(ServerSettings settings)
{
InitializeComponent();
Settings = settings;
}
private void userButton1_Click(object sender, EventArgs e)
{
if (!userButton1.Selected)
{
userButton1.Selected = true;
userButton2.Selected = false;
}
}
private void userButton2_Click(object sender, EventArgs e)
{
if (!userButton2.Selected)
{
userButton1.Selected = false;
userButton2.Selected = true;
}
}
private ServerSettings Settings = null;
private void FormMaintenance_Shown(object sender, EventArgs e)
{
if (Settings.Can_Account_Login)
{
userButton1.Selected = true;
}
else
{
userButton2.Selected = true;
}
textBox1.Text = Settings.Account_Forbidden_Reason;
}
private void userButton3_Click(object sender, EventArgs e)
{
if (userButton1.Selected)
{
Settings.Can_Account_Login = true;
}
else
{
Settings.Can_Account_Login = false;
}
Settings.Account_Forbidden_Reason = textBox1.Text;
Settings.SaveToFile();
MessageBox.Show("保存成功");
Close();
}
}
}

View File

@@ -0,0 +1,134 @@
using HslCommunication.Controls;
namespace CommonLibrary
{
partial class FormMaintenance
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.userButton1 = new UserButton();
this.userButton2 = new UserButton();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.userButton3 = new UserButton();
this.SuspendLayout();
//
// userButton1
//
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 15F);
this.userButton1.Location = new System.Drawing.Point(12, 13);
this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(176, 61);
this.userButton1.TabIndex = 0;
this.userButton1.UIText = "可登录";
this.userButton1.Click += new System.EventHandler(this.userButton1_Click);
//
// userButton2
//
this.userButton2.BackColor = System.Drawing.Color.Transparent;
this.userButton2.CustomerInformation = "";
this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton2.Font = new System.Drawing.Font("微软雅黑", 15F);
this.userButton2.Location = new System.Drawing.Point(231, 13);
this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton2.Name = "userButton2";
this.userButton2.Size = new System.Drawing.Size(189, 61);
this.userButton2.TabIndex = 1;
this.userButton2.UIText = "维护中";
this.userButton2.Click += new System.EventHandler(this.userButton2_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 78);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(92, 17);
this.label1.TabIndex = 2;
this.label1.Text = "维护中文本说明";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 98);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(411, 55);
this.textBox1.TabIndex = 3;
//
// userButton3
//
this.userButton3.BackColor = System.Drawing.Color.Transparent;
this.userButton3.CustomerInformation = "";
this.userButton3.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton3.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton3.Location = new System.Drawing.Point(158, 162);
this.userButton3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton3.Name = "userButton3";
this.userButton3.Size = new System.Drawing.Size(115, 37);
this.userButton3.TabIndex = 4;
this.userButton3.UIText = "保存";
this.userButton3.Click += new System.EventHandler(this.userButton3_Click);
//
// FormMaintenance
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(435, 209);
this.Controls.Add(this.userButton3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.userButton2);
this.Controls.Add(this.userButton1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(451, 248);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(451, 248);
this.Name = "FormMaintenance";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "维护变更";
this.Shown += new System.EventHandler(this.FormMaintenance_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private UserButton userButton1;
private UserButton userButton2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private UserButton userButton3;
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CommonLibrary
{
/// <summary>
/// 一个简单的修改密码的类
/// </summary>
public partial class FormPasswordModify : Form
{
/// <summary>
/// 实例化一个密码修改窗口,需要指定密码修改的方法
/// </summary>
/// <param name="password_old">旧密码,需要用来验证权限</param>
/// <param name="submitMethod">修改密码的真正方法</param>
/// <param name="passwordLengthMin">指定密码长度最小值,可不提供</param>
/// <param name="passwordLengthMax">指定密码长度最大值,可不提供</param>
public FormPasswordModify(string password_old,
Func<string, bool> submitMethod,
int passwordLengthMin = 4,
int passwordLengthMax = 8)
{
InitializeComponent();
PasswordLengthMin = passwordLengthMin;
PasswordLengthMax = passwordLengthMax;
PasswordOriginal = password_old;
SubmitMethod = submitMethod;
}
private void FormPasswordModify_Load(object sender, EventArgs e)
{
Text = "密码修改 [务必不要使用简单的密码] ";
timer1.Interval = 1000;
timer1.Tick += Timer1_Tick;
label4.Text = $"剩余修改时间:{WaittingTime}秒";
}
private void Timer1_Tick(object sender, EventArgs e)
{
if (WaittingTime > 0)
{
label4.Text = $"剩余修改时间:{WaittingTime--}秒";
}
else
{
WaittingTime = 120;
panel1.Visible = false;
label4.Text = $"剩余修改时间:{WaittingTime}秒";
textBox2.Text = "";
textBox3.Text = "";
textBox1.Enabled = true;
userButton1.Enabled = true;
timer1.Stop();
}
}
private int WaittingTime { get; set; } = 120;
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
userButton1.PerformClick();
}
}
private void FormPasswordModify_Shown(object sender, EventArgs e)
{
textBox1.Focus();
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
textBox3.Focus();
}
}
private void userButton1_Click(object sender, EventArgs e)
{
//验证原密码
if (textBox1.Text == PasswordOriginal)
{
textBox1.Enabled = false;
userButton1.Enabled = false;
panel1.Visible = true;
textBox2.Focus();
timer1.Start();
}
else
{
MessageBox.Show("密码验证错误!");
}
}
private string PasswordOriginal { get; set; } = "";
private int PasswordLengthMin { get; set; } = 4;
private int PasswordLengthMax { get; set; } = 8;
private Func<string, bool> SubmitMethod = null;
private void userButton2_Click(object sender, EventArgs e)
{
if (textBox2.Text.Length >= PasswordLengthMin &&
textBox2.Text.Length <= PasswordLengthMax)
{
if (textBox2.Text != textBox3.Text)
{
MessageBox.Show("两次密码不一致,请重新输入");
}
else
{
if (SubmitMethod == null)
{
MessageBox.Show("该功能未实现!");
}
else
{
if (SubmitMethod(textBox2.Text))
{
MessageBox.Show("密码更新成功!");
}
else
{
MessageBox.Show("密码更新失败!请稍候重试!");
}
}
}
}
else
{
MessageBox.Show($"密码长度不正确,请控制在{PasswordLengthMin}-{PasswordLengthMax}位之间");
}
}
private void FormPasswordModify_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Stop();
}
}
}

View File

@@ -0,0 +1,200 @@
using HslCommunication.Controls;
namespace CommonLibrary
{
partial class FormPasswordModify
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.userButton1 = new UserButton();
this.panel1 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.userButton2 = new UserButton();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(163, 20);
this.label1.TabIndex = 0;
this.label1.Text = "请输入原密码进行验证:";
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.Location = new System.Drawing.Point(16, 36);
this.textBox1.Name = "textBox1";
this.textBox1.PasswordChar = '*';
this.textBox1.Size = new System.Drawing.Size(287, 23);
this.textBox1.TabIndex = 1;
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
//
// userButton1
//
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton1.Location = new System.Drawing.Point(310, 35);
this.userButton1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(73, 24);
this.userButton1.TabIndex = 2;
this.userButton1.UIText = "确认";
this.userButton1.Click += new System.EventHandler(this.userButton1_Click);
//
// panel1
//
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.userButton2);
this.panel1.Controls.Add(this.textBox3);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.label2);
this.panel1.Location = new System.Drawing.Point(8, 71);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(384, 328);
this.panel1.TabIndex = 3;
this.panel1.Visible = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.ForeColor = System.Drawing.Color.Gray;
this.label4.Location = new System.Drawing.Point(4, 164);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(107, 20);
this.label4.TabIndex = 7;
this.label4.Text = "剩余修改时间:";
//
// userButton2
//
this.userButton2.BackColor = System.Drawing.Color.Transparent;
this.userButton2.CustomerInformation = "";
this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton2.Font = new System.Drawing.Font("微软雅黑", 10.5F);
this.userButton2.Location = new System.Drawing.Point(134, 235);
this.userButton2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.userButton2.Name = "userButton2";
this.userButton2.Size = new System.Drawing.Size(117, 31);
this.userButton2.TabIndex = 6;
this.userButton2.UIText = "提交";
this.userButton2.Click += new System.EventHandler(this.userButton2_Click);
//
// textBox3
//
this.textBox3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox3.Location = new System.Drawing.Point(8, 124);
this.textBox3.Name = "textBox3";
this.textBox3.PasswordChar = '*';
this.textBox3.Size = new System.Drawing.Size(287, 23);
this.textBox3.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(4, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(135, 20);
this.label3.TabIndex = 4;
this.label3.Text = "请再次输入新密码:";
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox2.Location = new System.Drawing.Point(8, 61);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(287, 23);
this.textBox2.TabIndex = 3;
this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(4, 34);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(107, 20);
this.label2.TabIndex = 2;
this.label2.Text = "请输入新密码:";
//
// FormPasswordModify
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(396, 407);
this.Controls.Add(this.panel1);
this.Controls.Add(this.userButton1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(412, 446);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(412, 446);
this.Name = "FormPasswordModify";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "密码修改窗口";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormPasswordModify_FormClosing);
this.Load += new System.EventHandler(this.FormPasswordModify_Load);
this.Shown += new System.EventHandler(this.FormPasswordModify_Shown);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private UserButton userButton1;
private System.Windows.Forms.Panel panel1;
private UserButton userButton2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label4;
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -8,10 +8,10 @@ using Newtonsoft.Json.Linq;
namespace CommonLibrary
{
/// <summary>
/// 服务器的账户管理类,如果你采用这种方式存储,必须仔细阅读说明手册
/// 服务器的账户管理类,如果你采用这种方式存储,请参照本项目事例
/// </summary>
/// <typeparam name="T">账户类该类必须派生自UserAccount类</typeparam>
public class ServerAccounts<T> where T : UserAccount, new()
public class ServerAccounts<T> : HslCommunication.BasicFramework.SoftFileSaveBase where T : UserAccount, new()
{
/// <summary>
/// 初始化构造方法
@@ -28,11 +28,6 @@ namespace CommonLibrary
all_list_accounts.AddRange(accounts);
}
/// <summary>
/// 所有的帳戶信息存儲的位置,只有設置了才進行保存
/// </summary>
public string FileSavePath { get; set; } = "";
private List<T> all_list_accounts = new List<T>();
private object lock_list_accounts = new object();
@@ -128,17 +123,10 @@ namespace CommonLibrary
/// <param name="json_account">账户对象的JSON表示方式</param>
/// <returns>成功True失败False</returns>
public bool AddNewAccount(string json_account)
{
try
{
T account = JObject.Parse(json_account).ToObject<T>();
return AddNewAccount(account);
}
catch
{
return false;
}
}
/// <summary>
/// 新增一个账户如果账户名称已经存在则返回False注册成功返回True
/// </summary>
@@ -218,72 +206,46 @@ namespace CommonLibrary
{
all_list_accounts = JArray.Parse(json).ToObject<List<T>>();
}
catch
catch(Exception ex)
{
LogHelper.LogSave(Resource.StringResouce.AccountLoadFailed, ex);
}
}
}
}
}
}
/// <summary>
/// 使用Base64编码将所有的账户信息保存到文件
/// 从字符串加载数据内容
/// </summary>
public void SaveFile()
/// <param name="content"></param>
public override void LoadByString(string content)
{
SaveFile(m => Convert.ToBase64String(Encoding.Unicode.GetBytes(m)));
}
/// <summary>
/// 使用自定义的加密方法将所有账户信息保存到文件
/// </summary>
/// <param name="encrypt">加密的方式</param>
public void SaveFile(Converter<string, string> encrypt)
{
if (FileSavePath != "")
{
string result = GetAllAccountsJson();
StreamWriter sw = new StreamWriter(FileSavePath, false, Encoding.Default);
sw.Write(encrypt(result));
sw.Flush();
sw.Dispose();
}
}
/// <summary>
/// 使用Base64编码从文件加载所有的账户
/// </summary>
public void LoadByFile()
{
LoadByFile(m => Encoding.Unicode.GetString(Convert.FromBase64String(m)));
LoadAllAccountsJson(content);
}
/// <summary>
/// 使用自定义的解密方法加载所有的账户
/// 获取需要保存的数据内容
/// </summary>
public void LoadByFile(Converter<string, string> decrypt)
/// <returns></returns>
public override string ToSaveString()
{
if (FileSavePath != "")
{
if (File.Exists(FileSavePath))
{
StreamReader sr = new StreamReader(FileSavePath, Encoding.Default);
string result = sr.ReadToEnd();
sr.Close();
sr.Dispose();
result = decrypt(result);
LoadAllAccountsJson(result);
return GetAllAccountsJson();
}
}
}
/**************************************************************
*
* 日志记录块,保存运行中的所有的异常信息,方便追踪系统异常
*
*************************************************************/
/// <summary>
/// 日志记录对象
/// 使用加密规则从文件加载
/// </summary>
public HslCommunication.Enthernet.HslLogHelper LogHelper { get; set; }
public override void LoadByFile()
{
LoadByFile(m => m);
}
/// <summary>
/// 使用加密规则保存到文件
/// </summary>
public override void SaveToFile()
{
SaveToFile(m => m);
}
}
}

View File

@@ -0,0 +1,61 @@
using HslCommunication.BasicFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CommonLibrary
{
/// <summary>
/// 系统更新日志类窗体
/// </summary>
public partial class FormUpdateLog : Form
{
/// <summary>
/// 实例化一个更新窗口的对象,用来呈现更新日志
/// </summary>
/// <param name="versions">包含了更新细节的一个对象,更新日志,更新内容</param>
public FormUpdateLog(IEnumerable<VersionInfo> versions)
{
InitializeComponent();
Versions = versions;
}
private IEnumerable<VersionInfo> Versions = null;
private void FormUpdateLog_Load(object sender, EventArgs e)
{
richTextBox1.SelectionIndent = 3;
richTextBox1.SelectionHangingIndent = 16;
richTextBox1.SelectionRightIndent = 3;
listBox1.DataSource = Versions;
listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
ListBox1_SelectedIndexChanged(null, new EventArgs());
}
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem != null)
{
VersionInfo info = listBox1.SelectedItem as VersionInfo;
if (info != null)
{
richTextBox1.Clear();
richTextBox1.AppendText("版本:" + info.VersionNum + Environment.NewLine);
richTextBox1.AppendText("日期:" + info.ReleaseDate.ToShortDateString() + Environment.NewLine);
richTextBox1.AppendText(Environment.NewLine);
richTextBox1.AppendText("内容:" + Environment.NewLine +
info.UpdateDetails.ToString() + Environment.NewLine);
richTextBox1.SelectionStart = 0;
}
}
}
}
}

View File

@@ -0,0 +1,119 @@
namespace CommonLibrary
{
partial class FormUpdateLog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.Black;
this.label2.Location = new System.Drawing.Point(144, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(90, 21);
this.label2.TabIndex = 9;
this.label2.Text = "更新日志:";
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.ForeColor = System.Drawing.Color.Black;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(74, 21);
this.label1.TabIndex = 8;
this.label1.Text = "版本号:";
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.listBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 21;
this.listBox1.Location = new System.Drawing.Point(15, 39);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(123, 403);
this.listBox1.TabIndex = 10;
//
// richTextBox1
//
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.richTextBox1.Location = new System.Drawing.Point(148, 38);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.richTextBox1.Size = new System.Drawing.Size(489, 394);
this.richTextBox1.TabIndex = 11;
this.richTextBox1.Text = "";
//
// FormUpdateLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(651, 448);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormUpdateLog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "更新日志";
this.Load += new System.EventHandler(this.FormUpdateLog_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.RichTextBox richTextBox1;
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,59 @@
using HslCommunication.BasicFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CommonLibrary
{
/// <summary>
/// 控制版本号的窗口类
/// </summary>
public partial class FormVersionControl : Form
{
/// <summary>
///
/// </summary>
/// <param name="settings"></param>
public FormVersionControl(ServerSettings settings)
{
InitializeComponent();
Settings = settings;
}
private ServerSettings Settings = null;
private void FormVersionControl_Shown(object sender, EventArgs e)
{
textBox1.Text = Settings.SystemVersion.ToString();
textBox2.Focus();
}
private void userButton1_Click(object sender, EventArgs e)
{
try
{
Settings.SystemVersion = new SystemVersion(textBox2.Text);
}
catch(Exception ex)
{
MessageBox.Show("版本号格式错误应为1.0.0" + Environment.NewLine +
"错误描述:" + ex.Message);
}
try
{
Settings.SaveToFile();
MessageBox.Show("保存成功");
}
catch(Exception ex)
{
MessageBox.Show("数据保存失败" + Environment.NewLine +
"错误描述:" + ex.Message);
}
}
}
}

View File

@@ -0,0 +1,122 @@
using HslCommunication.Controls;
namespace CommonLibrary
{
partial class FormVersionControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.userButton1 = new UserButton();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(24, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 17);
this.label1.TabIndex = 0;
this.label1.Text = "当前版本:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(101, 28);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(261, 23);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(101, 68);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(261, 23);
this.textBox2.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(24, 71);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 17);
this.label2.TabIndex = 2;
this.label2.Text = "更新版本:";
//
// userButton1
//
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton1.Location = new System.Drawing.Point(145, 110);
this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(110, 30);
this.userButton1.TabIndex = 4;
this.userButton1.UIText = "保存";
this.userButton1.Click += new System.EventHandler(this.userButton1_Click);
//
// FormVersionControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(397, 158);
this.Controls.Add(this.userButton1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(413, 197);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(413, 197);
this.Name = "FormVersionControl";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "系统版本更新";
this.Shown += new System.EventHandler(this.FormVersionControl_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private UserButton userButton1;
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using System.IO;
using HslCommunication.BasicFramework;
//2017-02-10
namespace CommonLibrary
{
/// <summary>
/// 服务器的常用参数保存,包含了版本号,公告,是否允许登录,不能登录说明
/// </summary>
public class ServerSettings : SoftFileSaveBase
{
/// <summary>
/// 系统的版本号,可以用来验证版本更新的依据
/// 初始化1.0.0
/// </summary>
public SystemVersion SystemVersion { get; set; } = new SystemVersion("1.0.0");
/// <summary>
/// 系统的公告信息,默认为测试公告
/// </summary>
public string Announcement { get; set; } = "测试公告";
/// <summary>
/// 是否允许账户登录
/// 超级管理员账户除外
/// </summary>
public bool Can_Account_Login { get; set; } = true;
/// <summary>
/// 不允许登录系统的原因
/// </summary>
public string Account_Forbidden_Reason { get; set; } = "系统处于维护中,请稍后登录。";
/// <summary>
/// 获取需要存储的数据
/// </summary>
/// <returns></returns>
public override string ToSaveString()
{
JObject json = new JObject
{
{ nameof(SystemVersion), new JValue(SystemVersion.ToString()) },
{ nameof(Announcement), new JValue(Announcement) },
{ nameof(Can_Account_Login), new JValue(Can_Account_Login) },
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) }
};
return json.ToString();
}
/// <summary>
/// 从字符串数据加载配置
/// </summary>
/// <param name="content"></param>
public override void LoadByString(string content)
{
JObject json = JObject.Parse(content);
SystemVersion = new SystemVersion(json.Property(nameof(SystemVersion)).Value.Value<string>());
Announcement = json.Property(nameof(Announcement)).Value.Value<string>();
Can_Account_Login = SoftBasic.GetValueFromJsonObject(json, nameof(Can_Account_Login), Can_Account_Login);
Account_Forbidden_Reason = SoftBasic.GetValueFromJsonObject(json, nameof(Account_Forbidden_Reason), Account_Forbidden_Reason);
}
}
/// <summary>
/// 用户客户端存储本地JSON数据的类包含了所有需要存储的信息
/// </summary>
public class JsonSettings : SoftFileSaveBase
{
/// <summary>
/// 实例化一个设置的对象
/// </summary>
public JsonSettings()
{
SystemInfo = SoftAuthorize.GetInfo();
}
/// <summary>
/// 指示系统是否是更新后第一次运行
/// </summary>
public bool IsNewVersionRunning { get; set; } = true;
/// <summary>
/// 上次系统登录的用户名
/// </summary>
public string LoginName { get; set; } = "";
/// <summary>
/// 上次系统登录的密码
/// </summary>
public string Password { get; set; } = "";
/// <summary>
/// 当前计算机的机器码,用来判定参数是否是正确的
/// </summary>
public string SystemInfo { get; private set; }
public override string ToSaveString()
{
JObject json = new JObject();
json.Add(nameof(LoginName), new JValue(LoginName));
json.Add(nameof(Password), new JValue(Password));
json.Add(nameof(IsNewVersionRunning), new JValue(IsNewVersionRunning));
json.Add(nameof(SystemInfo), new JValue(SystemInfo));
return json.ToString();
}
public override void LoadByString(string content)
{
JObject json = JObject.Parse(content);
string systemInfo = SoftBasic.GetValueFromJsonObject(json, nameof(SystemInfo), "");
if (systemInfo == SystemInfo)
{
//文件匹配正确
LoginName = SoftBasic.GetValueFromJsonObject(json, nameof(LoginName), LoginName);
IsNewVersionRunning = SoftBasic.GetValueFromJsonObject(json, nameof(IsNewVersionRunning), IsNewVersionRunning);
Password = SoftBasic.GetValueFromJsonObject(json, nameof(Password), Password);
}
}
/// <summary>
/// 使用指定的解密实现数据解密
/// </summary>
public override void LoadByFile()
{
LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonLibrary.Security));
}
public override void SaveToFile()
{
SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonLibrary.Security));
}
}
}

View File

@@ -36,7 +36,10 @@ namespace CommonLibrary
#endregion
/// <summary>
/// 整个系统的加密解密密码
/// </summary>
public const string Security = "qwertyui";
}

View File

@@ -52,8 +52,33 @@
<Compile Include="AccountSupport\FormAccountManage.designer.cs">
<DependentUpon>FormAccountManage.cs</DependentUpon>
</Compile>
<Compile Include="AccountSupport\FormMaintenance.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AccountSupport\FormMaintenance.designer.cs">
<DependentUpon>FormMaintenance.cs</DependentUpon>
</Compile>
<Compile Include="AccountSupport\FormPasswordModify.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AccountSupport\FormPasswordModify.designer.cs">
<DependentUpon>FormPasswordModify.cs</DependentUpon>
</Compile>
<Compile Include="AccountSupport\ServerAccount.cs" />
<Compile Include="AccountSupport\UserAccount.cs" />
<Compile Include="BasicSupport\FormUpdateLog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BasicSupport\FormUpdateLog.designer.cs">
<DependentUpon>FormUpdateLog.cs</DependentUpon>
</Compile>
<Compile Include="BasicSupport\FormVersionControl.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="BasicSupport\FormVersionControl.designer.cs">
<DependentUpon>FormVersionControl.cs</DependentUpon>
</Compile>
<Compile Include="BasicSupport\SoftSettings.cs" />
<Compile Include="Common.cs" />
<Compile Include="HeadCode.cs" />
<Compile Include="OrderSupport\ClassGoods.cs" />
@@ -68,7 +93,20 @@
<EmbeddedResource Include="AccountSupport\FormAccountManage.resx">
<DependentUpon>FormAccountManage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AccountSupport\FormMaintenance.resx">
<DependentUpon>FormMaintenance.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AccountSupport\FormPasswordModify.resx">
<DependentUpon>FormPasswordModify.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BasicSupport\FormUpdateLog.resx">
<DependentUpon>FormUpdateLog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BasicSupport\FormVersionControl.resx">
<DependentUpon>FormVersionControl.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -17,6 +17,10 @@ namespace CommonLibrary
{
public static string SoftName { get; } = "你的软件系统";
public static string SoftCopyRight { get; } = "版权归属人";
public const string AccountLoadFailed = "新增账户失败";
}
}
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
namespace
using HslCommunication.Controls;
namespace
{
partial class FormLogin
{
@@ -33,7 +35,7 @@
this.textBox_userName = new System.Windows.Forms.TextBox();
this.textBox_password = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.userButton_login = new BasicFramework.UserButton();
this.userButton_login = new UserButton();
this.label_version = new System.Windows.Forms.Label();
this.label_copyright = new System.Windows.Forms.Label();
this.label_status = new System.Windows.Forms.Label();
@@ -181,7 +183,7 @@
private System.Windows.Forms.TextBox textBox_userName;
private System.Windows.Forms.TextBox textBox_password;
private System.Windows.Forms.Label label3;
private BasicFramework.UserButton userButton_login;
private UserButton userButton_login;
private System.Windows.Forms.Label label_version;
private System.Windows.Forms.Label label_copyright;
private System.Windows.Forms.Label label_status;

View File

@@ -9,6 +9,8 @@ using System.Windows.Forms;
using System.Threading;
using Newtonsoft.Json.Linq;
using HslCommunication;
using CommonLibrary;
using HslCommunication.BasicFramework;
namespace
{
@@ -36,7 +38,7 @@ namespace 软件系统客户端模版
label_status.Visible = false;
UserClient.JsonSettings.FileSavePath = Application.StartupPath + @"\JsonSettings.txt";
UserClient.JsonSettings.LoadSettings();//根据实际实际情况选中解密算法默认采用DES加密解密算法
UserClient.JsonSettings.LoadByFile();//根据实际实际情况选中解密算法默认采用DES加密解密算法
label_version.Text = "版本:" + UserClient.CurrentVersion.ToString();
label2.Text = CommonLibrary.Resource.StringResouce.SoftName;
@@ -200,14 +202,14 @@ namespace 软件系统客户端模版
//包装数据
Newtonsoft.Json.Linq.JObject json = new Newtonsoft.Json.Linq.JObject();
json.Add(BasicFramework.UserAccount.UserNameText, new Newtonsoft.Json.Linq.JValue(textBox_userName.Text));
json.Add(BasicFramework.UserAccount.PasswordText, new Newtonsoft.Json.Linq.JValue(textBox_password.Text));
json.Add(UserAccount.UserNameText, new Newtonsoft.Json.Linq.JValue(textBox_userName.Text));
json.Add(UserAccount.PasswordText, new Newtonsoft.Json.Linq.JValue(textBox_password.Text));
result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.+json.ToString());
if (result.IsSuccess)
{
//服务器应该返回账户的信息
BasicFramework.UserAccount account = JObject.Parse(result.Content).ToObject<BasicFramework.UserAccount>();
UserAccount account = JObject.Parse(result.Content).ToObject<UserAccount>();
if(!account.LoginEnable)
{
//不允许登录
@@ -228,7 +230,7 @@ namespace 软件系统客户端模版
//登录成功,进行保存用户名称和密码
UserClient.JsonSettings.LoginName = textBox_userName.Text;
UserClient.JsonSettings.Password = checkBox_remeber.Checked ? textBox_password.Text : "";
UserClient.JsonSettings.SaveSettings();
UserClient.JsonSettings.SaveToFile();
//版本验证
@@ -242,7 +244,7 @@ namespace 软件系统客户端模版
if (result.IsSuccess)
{
//服务器应该返回服务器的版本号
BasicFramework.SystemVersion sv = new BasicFramework.SystemVersion(result.Content);
SystemVersion sv = new SystemVersion(result.Content);
//系统账户跳过低版本检测
if (UserClient.UserAccount.UserName != "admin")
{
@@ -250,7 +252,7 @@ namespace 软件系统客户端模版
{
//保存新版本信息
UserClient.JsonSettings.IsNewVersionRunning = true;
UserClient.JsonSettings.SaveSettings();
UserClient.JsonSettings.SaveToFile();
//和当前系统版本号不一致,启动更新
if (IsHandleCreated) Invoke(start_update);
return;
@@ -262,7 +264,7 @@ namespace 软件系统客户端模版
{
//保存新版本信息
UserClient.JsonSettings.IsNewVersionRunning = true;
UserClient.JsonSettings.SaveSettings();
UserClient.JsonSettings.SaveToFile();
//和当前系统版本号不一致,启动更新
if (IsHandleCreated) Invoke(start_update);
return;
@@ -295,7 +297,7 @@ namespace 软件系统客户端模版
//服务器返回初始化的数据,此处进行数据的提取,有可能包含了多个数据
json = Newtonsoft.Json.Linq.JObject.Parse(result.Content);
//例如公告数据
UserClient.Announcement = BasicFramework.SoftBasic.GetValueFromJsonObject(json, nameof(UserClient.Announcement), "");
UserClient.Announcement = SoftBasic.GetValueFromJsonObject(json, nameof(UserClient.Announcement), "");
}
else

View File

@@ -1,4 +1,6 @@
namespace
using HslCommunication.Controls;
namespace
{
partial class FormRegisterAccount
{
@@ -38,7 +40,7 @@
this.label5 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.userButton_login = new BasicFramework.UserButton();
this.userButton_login = new UserButton();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
@@ -201,7 +203,7 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label6;
private BasicFramework.UserButton userButton_login;
private UserButton userButton_login;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
}

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Windows.Forms;
using HslCommunication.Enthernet;
using HslCommunication;
using CommonLibrary;
namespace
{
@@ -22,13 +23,13 @@ namespace 软件系统客户端模版
private void FormRegisterAccount_Load(object sender, EventArgs e)
{
comboBox1.DataSource = BasicFramework.AccountGrade.GetDescription();
comboBox1.DataSource = AccountGrade.GetDescription();
comboBox2.DataSource = new string[] { "允许", "不允许" };
comboBox1.SelectedItem = BasicFramework.AccountGrade.GetDescription(BasicFramework.AccountGrade.Technology);
comboBox1.SelectedItem = AccountGrade.GetDescription(AccountGrade.Technology);
comboBox2.SelectedItem = "允许";
textBox4.Text = (new BasicFramework.UserAccount()).ForbidMessage;
textBox4.Text = (new UserAccount()).ForbidMessage;
}
private Net_Simplify_Client net_client = null;
@@ -36,20 +37,20 @@ namespace 软件系统客户端模版
private void userButton_login_Click(object sender, EventArgs e)
{
//点击了注册,先获取数据
BasicFramework.UserAccount account = new BasicFramework.UserAccount();
UserAccount account = new UserAccount();
account.UserName = textBox1.Text;
account.Password = textBox2.Text;
switch (comboBox1.SelectedIndex)
{
case 0: account.Grade = BasicFramework.AccountGrade.SuperAdministrator; break;
case 1: account.Grade = BasicFramework.AccountGrade.Admin; break;
case 2: account.Grade = BasicFramework.AccountGrade.Technology; break;
default: account.Grade = BasicFramework.AccountGrade.General; break;
case 0: account.Grade = AccountGrade.SuperAdministrator; break;
case 1: account.Grade = AccountGrade.Admin; break;
case 2: account.Grade = AccountGrade.Technology; break;
default: account.Grade = AccountGrade.General; break;
}
account.LoginEnable = comboBox2.SelectedItem.ToString() == "允许";
account.ForbidMessage = textBox4.Text;
OperateResultString result = net_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode. + account.ToJsonString());
OperateResultString result = net_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode. + account.ToJsonString());
if (result.IsSuccess && result.Content == "1")
{
MessageBox.Show("注册成功!");

View File

@@ -1,4 +1,6 @@
namespace
using HslCommunication.Controls;
namespace
{
partial class FormUpdateRemote
{
@@ -29,10 +31,10 @@
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.userButton_file = new BasicFramework.UserButton();
this.userButton_file = new UserButton();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.userButton_version = new BasicFramework.UserButton();
this.userButton_version = new UserButton();
this.SuspendLayout();
//
// label1
@@ -116,9 +118,9 @@
#endregion
private System.Windows.Forms.Label label1;
private BasicFramework.UserButton userButton_file;
private UserButton userButton_file;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private BasicFramework.UserButton userButton_version;
private UserButton userButton_version;
}
}

View File

@@ -9,7 +9,7 @@ using System.Windows.Forms;
using Newtonsoft.Json.Linq;
using HslCommunication.Enthernet;
using HslCommunication;
using CommonLibrary;
namespace .UIControls
{
@@ -25,7 +25,7 @@ namespace 软件系统客户端模版.UIControls
private void userButton_upload_Click(object sender, EventArgs e)
{
//上传数据,先对权限进行验证
if(UserClient.UserAccount.Grade<BasicFramework.AccountGrade.Technology)
if(UserClient.UserAccount.Grade<AccountGrade.Technology)
{
MessageBox.Show("权限不够!");
return;

View File

@@ -3,7 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using HslCommunication.Enthernet;
using HslCommunication.BasicFramework;
using CommonLibrary;
namespace
{
@@ -15,11 +16,11 @@ namespace 软件系统客户端模版
public class UserClient
{
public static BasicFramework.JsonSettings JsonSettings = new BasicFramework.JsonSettings();
public static JsonSettings JsonSettings = new JsonSettings();
/// <summary>
/// 本软件的当前版本,用来验证更新的关键依据
/// </summary>
public static BasicFramework.SystemVersion CurrentVersion { get; } = new BasicFramework.SystemVersion("1.0.0");
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0");
/// <summary>
/// 服务器的IP地址默认为127.0.0.1,可用于单机调试
@@ -29,20 +30,17 @@ namespace 软件系统客户端模版
/// <summary>
/// 所有版本更新信息的对象
/// </summary>
public static BasicFramework.ClassSystemVersion HistoryVersions { get; } = new BasicFramework.ClassSystemVersion()
{
Versions = new List<BasicFramework.VersionInfo>()
public static List<VersionInfo> HistoryVersions { get; } = new List<VersionInfo>
{
//写入所有的历史版本信息,这样就能在更新日志的界面查看到信息
new BasicFramework.VersionInfo()
new VersionInfo()
{
VersionNum=new BasicFramework.SystemVersion("1.0.0"),
VersionNum=new SystemVersion("1.0.0"),
ReleaseDate=new DateTime(2017,1,1),//该版本发布的日期
UpdateDetails=new StringBuilder("1.本系统第一版本正式发布使用。"+Environment.NewLine+
"2.提供了多客户端用时在线的功能。"+Environment.NewLine+
"3.需要用户自行添加"),
},
},
};
@@ -55,7 +53,7 @@ namespace 软件系统客户端模版
/// <summary>
/// 当前系统的登录账户
/// </summary>
public static BasicFramework.UserAccount UserAccount { get; set; } = new BasicFramework.UserAccount();
public static UserAccount UserAccount { get; set; } = new UserAccount();
/// <summary>
/// 服务器的时间该时间与服务器同步每隔10秒钟防止客户端串改单机时间可以作为各种时间条件判定
@@ -70,7 +68,7 @@ namespace 软件系统客户端模版
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
CommonLibrary.CommonLibrary.Port_Second_Net))
{
KeyToken = CommonLibrary.CommonHeadCode.KeyToken,
KeyToken = CommonHeadCode.KeyToken,
};
}
}

View File

@@ -32,10 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BasicFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\BasicFramework.dll</HintPath>
</Reference>
<Reference Include="CommonLibrary">
<HintPath>..\CommonLibrary\bin\Debug\CommonLibrary.dll</HintPath>
</Reference>

View File

@@ -15,7 +15,7 @@
{
//紧急存储数据
UserServer.ServerSettings.SaveToFile();
UserServer.ServerAccounts.SaveFile();
UserServer.ServerAccounts.SaveToFile();
if (disposing && (components != null))
{

View File

@@ -9,8 +9,8 @@ using System.Windows.Forms;
using HslCommunication.Enthernet;
using System.Threading;
using CommonLibrary;
using BasicFramework;
using Newtonsoft.Json.Linq;
using HslCommunication.BasicFramework;
//============================================================================
@@ -77,7 +77,7 @@ namespace 软件系统服务端模版
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//密码验证的示例,此处关闭窗口验证
BasicFramework.FormPasswordCheck fpc = new BasicFramework.FormPasswordCheck("123456");
FormPasswordCheck fpc = new FormPasswordCheck("123456");
if (fpc.ShowDialog() == DialogResult.OK)
{
IsWindowShow = false;
@@ -122,7 +122,7 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormVersionControl fvc = new BasicFramework.FormVersionControl(UserServer.ServerSettings);
FormVersionControl fvc = new FormVersionControl(UserServer.ServerSettings);
fvc.ShowDialog();
fvc.Dispose();
toolStripStatusLabel_version.Text = UserServer.ServerSettings.SystemVersion.ToString();
@@ -130,7 +130,7 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormMaintenance fm = new BasicFramework.FormMaintenance(UserServer.ServerSettings);
FormMaintenance fm = new FormMaintenance(UserServer.ServerSettings);
fm.ShowDialog();
fm.Dispose();
MaintenanceInitialization();
@@ -158,9 +158,9 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormAbout fm = new BasicFramework.FormAbout(
CommonLibrary.Resource.StringResouce.SoftName, UserServer.ServerSettings.SystemVersion,
2017, CommonLibrary.Resource.StringResouce.SoftCopyRight);
FormAbout fm = new FormAbout(
Resource.StringResouce.SoftName, UserServer.ServerSettings.SystemVersion,
2017, Resource.StringResouce.SoftCopyRight);
fm.ShowDialog();
fm.Dispose();
}
@@ -175,7 +175,7 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormAboutVersion fav = new BasicFramework.FormAboutVersion(UserServer.ServerSettings.SystemVersion);
FormAboutVersion fav = new FormAboutVersion(UserServer.ServerSettings.SystemVersion);
fav.ShowDialog();
fav.Dispose();
}
@@ -215,7 +215,7 @@ namespace 软件系统服务端模版
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
SoftBasic.ShowExceptionMessage(ex);
}
}
@@ -240,7 +240,7 @@ namespace 软件系统服务端模版
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
SoftBasic.ShowExceptionMessage(ex);
}
}
#endregion
@@ -265,7 +265,7 @@ namespace 软件系统服务端模版
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
SoftBasic.ShowExceptionMessage(ex);
}
}
/// <summary>
@@ -305,7 +305,7 @@ namespace 软件系统服务端模版
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
//此处使用的是组件自带的验证的方式如果使用SQL数据库另行验证
Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(object2.Substring(4));
JObject json = JObject.Parse(object2.Substring(4));
//提取账户,密码
string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, "");
string password = SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, "");
@@ -421,7 +421,7 @@ namespace 软件系统服务端模版
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
SoftBasic.ShowExceptionMessage(ex);
}
}
@@ -570,6 +570,6 @@ namespace 软件系统服务端模版
/// <summary>
/// 还未有其他什么用途
/// </summary>
private HslLogHelper LogHelper = new HslLogHelper();
private SoftLogHelper LogHelper { get; set; }
}
}

View File

@@ -1,8 +1,8 @@
using System;
using CommonLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BasicFramework;
//=========================================================================================
//
@@ -49,6 +49,7 @@ namespace 软件系统服务端模版
/// <summary>
/// 一个扩展的用户账户示例,代替服务器和客户端的账户类即可
/// 也可以直接在源代码中扩展
/// </summary>
public class UserAccountEx : UserAccount
{

View File

@@ -32,10 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BasicFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\BasicFramework.dll</HintPath>
</Reference>
<Reference Include="CommonLibrary">
<HintPath>..\CommonLibrary\bin\Debug\CommonLibrary.dll</HintPath>
</Reference>