网络组件更新,用户暗号重新设计,个人信息界面文件上传支持拖拽

This commit is contained in:
dathlin
2017-09-19 22:16:44 +08:00
parent de13c87afe
commit cad8cd3de4
17 changed files with 335 additions and 131 deletions

View File

@@ -27,15 +27,23 @@ namespace ClientsLibrary
/// <summary>
/// 系统统一的登录模型
/// </summary>
/// <param name="message_show"></param>
/// <param name="start_update"></param>
/// <param name="thread_finish"></param>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="remember"></param>
/// <param name="clientType"></param>
/// <param name="message_show">信息提示方法</param>
/// <param name="start_update">启动更新方法</param>
/// <param name="thread_finish">线程结束后的复原方法</param>
/// <param name="userName">用户名</param>
/// <param name="password">密码</param>
/// <param name="remember">是否记住登录密码</param>
/// <param name="clientType">客户端登录类型</param>
/// <returns></returns>
public static bool AccountLoginServer(Action<string> message_show, Action start_update, Action thread_finish,string userName,string password,bool remember,string clientType)
public static bool AccountLoginServer(
Action<string> message_show,
Action start_update,
Action thread_finish,
string userName,
string password,
bool remember,
string clientType
)
{
message_show.Invoke("正在维护检查...");

View File

@@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("我的文件(下载中)");
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("我的文件(下载中)");
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pictureBox_UserPortrait = new System.Windows.Forms.PictureBox();
this.label12 = new System.Windows.Forms.Label();
@@ -55,10 +55,10 @@
this.textBox_UserName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.treeView1 = new System.Windows.Forms.TreeView();
this.userButton2 = new HslCommunication.Controls.UserButton();
this.userButton1 = new HslCommunication.Controls.UserButton();
this.userButton_upload = new HslCommunication.Controls.UserButton();
this.treeView1 = new System.Windows.Forms.TreeView();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox_UserPortrait)).BeginInit();
this.groupBox2.SuspendLayout();
@@ -331,21 +331,7 @@
this.groupBox2.Size = new System.Drawing.Size(373, 492);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "个人文件";
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.treeView1.Location = new System.Drawing.Point(10, 24);
this.treeView1.Name = "treeView1";
treeNode4.Name = "files_root";
treeNode4.Text = "我的文件(下载中)";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode4});
this.treeView1.ShowLines = false;
this.treeView1.Size = new System.Drawing.Size(353, 429);
this.treeView1.TabIndex = 0;
this.groupBox2.Text = "个人文件,支持拖拽";
//
// userButton2
//
@@ -392,7 +378,24 @@
this.userButton_upload.UIText = "上传";
this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click);
//
// AccountDetails
// treeView1
//
this.treeView1.AllowDrop = true;
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.treeView1.Location = new System.Drawing.Point(10, 24);
this.treeView1.Name = "treeView1";
treeNode1.Name = "files_root";
treeNode1.Text = "我的文件(下载中)";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode1});
this.treeView1.ShowLines = false;
this.treeView1.Size = new System.Drawing.Size(353, 429);
this.treeView1.TabIndex = 0;
this.treeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView1_DragDrop);
this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView1_DragEnter);
//
// FormAccountDetails
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -404,7 +407,7 @@
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(722, 555);
this.MinimumSize = new System.Drawing.Size(722, 555);
this.Name = "AccountDetails";
this.Name = "FormAccountDetails";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "AccountDetails";
this.Load += new System.EventHandler(this.AccountDetails_Load);

View File

@@ -11,6 +11,7 @@ using System.Threading;
using System.Windows.Forms;
using HslCommunication;
using HslCommunication.BasicFramework;
using System.IO;
namespace ClientsLibrary
{
@@ -154,17 +155,21 @@ namespace ClientsLibrary
openFileDialog.Multiselect = true;
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FormFileOperate upload = new FormFileOperate(UserClient.Net_File_Client,
openFileDialog.FileNames,
UploadFilesToServer(openFileDialog.FileNames);
}
}
}
private void UploadFilesToServer(string[] files)
{
FormFileOperate upload = new FormFileOperate(UserClient.Net_File_Client,
files,
"Files",
"Personal",
UserClient.UserAccount.UserName);
upload.ShowDialog();
// 更新文件列表
DownloadUserFileNames();
}
}
upload.ShowDialog();
// 更新文件列表
DownloadUserFileNames();
}
private void userButton1_Click(object sender, EventArgs e)
@@ -223,8 +228,65 @@ namespace ClientsLibrary
#endregion
private void treeView1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] paths = e.Data.GetData(DataFormats.FileDrop) as string[];
if (paths != null)
{
List<string> files = new List<string>();
try
{
foreach (var m in paths)
{
FileInfo finfo = new FileInfo(m);
if (finfo.Attributes == FileAttributes.Directory)
{
foreach (var n in Directory.GetFiles(m))
{
files.Add(n);
}
}
else
{
files.Add(m);
}
}
}
catch(Exception ex)
{
UserClient.LogNet?.WriteException("拖拽文件上传异常:", ex);
SoftBasic.ShowExceptionMessage(ex);
return;
}
if (files.Count > 0)
{
Invoke(new Action(() =>
{
UploadFilesToServer(files.ToArray());
}));
}
}
}
}
private void treeView1_DragEnter(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}

