修复了BUG,更新了组件V1.0.1版,提供了很多功能

This commit is contained in:
hsl20
2017-03-04 17:07:26 +08:00
parent e2fd8a7b29
commit d277f6a289
18 changed files with 797 additions and 60 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommonLibrary
{
public class CommonLibrary
{
#region
/// <summary>
/// 主网络端口,此处随机定义了一个数据
/// </summary>
public static int Port_Main_Net { get; } = 17652;
/// <summary>
/// 同步网络访问的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Second_Net { get; } = 14568;
/// <summary>
/// 用于软件系统更新的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Update_Net { get; } = 17538;
/// <summary>
/// 用于软件远程更新的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Update_Remote { get; } = 26435;
#endregion
}
}

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>8c97f322-4306-40fc-afcf-753384d80046</ProjectGuid>
<ProjectGuid>{8C97F322-4306-40FC-AFCF-753384D80046}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CommonLibrary</RootNamespace>
@@ -30,20 +30,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="CommonHeadCode.cs" />
<Compile Include="HeadCode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resource.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -53,5 +51,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

51
CommonLibrary/HeadCode.cs Normal file
View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommonLibrary
{
/// <summary>
/// 用于网络通信的二级协议头说明
/// </summary>
public class CommonHeadCode
{
/// <summary>
/// 同步通信的头说明以字母A开头
/// </summary>
public class SimplifyHeadCode
{
public static string { get; } = "A001";//A开始的表明是系统相关的
public static string { get; } = "A002";
public static string { get; } = "A003";
public static string { get; } = "A004";
public static string { get; } = "A005";
public static string { get; } = "A006";
public static string { get; } = "A007";
public static string { get; } = "A008";
public static string { get; } = "A009";
public static string { get; } = "B001";//B开头的是日志请求和清空
public static string { get; } = "B002";
public static string { get; } = "B003";
public static string { get; } = "B004";
public static string { get; } = "B005";
public static string { get; } = "B006";
}
/// <summary>
/// 异步通信的头说明以字母H开头后面跟I,G,K,L,M
/// </summary>
public class MultiNetHeadCode
{
public static string 线 { get; } = "H001";
public static string { get; } = "H002";
public static string { get; } = "H003";
}
//可以在下面进行扩展,需要保证长度都是统一的
}
}

22
CommonLibrary/Resource.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommonLibrary
{
/// <summary>
/// 所有的数据资源中心
/// </summary>
public class Resource
{
/// <summary>
/// 字符串资源中心
/// </summary>
public class StringResouce
{
public static string SoftName { get; } = "你的软件系统";
public static string SoftCopyRight { get; } = "版权归属人";
}
}
}

View File

