大幅度重构代码,还需要完善测试【A large number of changes, need coding】
This commit is contained in:
8
软件系统客户端模版/FormLogin.Designer.cs
generated
8
软件系统客户端模版/FormLogin.Designer.cs
generated
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
8
软件系统客户端模版/FormRegisterAccount.Designer.cs
generated
8
软件系统客户端模版/FormRegisterAccount.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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("注册成功!");
|
||||
|
||||
12
软件系统客户端模版/FormUpdateRemote.Designer.cs
generated
12
软件系统客户端模版/FormUpdateRemote.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
public static List<VersionInfo> HistoryVersions { get; } = new List<VersionInfo>
|
||||
{
|
||||
Versions = new List<BasicFramework.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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user