View File

@@ -29,26 +29,26 @@ namespace ClientsLibrary
/// 客户端需要进行本地存储的信息日志
/// </summary>
public static JsonSettings JsonSettings = new JsonSettings();
/// <summary>
/// 本软件的当前版本,用来验证更新的关键依据
/// </summary>
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0.170914");
/// <summary>
/// 服务器的IP地址默认为127.0.0.1,可用于单机调试,
/// 云服务器端117.48.203.204,注意,云端为最新版,客户端版本比较旧会调试失败
/// </summary>
public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址
public static string ServerIp { get; } = "117.48.203.204";//用于测试的云服务器地址
/// <summary>
/// 系统的分厂信息
/// </summary>
public static List<string> SystemFactories { get; set; } = new List<string>();
@@ -68,7 +68,7 @@ namespace ClientsLibrary
"3.需要用户自行添加"),
},
};
/// <summary>
/// 设置或获取系统的公告
@@ -89,10 +89,9 @@ namespace ClientsLibrary
/// 用于访问服务器数据的网络对象类,必须修改这个端口参数,否则运行失败
/// </summary>
public static NetSimplifyClient Net_simplify_client { get; set; } = new NetSimplifyClient(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
CommonLibrary.CommonProtocol.Port_Second_Net))
new IPEndPoint(IPAddress.Parse(ServerIp), CommonProtocol.Port_Second_Net))
{
KeyToken = CommonLibrary.CommonProtocol.KeyToken,
KeyToken = CommonProtocol.KeyToken,
ConnectTimeout = 5000,
};
@@ -100,10 +99,9 @@ namespace ClientsLibrary
/// 用于使用udp向服务器进行发送即时可丢失数据的对象
/// </summary>
public static NetUdpClient Net_Udp_Client { get; set; } = new NetUdpClient(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
CommonLibrary.CommonProtocol.Port_Udp_Server))
new IPEndPoint(IPAddress.Parse(ServerIp), CommonProtocol.Port_Udp_Server))
{
KeyToken = CommonLibrary.CommonProtocol.KeyToken,
KeyToken = CommonProtocol.KeyToken,
};
@@ -112,7 +110,7 @@ namespace ClientsLibrary
/// </summary>
public static AdvancedFileClient Net_File_Client { get; set; } = new AdvancedFileClient()
{
KeyToken = CommonLibrary.CommonProtocol.KeyToken,
KeyToken = CommonProtocol.KeyToken,
LogNet = LogNet,
ServerIpEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), CommonLibrary.CommonProtocol.Port_Advanced_File_Server)
};

View File

@@ -49,7 +49,7 @@ namespace CommonLibrary
if (name == all_list_accounts[i].UserName)
{
all_list_accounts[i].Password = password;
ILogNet?.WriteInfo(Resource.StringResouce.AccountModifyPassword + name);
ILogNet?.WriteInfo(SoftResources.StringResouce.AccountModifyPassword + name);
break;
}
}
@@ -72,7 +72,7 @@ namespace CommonLibrary
{
all_list_accounts[i].SmallPortraitMD5 = smallPortraitMD5;
all_list_accounts[i].LargePortraitMD5 = largePortraitMD5;
ILogNet?.WriteInfo(Resource.StringResouce.AccountUploadPortrait + name);
ILogNet?.WriteInfo(SoftResources.StringResouce.AccountUploadPortrait + name);
break;
}
}
@@ -176,7 +176,7 @@ namespace CommonLibrary
}
}
all_list_accounts.Add(account);
ILogNet?.WriteInfo(Resource.StringResouce.AccountAddSuccess + account.UserName);
ILogNet?.WriteInfo(SoftResources.StringResouce.AccountAddSuccess + account.UserName);
hybirdLock.Leave();
return result;
@@ -194,7 +194,7 @@ namespace CommonLibrary
if (name == all_list_accounts[i].UserName)
{
all_list_accounts.RemoveAt(i);
ILogNet?.WriteInfo(Resource.StringResouce.AccountDeleteSuccess + name);
ILogNet?.WriteInfo(SoftResources.StringResouce.AccountDeleteSuccess + name);
break;
}
}
@@ -241,7 +241,7 @@ namespace CommonLibrary
}
catch (Exception ex)
{
ILogNet?.WriteException(Resource.StringResouce.AccountLoadFailed, ex);
ILogNet?.WriteException(SoftResources.StringResouce.AccountLoadFailed, ex);
}
hybirdLock.Leave();
}