@@ -246,11 +246,128 @@
存储数据到文件
</summary>
</member>
<member name="T:BasicFramework.SoftMail">
<summary>
软件的邮箱类用于发送邮箱数据连续发送10次失败则禁止发送
</summary>
</member>
<member name="P:BasicFramework.SoftMail.SoftMailSendFailedCount">
<summary>
系统连续发送失败的次数,为了不影响系统,连续三次失败就禁止发送
</summary>
</member>
<member name="F:BasicFramework.SoftMail.MailSystem163">
<summary>
系统提供一个默认的163邮箱发送账号只要更改接收地址即可发送服务可能会被拦截
</summary>
</member>
<member name="F:BasicFramework.SoftMail.MailSystemQQ">
<summary>
系统提供一个默认的QQ邮箱发送账号只要更改接收地址即可发送服务发送成功概率比较高
</summary>
</member>
<member name="M:BasicFramework.SoftMail.#ctor(System.Action{System.Net.Mail.SmtpClient},System.String,System.String)">
<summary>
实例化一个邮箱发送类,需要指定初始化信息
</summary>
<param name="mailIni">初始化的方法</param>
<param name="addr_From">发送地址,应该和账户匹配</param>
<param name="addr_to">邮件接收地址</param>
</member>
<member name="P:BasicFramework.SoftMail.smtpClient">
<summary>
系统的邮件发送客户端
</summary>
</member>
<member name="P:BasicFramework.SoftMail.MailFromAddress">
<summary>
发送邮件的地址
</summary>
</member>
<member name="P:BasicFramework.SoftMail.MailSendAddress">
<summary>
邮件发送的地址
</summary>
</member>
<member name="M:BasicFramework.SoftMail.SendMail(System.Exception)">
<summary>
发生BUG至邮件地址需要提前指定发送地址否则失败
</summary>
<param name="ex">异常的BUG同样试用兼容类型</param>
<returns>是否发送成功,内容不正确会被视为垃圾邮件</returns>
</member>
<member name="M:BasicFramework.SoftMail.SendMail(System.String,System.String)">
<summary>
发送邮件至地址,需要提前指定发送地址,否则失败
</summary>
<param name="subject">邮件主题</param>
<param name="body">邮件内容</param>
<returns>是否发送成功,内容不正确会被视为垃圾邮件</returns>
</member>
<member name="M:BasicFramework.SoftMail.SendMail(System.Exception,System.String)">
<summary>
发生BUG至邮件地址需要提前指定发送地址否则失败
</summary>
<param name="ex">异常的BUG同样试用兼容类型</param>
<param name="addtion">额外信息</param>
<returns>是否发送成功,内容不正确会被视为垃圾邮件</returns>
</member>
<member name="M:BasicFramework.SoftMail.SendMail(System.String,System.String,System.String)">
<summary>
发送邮件的方法默认发送别名优先级是否HTML
</summary>
<param name="addr_to">接收地址</param>
<param name="subject">邮件主题</param>
<param name="body">邮件内容</param>
<returns>是否发送成功,内容不正确会被视为垃圾邮件</returns>
</member>
<member name="M:BasicFramework.SoftMail.SendMail(System.String,System.String,System.String[],System.String,System.String,System.Net.Mail.MailPriority,System.Boolean)">
<summary>
发送邮件的方法,需要提供完整的参数信息
</summary>
<param name="addr_from">发送地址</param>
<param name="name">发送别名</param>
<param name="addr_to">接收地址</param>
<param name="subject">邮件主题</param>
<param name="body">邮件内容</param>
<param name="priority">优先级</param>
<param name="isHtml">邮件内容是否是HTML语言</param>
<returns>发生是否成功,内容不正确会被视为垃圾邮件</returns>
</member>
<member name="T:BasicFramework.SoftPaint">
<summary>
静态类,包含了几个常用的画图方法,获取字符串,绘制小三角等
</summary>
</member>
<member name="T:BasicFramework.SoftSqlOperate">
<summary>
数据库操作的相关类,包含了常用的方法,避免大量的重复代码
</summary>
</member>
<member name="M:BasicFramework.SoftSqlOperate.ExecuteSql(System.String,System.String)">
<summary>
普通的执行SQL语句并返回影响行数该方法应该放到try-catch代码块中
</summary>
<param name="conStr">数据库的连接字符串</param>
<param name="cmdStr">sql语句适合插入更新删除</param>
<returns>返回受影响的行数</returns>
</member>
<member name="M:BasicFramework.SoftSqlOperate.ExecuteSelectTable(System.String,System.String)">
<summary>
选择数据表的执行SQL语句并返回影响行数该方法应该放到try-catch代码块中
</summary>
<param name="conStr">数据库的连接字符串</param>
<param name="cmdStr">sql语句适合插入更新删除</param>
<returns>结果数据表</returns>
</member>
<member name="M:BasicFramework.SoftSqlOperate.ExecuteSelectEnumerable``1(System.String,System.String)">
<summary>
选择指定类型数据集合执行SQL语句并返回影响行数该方法应该放到try-catch代码块中
</summary>
<param name="conStr">数据库的连接字符串</param>
<param name="cmdStr">sql语句适合插入更新删除</param>
<returns>结果数据集合</returns>
</member>
<member name="T:BasicFramework.ISqlDataType">
<summary>
数据库对应类的读取接口
@@ -262,6 +379,16 @@
</summary>
<param name="sdr"></param>
</member>
<member name="T:BasicFramework.SoftUserControls">
<summary>
一个用来管理多个用户控件显示的类
</summary>
</member>
<member name="P:BasicFramework.SoftUserControls.CurrentControl">
<summary>
当前的窗口
</summary>
</member>
<member name="T:BasicFramework.UserClock">
<summary>
一个时钟控件
@@ -682,6 +809,13 @@
</summary>
<param name="ex"></param>
</member>
<member name="M:BasicFramework.SoftBasic.GetExceptionMessage(System.Exception)">
<summary>
获取一个异常的完整错误信息
</summary>
<param name="ex"></param>
<returns></returns>
</member>
<member name="F:BasicFramework.SoftBasic.FrameworkVersion">
<summary>
本框架的版本号
@@ -830,6 +964,11 @@
用户客户端存储本地JSON数据的类包含了所有需要存储的信息
</summary>
</member>
<member name="M:BasicFramework.JsonSettings.#ctor">
<summary>
实例化一个设置的对象
</summary>
</member>
<member name="P:BasicFramework.JsonSettings.IsNewVersionRunning">
<summary>
指示系统是否是更新后第一次运行
@@ -850,14 +989,19 @@
参数文件的存储路径
</summary>
</member>
<member name="P:BasicFramework.JsonSettings.SystemInfo">
<summary>
当前计算机的机器码,用来判定参数是否是正确的
</summary>
</member>
<member name="M:BasicFramework.JsonSettings.LoadSettings">
<summary>
加载系统的设置信息,程序刚运行时就应该加载数据
使用默认的加密算法加载系统的设置信息,程序刚运行时就应该加载数据
</summary>
</member>
<member name="M:BasicFramework.JsonSettings.LoadSettings(System.Converter{System.String,System.String})">
<summary>
使用自定义的密规则加载系统的设置信息,程序刚运行时就应该加载数据
使用自定义的密规则加载系统的设置信息,程序刚运行时就应该加载数据
</summary>
</member>
<member name="M:BasicFramework.JsonSettings.SaveSettings">
@@ -925,6 +1069,11 @@
该用户上次登录的IP地址
</summary>
</member>
<member name="P:BasicFramework.UserAccount.LoginFailedCount">
<summary>
该用户连续登录失败的计数,可以用来连续五次失败禁止账户登录
</summary>
</member>
<member name="P:BasicFramework.UserAccount.UserNameText">
<summary>
用于存储的名称
@@ -935,11 +1084,24 @@
用于存储的名称
</summary>
</member>
<member name="M:BasicFramework.UserAccount.DeepCopy``1(``0)">
<member name="M:BasicFramework.UserAccount.DeepCopy``1">
<summary>
深度拷贝当前账户信息
深度拷贝当前账户信息
</summary>
<param name="account"></param>
<typeparam name="T">返回的类型,应该为继承后的类型</typeparam>
<returns>新的对象</returns>
</member>
<member name="M:BasicFramework.UserAccount.ToString">
<summary>
获取账号的用户名
</summary>
<returns></returns>
</member>
<member name="M:BasicFramework.UserAccount.ToJsonString">
<summary>
获取本账号的JSON字符串用于在网络中数据传输
</summary>
<returns></returns>
</member>
<member name="T:BasicFramework.AccountGrade">
<summary>
@@ -973,6 +1135,12 @@
<param name="grade">等级数据</param>
<returns>等级描述</returns>
</member>
<member name="M:BasicFramework.AccountGrade.GetDescription">
<summary>
获取权限的数组
</summary>
<returns></returns>
</member>
<member name="M:BasicFramework.AccountGrade.GetDescription(System.Converter{System.Int32,System.String},System.Int32)">
<summary>
获取对应等级的文本描述
@@ -1033,6 +1201,26 @@
<param name="ipAddress">登录的ip地址</param>
<returns>驗證結果對象</returns>
</member>
<member name="M:BasicFramework.ServerAccounts`1.AddNewAccount(System.String)">
<summary>
新增一个账户如果账户名称已经存在则返回False注册成功返回True
</summary>
<param name="json_account">账户对象的JSON表示方式</param>
<returns>成功True失败False</returns>
</member>
<member name="M:BasicFramework.ServerAccounts`1.AddNewAccount(`0)">
<summary>
新增一个账户如果账户名称已经存在则返回False注册成功返回True
</summary>
<param name="account">账户对象</param>
<returns>成功True失败False</returns>
</member>
<member name="M:BasicFramework.ServerAccounts`1.DeleteAccount(System.String)">
<summary>
删除一个账户信息,
</summary>
<param name="name"></param>
</member>
<member name="M:BasicFramework.ServerAccounts`1.CheckAccountJson(System.String,System.String,System.String)">
<summary>
檢查帳戶並返回帳戶對象的JSON字符串
@@ -1147,6 +1335,12 @@
<param name="encrypt">数据加密的方法,必须用户指定</param>
<returns>是否成功授权</returns>
</member>
<member name="M:BasicFramework.SoftAuthorize.GetInfo">
<summary>
获取本计算机唯一的机器码
</summary>
<returns></returns>
</member>
<member name="T:BasicFramework.MD5Code">
<summary>
字符串加密解密相关的自定义类

Binary file not shown.

View File

@@ -693,6 +693,12 @@
</summary>
<param name="str"></param>
</member>
<member name="M:IndustryEthernet.Net_Socket_Server.SendAllClients(System.Byte[])">
<summary>
服务端用于发送所有数据到所有的客户端
</summary>
<param name="data">需要群发客户端的字节数据</param>
</member>
<member name="F:IndustryEthernet.Net_Socket_Server.LogReacord">
<summary>
日志存储类,用来存储日志信息

Binary file not shown.

View File

@@ -35,10 +35,12 @@ namespace 软件系统客户端模版
{
label_status.Visible = false;
UserClient.JsonSettings.FileSavePath = Application.StartupPath + @"\settings.txt";
UserClient.JsonSettings.FileSavePath = Application.StartupPath + @"\JsonSettings.txt";
UserClient.JsonSettings.LoadSettings();//根据实际实际情况选中解密算法默认采用DES加密解密算法
label_version.Text = "版本:" + UserClient.CurrentVersion.ToString();
label2.Text = CommonLibrary.Resource.StringResouce.SoftName;
label_copyright.Text = $"本软件著作权归{CommonLibrary.Resource.StringResouce.SoftCopyRight}所有";
}
private void FormLogin_Shown(object sender, EventArgs e)