View File

@@ -228,7 +228,10 @@ namespace CommonLibrary
/// 指示系统的主题色是否是深色目前只适合于wpf
/// </summary>
public bool IsThemeDark { get; set; } = false;
/// <summary>
/// 本地保存的密码过期天数
/// </summary>
public int PasswordOverdueDays { get; set; } = 7;
/// <summary>
/// 当前计算机的机器码,用来判定参数是否是正确的
@@ -251,6 +254,7 @@ namespace CommonLibrary
json.Add(nameof(SystemInfo), new JValue(SystemInfo));
json.Add(nameof(LoginTime), new JValue(LoginTime));
json.Add(nameof(IsThemeDark), new JValue(IsThemeDark));
json.Add(nameof(PasswordOverdueDays), new JValue(PasswordOverdueDays));
return json.ToString();
}
@@ -258,14 +262,17 @@ namespace CommonLibrary
{
JObject json = JObject.Parse(content);
string systemInfo = SoftBasic.GetValueFromJsonObject(json, nameof(SystemInfo), "");
// 用户名不会因此更改
LoginName = SoftBasic.GetValueFromJsonObject(json, nameof(LoginName), LoginName);
if (systemInfo == SystemInfo)
{
//确认账户名及密码是本机的记录,而不是从其他电脑端拷贝过来的
LoginName = SoftBasic.GetValueFromJsonObject(json, nameof(LoginName), LoginName);
IsNewVersionRunning = SoftBasic.GetValueFromJsonObject(json, nameof(IsNewVersionRunning), IsNewVersionRunning);
Password = SoftBasic.GetValueFromJsonObject(json, nameof(Password), Password);
LoginTime = SoftBasic.GetValueFromJsonObject(json, nameof(LoginTime), LoginTime);
IsThemeDark = SoftBasic.GetValueFromJsonObject(json, nameof(IsThemeDark), IsThemeDark);
PasswordOverdueDays = SoftBasic.GetValueFromJsonObject(json, nameof(PasswordOverdueDays), PasswordOverdueDays);
}
}

View File

@@ -92,7 +92,7 @@
<Compile Include="OrderSupport\ClassOrder.cs" />
<Compile Include="PortraitSupport\PortraitSupport.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resource.cs" />
<Compile Include="ProtocolSupport\Resource.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AccountSupport\FormAccountManage.resx">

View File

@@ -55,7 +55,7 @@ namespace CommonLibrary
*
**************************************************************************/
SoftBasic.FrameworkVersion = new SystemVersion("1.4.0");
SoftBasic.FrameworkVersion = new SystemVersion("1.4.1");
}

View File