View File

@@ -65,6 +65,7 @@
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label_Announcement = new System.Windows.Forms.Label();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
@@ -143,7 +144,8 @@
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "管理员ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(84, 31);
this.ToolStripMenuItem.Text = "管理员";
@@ -285,6 +287,7 @@
this.listBox1.ItemHeight = 17;
this.listBox1.Location = new System.Drawing.Point(11, 166);
this.listBox1.Name = "listBox1";
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.listBox1.Size = new System.Drawing.Size(200, 225);
this.listBox1.TabIndex = 12;
//
@@ -409,6 +412,13 @@
this.label_Announcement.Text = "[公告]";
this.label_Announcement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 注册账号ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "注册账号ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "注册账号";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// FormMainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -476,6 +486,7 @@
private System.Windows.Forms.Label label_Announcement;
private System.Windows.Forms.Label label_factory;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@@ -83,7 +83,7 @@ namespace 软件系统客户端模版
{
UserClient.JsonSettings.IsNewVersionRunning = false;
UserClient.JsonSettings.SaveSettings();
ToolStripMenuItem_Click(null, new EventArgs());
ToolStripMenuItem_Click(null, new EventArgs());
}
//根据权限使能菜单
@@ -127,7 +127,8 @@ namespace 软件系统客户端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAbout fa = new FormAbout("软件系统", UserClient.CurrentVersion, 2017, "张三");
FormAbout fa = new FormAbout(Resource.StringResouce.SoftName,
UserClient.CurrentVersion, 2017, Resource.StringResouce.SoftCopyRight);
fa.ShowDialog();
fa.Dispose();
}
@@ -167,6 +168,14 @@ namespace 软件系统客户端模版
flg.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
using (FormRegisterAccount fra = new FormRegisterAccount(net_simplify_client))
{
fra.ShowDialog();
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAccountManage fam = new FormAccountManage(() =>
@@ -249,6 +258,10 @@ namespace 软件系统客户端模版
private void Net_socket_client_AcceptByte(HuTcpState object1, byte[] object2)
{
//接收到服务器发来的字节数据
if (IsHandleCreated) Invoke(new Action(() =>
{
MessageBox.Show(BitConverter.ToInt32(object2, 0).ToString());
}));
}
private void Net_socket_client_LoginSuccess()
@@ -285,8 +298,7 @@ namespace 软件系统客户端模版
#region
//=========================================================================================
//
// 在本界面任意地方调用net_simplify_client.ReadFromServer("[指令头]")即可获取服务器数据
@@ -300,8 +312,8 @@ namespace 软件系统客户端模版
private Net_Simplify_Client net_simplify_client = new Net_Simplify_Client(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(UserClient.ServerIp),
CommonLibrary.CommonLibrary.Port_Second_Net));
#endregion
}
}