@@ -5,26 +5,23 @@ using System.Text;
namespace CommonLibrary
{
/*********************************************************************************************
*
* 说明用于同步网络和异步网络的各种消息头的区别初始想法使用长度为4的字符串区分
* 目前改为int数据区分以后需要代码重构
*
*********************************************************************************************/
/// <summary>
/// 用于网络通信的二级协议头说明
/// </summary>
public class CommonHeadCode
{
/************************************************************************************************
*
* 注意您在准备二次开发时应该重新生成一个自己的GUID码
*
**************************************************************************************************/
/// <summary>
/// 用于整个网络服务交互的身份令牌,可有效的防止来自网络的攻击,重新生成令牌后就无法更改,否则不支持自动升级
/// </summary>
public static Guid KeyToken { get; set; } = new Guid("1275BB9A-14B2-4A96-9673-B0AF0463D474");
/// <summary>
/// 同步通信的指令头说明以10000开头后面接2000030000
/// </summary>
@@ -61,8 +58,7 @@ namespace CommonLibrary
public static int { get; } = 10016;
public static int { get; } = 10017;
/// <summary>
/// 判断指令否是日志相关指令

View File

@@ -8,7 +8,7 @@ namespace CommonLibrary
/// <summary>
/// 所有的数据资源中心
/// </summary>
public class Resource
public class SoftResources
{
/// <summary>
/// 字符串资源中心

Binary file not shown.

View File

@@ -1392,6 +1392,143 @@
</summary>
<returns></returns>
</member>
<member name="T:HslCommunication.NetHandle">
<summary>
用于网络传递的信息头使用上等同于int
</summary>
</member>
<member name="M:HslCommunication.NetHandle.op_Implicit(System.Int32)~HslCommunication.NetHandle">
<summary>
赋值操作可以直接赋值int数据
</summary>
<param name="value"></param>
</member>
<member name="M:HslCommunication.NetHandle.op_Implicit(HslCommunication.NetHandle)~System.Int32">
<summary>
也可以赋值给int数据
</summary>
<param name="netHandle"></param>
</member>
<member name="M:HslCommunication.NetHandle.op_Equality(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
判断是否相等
</summary>
<param name="netHandle1">第一个数</param>
<param name="netHandle2">第二个数</param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.op_Inequality(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
判断是否不相等
</summary>
<param name="netHandle1"></param>
<param name="netHandle2"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.op_Addition(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
两个数值相加
</summary>
<param name="netHandle1"></param>
<param name="netHandle2"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.op_Subtraction(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
两个数值相减
</summary>
<param name="netHandle1"></param>
<param name="netHandle2"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.op_LessThan(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
判断是否小于另一个数值
</summary>
<param name="netHandle1"></param>
<param name="netHandle2"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.op_GreaterThan(HslCommunication.NetHandle,HslCommunication.NetHandle)">
<summary>
判断是否大于另一个数值
</summary>
<param name="netHandle1"></param>
<param name="netHandle2"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.#ctor(System.Int32)">
<summary>
初始化一个暗号对象
</summary>
</member>
<member name="M:HslCommunication.NetHandle.#ctor(System.Byte,System.Byte,System.UInt16)">
<summary>
根据三个值来初始化暗号对象
</summary>
<param name="major">主暗号</param>
<param name="minor">次暗号</param>
<param name="identifier">暗号编号</param>
</member>
<member name="F:HslCommunication.NetHandle.m_CodeValue">
<summary>
完整的暗号值
</summary>
</member>
<member name="F:HslCommunication.NetHandle.m_CodeMajor">
<summary>
主暗号分类0-255
</summary>
</member>
<member name="F:HslCommunication.NetHandle.m_CodeMinor">
<summary>
次要的暗号分类0-255
</summary>
</member>
<member name="F:HslCommunication.NetHandle.m_CodeIdentifier">
<summary>
暗号的编号分类0-65535
</summary>
</member>
<member name="P:HslCommunication.NetHandle.CodeValue">
<summary>
完整的暗号值
</summary>
</member>
<member name="P:HslCommunication.NetHandle.CodeMajor">
<summary>
主暗号分类0-255
</summary>
</member>
<member name="P:HslCommunication.NetHandle.CodeMinor">
<summary>
次要的暗号分类0-255
</summary>
</member>
<member name="P:HslCommunication.NetHandle.CodeIdentifier">
<summary>
暗号的编号分类0-65535
</summary>
</member>
<member name="M:HslCommunication.NetHandle.ToString">
<summary>
获取完整的暗号数据
</summary>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.Equals(System.Object)">
<summary>
判断两个实例是否相同
</summary>
<param name="obj"></param>
<returns></returns>
</member>
<member name="M:HslCommunication.NetHandle.GetHashCode">
<summary>
获取哈希值
</summary>
<returns></returns>
</member>
<member name="T:HslCommunication.HslCommunicationCode">
<summary>
用于本程序集访问通信的暗号说明
@@ -2414,7 +2551,7 @@
</summary>
<param name="obj"></param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexServer.Send(HslCommunication.Enthernet.AsyncStateOne,System.Int32,System.String)">
<member name="M:HslCommunication.Enthernet.NetComplexServer.Send(HslCommunication.Enthernet.AsyncStateOne,HslCommunication.NetHandle,System.String)">
<summary>
服务器端用于数据发送文本的方法
</summary>
@@ -2422,7 +2559,7 @@
<param name="customer">用户自定义的数据对象如不需要赋值为0</param>
<param name="str">发送的文本</param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexServer.Send(HslCommunication.Enthernet.AsyncStateOne,System.Int32,System.Byte[])">
<member name="M:HslCommunication.Enthernet.NetComplexServer.Send(HslCommunication.Enthernet.AsyncStateOne,HslCommunication.NetHandle,System.Byte[])">
<summary>
服务器端用于发送字节的方法
</summary>
@@ -2430,14 +2567,14 @@
<param name="customer">用户自定义的数据对象如不需要赋值为0</param>
<param name="bytes">实际发送的数据</param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexServer.SendAllClients(System.Int32,System.String)">
<member name="M:HslCommunication.Enthernet.NetComplexServer.SendAllClients(HslCommunication.NetHandle,System.String)">
<summary>
服务端用于发送所有数据到所有的客户端
</summary>
<param name="customer">用户自定义的命令头</param>
<param name="str">需要传送的实际的数据</param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexServer.SendAllClients(System.Int32,System.Byte[])">
<member name="M:HslCommunication.Enthernet.NetComplexServer.SendAllClients(HslCommunication.NetHandle,System.Byte[])">
<summary>
服务端用于发送所有数据到所有的客户端
</summary>
@@ -2545,14 +2682,14 @@
<param name="receive"></param>
<param name="ex"></param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexClient.Send(System.Int32,System.String)">
<member name="M:HslCommunication.Enthernet.NetComplexClient.Send(HslCommunication.NetHandle,System.String)">
<summary>
服务器端用于数据发送文本的方法
</summary>
<param name="customer">用户自定义的命令头</param>
<param name="str">发送的文本</param>
</member>
<member name="M:HslCommunication.Enthernet.NetComplexClient.Send(System.Int32,System.Byte[])">
<member name="M:HslCommunication.Enthernet.NetComplexClient.Send(HslCommunication.NetHandle,System.Byte[])">
<summary>
服务器端用于发送字节的方法
</summary>
@@ -2585,7 +2722,7 @@
</summary>
<param name="end_point">服务器的通信地址</param>
</member>
<member name="M:HslCommunication.Enthernet.NetSimplifyClient.ReadFromServer(System.Int32,System.String,System.Action{System.Int64,System.Int64},System.Action{System.Int64,System.Int64})">
<member name="M:HslCommunication.Enthernet.NetSimplifyClient.ReadFromServer(HslCommunication.NetHandle,System.String,System.Action{System.Int64,System.Int64},System.Action{System.Int64,System.Int64})">
<summary>
客户端向服务器进行请求,请求字符串数据
</summary>
@@ -2595,7 +2732,7 @@
<param name="receiveStatus">接收数据时的进度报告</param>
<returns></returns>
</member>
<member name="M:HslCommunication.Enthernet.NetSimplifyClient.ReadFromServer(System.Int32,System.Byte[],System.Action{System.Int64,System.Int64},System.Action{System.Int64,System.Int64})">
<member name="M:HslCommunication.Enthernet.NetSimplifyClient.ReadFromServer(HslCommunication.NetHandle,System.Byte[],System.Action{System.Int64,System.Int64},System.Action{System.Int64,System.Int64})">
<summary>
客户端向服务器进行请求,请求字节数据
</summary>
@@ -2776,7 +2913,7 @@
</summary>
<param name="endpoint"></param>
</member>
<member name="M:HslCommunication.Enthernet.NetUdpClient.SendMessage(System.Int32,System.Byte[])">
<member name="M:HslCommunication.Enthernet.NetUdpClient.SendMessage(HslCommunication.NetHandle,System.Byte[])">
<summary>
发送字节数据到服务器
</summary>
@@ -2786,7 +2923,7 @@
<exception cref="T:System.Net.Sockets.SocketException"></exception>
<exception cref="T:System.ObjectDisposedException"></exception>
</member>
<member name="M:HslCommunication.Enthernet.NetUdpClient.SendMessage(System.Int32,System.String)">
<member name="M:HslCommunication.Enthernet.NetUdpClient.SendMessage(HslCommunication.NetHandle,System.String)">
<summary>
发送字符串数据到服务器
</summary>

View File

@@ -46,19 +46,21 @@ namespace 软件系统客户端Wpf
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowToolTip.Opacity = 0;
TextBlockSoftName.Text = CommonLibrary.Resource.StringResouce.SoftName;
TextBlockSoftName.Text = SoftResources.StringResouce.SoftName;
TextBlockSoftVersion.Text = UserClient.CurrentVersion.ToString();
TextBlockSoftCopyright.Text = $"本软件著作权归{CommonLibrary.Resource.StringResouce.SoftCopyRight}所有";
TextBlockSoftCopyright.Text = $"本软件著作权归{CommonLibrary.SoftResources.StringResouce.SoftCopyRight}所有";
// 上次登录为7天以前则清除账户密码
if ((DateTime.Now - UserClient.JsonSettings.LoginTime).TotalDays < 7)
if ((DateTime.Now - UserClient.JsonSettings.LoginTime).TotalDays < UserClient.JsonSettings.PasswordOverdueDays)
{
//加载数据
NameTextBox.Text = UserClient.JsonSettings.LoginName ?? "";
PasswordBox.Password = UserClient.JsonSettings.Password ?? "";
Remember.IsChecked = UserClient.JsonSettings.Password != "";
}
//初始化输入焦点
if (UserClient.JsonSettings.Password != "") LoginButton.Focus();
else if (UserClient.JsonSettings.LoginName != "") PasswordBox.Focus();

View File

@@ -157,7 +157,7 @@ namespace 软件系统客户端Wpf
Account_address.Text = UserClient.UserAccount.LastLoginIpAddress;
//状态栏设置
TextBlock_CopyRight.Text = $"本软件著作权归{Resource.StringResouce.SoftCopyRight}所有";
TextBlock_CopyRight.Text = $"本软件著作权归{SoftResources.StringResouce.SoftCopyRight}所有";
//绑定事件仅执行一次不能放到show方法里
net_socket_client.MessageAlerts += Net_socket_client_MessageAlerts;
@@ -322,8 +322,8 @@ namespace 软件系统客户端Wpf
private void MenuItem关于本软件_Click(object sender, RoutedEventArgs e)
{
using (FormAbout fa = new FormAbout(Resource.StringResouce.SoftName,
UserClient.CurrentVersion, 2017, Resource.StringResouce.SoftCopyRight))
using (FormAbout fa = new FormAbout(SoftResources.StringResouce.SoftName,
UserClient.CurrentVersion, 2017, SoftResources.StringResouce.SoftCopyRight))
{
fa.ShowDialog();
}
@@ -416,7 +416,7 @@ namespace 软件系统客户端Wpf
/// <param name="state">网络连接对象</param>
/// <param name="customer">用户自定义的指令头,用来区分数据用途</param>
/// <param name="data">数据</param>
private void Net_socket_client_AcceptString(AsyncStateOne state, int customer, string data)
private void Net_socket_client_AcceptString(AsyncStateOne state, NetHandle customer, string data)
{
if (customer == CommonHeadCode.MultiNetHeadCode.)
{
@@ -482,7 +482,7 @@ namespace 软件系统客户端Wpf
}
}
private void Net_socket_client_AcceptByte(AsyncStateOne object1, int customer, byte[] object2)
private void Net_socket_client_AcceptByte(AsyncStateOne object1, NetHandle customer, byte[] object2)
{
//接收到服务器发来的字节数据
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
@@ -520,16 +520,7 @@ namespace 软件系统客户端Wpf
TextBlock_ClientStatus.Text = object1;
}));
}
#endregion

View File

@@ -42,8 +42,8 @@ namespace 软件系统客户端模版
UserClient.JsonSettings.LoadByFile();//根据实际实际情况选中解密算法默认采用DES加密解密算法
label_version.Text = "版本:" + UserClient.CurrentVersion.ToString();
label2.Text = CommonLibrary.Resource.StringResouce.SoftName;
label_copyright.Text = $"本软件著作权归{CommonLibrary.Resource.StringResouce.SoftCopyRight}所有";
label2.Text = CommonLibrary.SoftResources.StringResouce.SoftName;
label_copyright.Text = $"本软件著作权归{CommonLibrary.SoftResources.StringResouce.SoftCopyRight}所有";
}
private void FormLogin_Shown(object sender, EventArgs e)
@@ -51,7 +51,7 @@ namespace 软件系统客户端模版
IsWindowShow = true;
//如果七天未登录,账户密码清除
if ((DateTime.Now - UserClient.JsonSettings.LoginTime).TotalDays < 7)
if ((DateTime.Now - UserClient.JsonSettings.LoginTime).TotalDays < UserClient.JsonSettings.PasswordOverdueDays)
{
//加载数据
textBox_userName.Text = UserClient.JsonSettings.LoginName ?? "";
@@ -94,7 +94,6 @@ namespace 软件系统客户端模版
private void userButton_login_Click(object sender, EventArgs e)
{
label_status.Visible = true;
//验证输入
if (string.IsNullOrEmpty(textBox_userName.Text))

View File

@@ -72,7 +72,7 @@ namespace 软件系统客户端模版
//状态栏设置
toolStripStatusLabel_time.Alignment = ToolStripItemAlignment.Right;
statusStrip1.LayoutStyle = ToolStripLayoutStyle.StackWithOverflow;
toolStripStatusLabel1.Text = $"本软件著作权归{Resource.StringResouce.SoftCopyRight}所有";
toolStripStatusLabel1.Text = $"本软件著作权归{SoftResources.StringResouce.SoftCopyRight}所有";
//绑定事件仅执行一次不能放到show方法里
net_socket_client.MessageAlerts += Net_socket_client_MessageAlerts;
@@ -163,8 +163,8 @@ namespace 软件系统客户端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
using (FormAbout fa = new FormAbout(Resource.StringResouce.SoftName,
UserClient.CurrentVersion, 2017, Resource.StringResouce.SoftCopyRight))
using (FormAbout fa = new FormAbout(SoftResources.StringResouce.SoftName,
UserClient.CurrentVersion, 2017, SoftResources.StringResouce.SoftCopyRight))
{
fa.ShowDialog();
}
@@ -356,7 +356,7 @@ namespace 软件系统客户端模版
/// <param name="state">网络连接对象</param>
/// <param name="customer">用户自定义的指令头,用来区分数据用途</param>
/// <param name="data">数据</param>
private void Net_socket_client_AcceptString(AsyncStateOne state, int customer, string data)
private void Net_socket_client_AcceptString(AsyncStateOne state, NetHandle customer, string data)
{
if (customer == CommonHeadCode.MultiNetHeadCode.)
{
@@ -422,7 +422,7 @@ namespace 软件系统客户端模版
}
}
private void Net_socket_client_AcceptByte(AsyncStateOne object1, int customer, byte[] object2)
private void Net_socket_client_AcceptByte(AsyncStateOne object1, NetHandle customer, byte[] object2)
{
//接收到服务器发来的字节数据
if (IsHandleCreated) Invoke(new Action(() =>

View File

@@ -13,6 +13,7 @@ using Newtonsoft.Json.Linq;
using HslCommunication.BasicFramework;
using System.Diagnostics;
using HslCommunication.LogNet;
using HslCommunication;
/******************************************************************************************
@@ -109,8 +110,8 @@ namespace 软件系统服务端模版
//加载参数
UserServer.ServerSettings.LoadByFile();
toolStripStatusLabel_version.Text = UserServer.ServerSettings.SystemVersion.ToString();
toolStripStatusLabel1.Text = $"本软件著作权归{Resource.StringResouce.SoftCopyRight}所有";
label5.Text = Resource.StringResouce.SoftName;
toolStripStatusLabel1.Text = $"本软件著作权归{SoftResources.StringResouce.SoftCopyRight}所有";
label5.Text = SoftResources.StringResouce.SoftName;
//加载账户信息
UserServer.ServerAccounts.FileSavePath = Application.StartupPath + @"\accounts.txt";
UserServer.ServerAccounts.LoadByFile();
@@ -264,8 +265,8 @@ namespace 软件系统服务端模版
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
using (FormAbout fm = new FormAbout(
Resource.StringResouce.SoftName, UserServer.ServerSettings.SystemVersion,
2017, Resource.StringResouce.SoftCopyRight))
SoftResources.StringResouce.SoftName, UserServer.ServerSettings.SystemVersion,
2017, SoftResources.StringResouce.SoftCopyRight))
{
fm.ShowDialog();
}
@@ -427,7 +428,7 @@ namespace 软件系统服务端模版
/// <param name="state">网络状态</param>
/// <param name="customer">字节数据,根据实际情况选择是否使用</param>
/// <param name="data">来自客户端的字节数据</param>
private void Net_simplify_server_ReceivedBytesEvent(AsyncStateOne state, int customer, byte[] data)
private void Net_simplify_server_ReceivedBytesEvent(AsyncStateOne state, NetHandle customer, byte[] data)
{
if(customer==CommonHeadCode.SimplifyHeadCode.)
{
@@ -456,7 +457,7 @@ namespace 软件系统服务端模版
/// <param name="state">客户端的地址</param>
/// <param name="customer">用于自定义的指令头可不用转而使用data来区分</param>
/// <param name="data">接收到的服务器的数据</param>
private void Net_simplify_server_ReceiveStringEvent(AsyncStateOne state, int customer, string data)
private void Net_simplify_server_ReceiveStringEvent(AsyncStateOne state, NetHandle customer, string data)
{
//必须返回结果调用SendMessage(object1,[实际数据]);
if (CommonHeadCode.SimplifyHeadCode.IsCustomerGroupSystem(customer))
@@ -815,18 +816,18 @@ namespace 软件系统服务端模版
{
try
{
net_socket_server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;//设置身份令牌
net_socket_server.KeyToken = CommonProtocol.KeyToken;//设置身份令牌
net_socket_server.LogNet =new LogNetSingle(LogSavePath + @"\net_log.txt");
net_socket_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择
net_socket_server.FormatClientOnline = "#IP:{0} Name:{1}";//必须为#开头,具体格式可由自身需求确定
net_socket_server.IsSaveLogClientLineChange = true;//设置客户端上下线是否记录到日志
net_socket_server.ClientOnline += new HslCommunication.NetBase.IEDelegate<AsyncStateOne>(Net_socket_server_ClientOnline);//客户端上线触发
net_socket_server.ClientOffline += new HslCommunication.NetBase.IEDelegate<AsyncStateOne, string>(Net_socket_server_ClientOffline);//客户端下线触发,包括异常掉线
net_socket_server.AllClientsStatusChange += new HslCommunication.NetBase.IEDelegate<string>(Net_socket_server_AllClientsStatusChange);//客户端上下线变化时触发
net_socket_server.MessageAlerts += new HslCommunication.NetBase.IEDelegate<string>(Net_socket_server_MessageAlerts);//服务器产生提示消息触发
net_socket_server.AcceptByte += new HslCommunication.NetBase.IEDelegate<AsyncStateOne, int, byte[]>(Net_socket_server_AcceptByte);//服务器接收到字节数据触发
net_socket_server.AcceptString += new HslCommunication.NetBase.IEDelegate<AsyncStateOne, int, string>(Net_socket_server_AcceptString);//服务器接收到字符串数据触发
net_socket_server.ServerStart(CommonLibrary.CommonProtocol.Port_Main_Net);
net_socket_server.ClientOnline += new NetBase.IEDelegate<AsyncStateOne>(Net_socket_server_ClientOnline);//客户端上线触发
net_socket_server.ClientOffline += new NetBase.IEDelegate<AsyncStateOne, string>(Net_socket_server_ClientOffline);//客户端下线触发,包括异常掉线
net_socket_server.AllClientsStatusChange += new NetBase.IEDelegate<string>(Net_socket_server_AllClientsStatusChange);//客户端上下线变化时触发
net_socket_server.MessageAlerts += new NetBase.IEDelegate<string>(Net_socket_server_MessageAlerts);//服务器产生提示消息触发
net_socket_server.AcceptByte += new NetBase.IEDelegate<AsyncStateOne, NetHandle, byte[]>(Net_socket_server_AcceptByte);//服务器接收到字节数据触发
net_socket_server.AcceptString += new NetBase.IEDelegate<AsyncStateOne, NetHandle, string>(Net_socket_server_AcceptString);//服务器接收到字符串数据触发
net_socket_server.ServerStart(CommonProtocol.Port_Main_Net);
}
catch (Exception ex)
{
@@ -846,7 +847,7 @@ namespace 软件系统服务端模版
******************************************************************************************************************/
private void Net_socket_server_AcceptString(AsyncStateOne object1, int customer, string data)
private void Net_socket_server_AcceptString(AsyncStateOne object1, NetHandle customer, string data)
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作客户端异步发送的字符串都会到此处处理
if (CommonHeadCode.MultiNetHeadCode.IsCustomerGroupSystem(customer))
@@ -863,7 +864,7 @@ namespace 软件系统服务端模版
/// <param name="state">网络状态</param>
/// <param name="customer">用户自定义的指令头</param>
/// <param name="data">字符串数据</param>
private void DataProcessingWithStartH(AsyncStateOne state, int customer, string data)
private void DataProcessingWithStartH(AsyncStateOne state, NetHandle customer, string data)
{
if (customer == CommonHeadCode.MultiNetHeadCode.)
{
@@ -872,7 +873,7 @@ namespace 软件系统服务端模版
}
private void Net_socket_server_AcceptByte(AsyncStateOne state, int customer, byte[] data)
private void Net_socket_server_AcceptByte(AsyncStateOne state, NetHandle customer, byte[] data)
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作客户端异步发送的字节数组都会到此处处理
}
@@ -1156,7 +1157,7 @@ namespace 软件系统服务端模版
}
}
private void Net_udp_server_AcceptString(AsyncStateOne state, int customer, string data)
private void Net_udp_server_AcceptString(AsyncStateOne state, NetHandle customer, string data)
{
//此处为测试
Invoke(new Action(() =>
@@ -1165,7 +1166,7 @@ namespace 软件系统服务端模版
}));
}
private void Net_udp_server_AcceptByte(AsyncStateOne state, int customer, byte[] data)
private void Net_udp_server_AcceptByte(AsyncStateOne state, NetHandle customer, byte[] data)
{
//具体用法参考上面字符串方法
}