View File

@@ -0,0 +1,208 @@
namespace
{
partial class FormRegisterAccount
{
/// <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.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
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.comboBox1 = new System.Windows.Forms.ComboBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(21, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(98, 15);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(232, 23);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(98, 51);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(232, 23);
this.textBox2.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(21, 54);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 17);
this.label2.TabIndex = 2;
this.label2.Text = "密码:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(98, 87);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(232, 23);
this.textBox3.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(21, 90);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17);
this.label3.TabIndex = 4;
this.label3.Text = "工厂:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(21, 125);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 17);
this.label4.TabIndex = 6;
this.label4.Text = "权限:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(21, 161);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(68, 17);
this.label5.TabIndex = 8;
this.label5.Text = "能否登录:";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(98, 192);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(232, 23);
this.textBox4.TabIndex = 11;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(21, 195);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(68, 17);
this.label6.TabIndex = 10;
this.label6.Text = "禁止原因:";
//
// userButton_login
//
this.userButton_login.BackColor = System.Drawing.Color.Transparent;
this.userButton_login.CustomerInformation = "";
this.userButton_login.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton_login.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton_login.Location = new System.Drawing.Point(149, 279);
this.userButton_login.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.userButton_login.Name = "userButton_login";
this.userButton_login.Size = new System.Drawing.Size(97, 31);
this.userButton_login.TabIndex = 12;
this.userButton_login.UIText = "注册";
this.userButton_login.Click += new System.EventHandler(this.userButton_login_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(98, 122);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(232, 25);
this.comboBox1.TabIndex = 13;
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(98, 157);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(232, 25);
this.comboBox2.TabIndex = 14;
//
// FormRegisterAccount
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(382, 342);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.userButton_login);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label3);
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.Name = "FormRegisterAccount";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "注册新账户";
this.Load += new System.EventHandler(this.FormRegisterAccount_Load);
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 System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label6;
private BasicFramework.UserButton userButton_login;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox comboBox2;
}
}

View File

@@ -0,0 +1,62 @@
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;
using IndustryEthernet;
namespace
{
public partial class FormRegisterAccount : Form
{
public FormRegisterAccount(Net_Simplify_Client client)
{
InitializeComponent();
net_client = client;
}
private void FormRegisterAccount_Load(object sender, EventArgs e)
{
comboBox1.DataSource = BasicFramework.AccountGrade.GetDescription();
comboBox2.DataSource = new string[] { "允许", "不允许" };
comboBox1.SelectedItem = BasicFramework.AccountGrade.GetDescription(BasicFramework.AccountGrade.Technology);
comboBox2.SelectedItem = "允许";
textBox4.Text = (new BasicFramework.UserAccount()).ForbidMessage;
}
private Net_Simplify_Client net_client = null;
private void userButton_login_Click(object sender, EventArgs e)
{
//点击了注册,先获取数据
BasicFramework.UserAccount account = new BasicFramework.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;
}
account.LoginEnable = comboBox2.SelectedItem.ToString() == "允许";
account.ForbidMessage = textBox4.Text;
OperateResultString result = net_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode. + account.ToJsonString());
if (result.IsSuccess && result.Content == "1")
{
MessageBox.Show("注册成功!");
}
else
{
MessageBox.Show("注册失败!");
}
}
}
}

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

@@ -76,6 +76,12 @@
<Compile Include="FormMainWindow.Designer.cs">
<DependentUpon>FormMainWindow.cs</DependentUpon>
</Compile>
<Compile Include="FormRegisterAccount.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormRegisterAccount.Designer.cs">
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserClient.cs" />
@@ -88,6 +94,9 @@
<EmbeddedResource Include="FormMainWindow.resx">
<DependentUpon>FormMainWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormRegisterAccount.resx">
<DependentUpon>FormRegisterAccount.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -108,6 +117,9 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="UserControls\" />
</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

@@ -42,6 +42,7 @@
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -52,7 +53,6 @@
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@@ -117,31 +117,38 @@
// 版本控制ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本控制ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.ToolStripMenuItem.Text = "版本控制";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 维护切换ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "维护切换ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.ToolStripMenuItem.Text = "维护切换";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 消息发送ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "消息发送ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.ToolStripMenuItem.Text = "消息发送";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 一键断开ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "一键断开ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.ToolStripMenuItem.Text = "一键断开";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -233,16 +240,10 @@
this.listBox1.ItemHeight = 17;
this.listBox1.Location = new System.Drawing.Point(10, 60);
this.listBox1.Name = "listBox1";
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.listBox1.Size = new System.Drawing.Size(216, 344);
this.listBox1.TabIndex = 8;
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);

View File

@@ -130,12 +130,17 @@ namespace 软件系统服务端模版
fm.Dispose();
MaintenanceInitialization();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//测试发送字节数据
//net_socket_server.SendAllClients(BitConverter.GetBytes(12345678));
//将消息群发给所有的客户端,并使用消息弹窗的方式显示
FormInputAndAction fiaa = new FormInputAndAction(m =>{
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode. + m); return true;});
FormInputAndAction fiaa = new FormInputAndAction(m =>
{
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode. + m); return true;
});
fiaa.ShowDialog();
fiaa.Dispose();
}
@@ -149,10 +154,8 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormAbout fm = new BasicFramework.FormAbout(
"您的软件名称",
UserServer.ServerSettings.SystemVersion,
2017,
"某某某");
CommonLibrary.Resource.StringResouce.SoftName, UserServer.ServerSettings.SystemVersion,
2017, CommonLibrary.Resource.StringResouce.SoftCopyRight);
fm.ShowDialog();
fm.Dispose();
}
@@ -360,6 +363,11 @@ namespace 软件系统服务端模版
net_soft_update_Server.log_record.ClearLogText();
net_simplify_server.SendMessage(object1, "成功");
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
bool result = UserServer.ServerAccounts.AddNewAccount(object2.Substring(4));
net_simplify_server.SendMessage(object1, result ? "1" : "0");
}
else
{
net_simplify_server.SendMessage(object1, object2);
@@ -397,7 +405,8 @@ namespace 软件系统服务端模版
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作客户端异步发送的字符串都会到此处处理
string head_code = object2.Substring(0, 4);
byte[] result = Convert.FromBase64String(object2.Substring(4));
}
private void Net_socket_server_AcceptByte(HuTcpState object1, byte[] object2)
@@ -447,6 +456,6 @@ namespace 软件系统服务端模版
#endregion
private Log_Record log = new Log_Record();
}
}

View File

@@ -53,18 +53,12 @@ namespace 软件系统服务端模版
public class UserAccountEx : UserAccount
{
/// <summary>
/// 示例,扩展一个手机号的属性
/// 用户的年龄
/// </summary>
public string Phone { get; set; } = "";
public override void DeepCopy<T>(T account)
{
base.DeepCopy<T>(account);
UserAccountEx accountex = account as UserAccountEx;
if (accountex != null)
{
//所有新增的属性在此进行复制
accountex.Phone = Phone;
}
}
public int Age { get; set; } = 0;
/// <summary>
/// 用户的家庭住址
/// </summary>
public string HomeAddress { get; set; } = "";
}
}