代码整理重构,修复个人文件下载失败的BUG,发布版本1.4.0

This commit is contained in:
dathlin
2017-09-19 10:37:17 +08:00
parent 379d38d0eb
commit de13c87afe
14 changed files with 129 additions and 139 deletions

View File

@@ -45,7 +45,7 @@ namespace ClientsLibrary
textBox_UserName.Text = UserClient.UserAccount.UserName; textBox_UserName.Text = UserClient.UserAccount.UserName;
// 加载头像 // 加载头像
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolLoadPortrait), null); ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolLoadLargePortrait), null);
// 加载文件列表 // 加载文件列表
DownloadUserFileNames(); DownloadUserFileNames();
@@ -93,17 +93,16 @@ namespace ClientsLibrary
} }
} }
} }
private void ThreadPoolLoadPortrait(object obj)
{
UserPortrait.LoadUserLargePortraint(LoadPortraitByFileName);
}
private void pictureBox_UserPortrait_Click(object sender, EventArgs e) private void pictureBox_UserPortrait_Click(object sender, EventArgs e)
{ {
UserPortrait.ChangePortrait(); UserPortrait.ChangePortrait();
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolLoadLargePortrait), null);
}
private void ThreadPoolLoadLargePortrait(object obj)
{
UserPortrait.LoadUserLargePortraint(LoadPortraitByFileName); UserPortrait.LoadUserLargePortraint(LoadPortraitByFileName);
} }
@@ -185,7 +184,7 @@ namespace ClientsLibrary
"Files", "Files",
"Personal", "Personal",
UserClient.UserAccount.UserName, UserClient.UserAccount.UserName,
folderBrowserDialog.SelectedPath + "\\" + treeNode.Text folderBrowserDialog.SelectedPath
); );
download.ShowDialog(); download.ShowDialog();
} }
@@ -197,7 +196,7 @@ namespace ClientsLibrary
{ {
// 删除选中文件 // 删除选中文件
TreeNode treeNode = treeView1.SelectedNode; TreeNode treeNode = treeView1.SelectedNode;
if (treeNode.Name != "file_root") if (treeNode.Name != "files_root")
{ {
using (FormPasswordCheck passwordCheck = new FormPasswordCheck(UserClient.UserAccount.Password)) using (FormPasswordCheck passwordCheck = new FormPasswordCheck(UserClient.UserAccount.Password))
{ {

View File

@@ -75,7 +75,7 @@ namespace ClientsLibrary
bitmap32.Dispose(); bitmap32.Dispose();
using (FormFileOperate ffo = new FormFileOperate( using (FormFileOperate ffo = new FormFileOperate(
UserClient.Net_File_Client, UserClient.Net_File_Client,
new string[] new string[]
{ {
path300, path300,
@@ -85,41 +85,59 @@ namespace ClientsLibrary
ffo.ShowDialog(); ffo.ShowDialog();
} }
// 上传文件MD5码 ThreadPool.QueueUserWorkItem(new WaitCallback(obj =>
string SmallPortraitMD5 = SoftBasic.CalculateFileMD5(path32);
string LargePortraitMD5 = SoftBasic.CalculateFileMD5(path300);
JObject json = new JObject
{ {
{ UserAccount.UserNameText, new JValue(UserClient.UserAccount.UserName) }, // 上传文件MD5码
{ UserAccount.SmallPortraitText, new JValue(SmallPortraitMD5) }, string SmallPortraitMD5 = ""; SoftBasic.CalculateFileMD5(path32);
{ UserAccount.LargePortraitText, new JValue(LargePortraitMD5) } string LargePortraitMD5 = ""; SoftBasic.CalculateFileMD5(path300);
};
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer( try
CommonHeadCode.SimplifyHeadCode.MD5,
json.ToString());
if(result.IsSuccess)
{
if (result.Content.Substring(0, 2) == "成功")
{ {
UserClient.UserAccount.SmallPortraitMD5 = SmallPortraitMD5; SmallPortraitMD5 = SoftBasic.CalculateFileMD5(path32);
UserClient.UserAccount.LargePortraitMD5 = LargePortraitMD5; LargePortraitMD5 = SoftBasic.CalculateFileMD5(path300);
// 成功上传MD5码 }
LoadUserSmallPortraint(); catch(Exception ex)
{
UserClient.LogNet.WriteException("获取文件MD5码失败", ex);
MessageBox.Show("文件信息确认失败,请重新上传!");
return;
}
JObject json = new JObject
{
{ UserAccount.UserNameText, new JValue(UserClient.UserAccount.UserName) },
{ UserAccount.SmallPortraitText, new JValue(SmallPortraitMD5) },
{ UserAccount.LargePortraitText, new JValue(LargePortraitMD5) }
};
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(
CommonHeadCode.SimplifyHeadCode.MD5,
json.ToString());
if (result.IsSuccess)
{
if (result.Content.Substring(0, 2) == "成功")
{
UserClient.UserAccount.SmallPortraitMD5 = SmallPortraitMD5;
UserClient.UserAccount.LargePortraitMD5 = LargePortraitMD5;
// 成功上传MD5码
LoadUserSmallPortraint();
}
else
{
MessageBox.Show("上传头像失败!原因:" + result.Content);
}
} }
else else
{ {
MessageBox.Show("上传头像失败!原因:" + result.Content); MessageBox.Show("上传头像失败!原因:" + result.Message);
} }
}
else }), null);
{
MessageBox.Show("上传头像失败!原因:" + result.Message);
}
} }
} }
} }

View File

@@ -6,6 +6,7 @@ using HslCommunication.Enthernet;
using HslCommunication.BasicFramework; using HslCommunication.BasicFramework;
using CommonLibrary; using CommonLibrary;
using System.Net; using System.Net;
using CommonLibrary;
namespace ClientsLibrary namespace ClientsLibrary
{ {
@@ -37,9 +38,10 @@ namespace ClientsLibrary
/// <summary> /// <summary>
/// 服务器的IP地址默认为127.0.0.1,可用于单机调试,云服务器端117.48.203.204 /// 服务器的IP地址默认为127.0.0.1,可用于单机调试,
/// 云服务器端117.48.203.204,注意,云端为最新版,客户端版本比较旧会调试失败
/// </summary> /// </summary>
public static string ServerIp { get; } = "117.48.203.204";//用于测试的云服务器地址 public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址
/// <summary> /// <summary>
@@ -88,9 +90,9 @@ namespace ClientsLibrary
/// </summary> /// </summary>
public static NetSimplifyClient Net_simplify_client { get; set; } = new NetSimplifyClient( public static NetSimplifyClient Net_simplify_client { get; set; } = new NetSimplifyClient(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp), new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
CommonLibrary.CommonLibrary.Port_Second_Net)) CommonLibrary.CommonProtocol.Port_Second_Net))
{ {
KeyToken = CommonHeadCode.KeyToken, KeyToken = CommonLibrary.CommonProtocol.KeyToken,
ConnectTimeout = 5000, ConnectTimeout = 5000,
}; };
@@ -99,9 +101,9 @@ namespace ClientsLibrary
/// </summary> /// </summary>
public static NetUdpClient Net_Udp_Client { get; set; } = new NetUdpClient( public static NetUdpClient Net_Udp_Client { get; set; } = new NetUdpClient(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp), new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
CommonLibrary.CommonLibrary.Port_Udp_Server)) CommonLibrary.CommonProtocol.Port_Udp_Server))
{ {
KeyToken = CommonHeadCode.KeyToken, KeyToken = CommonLibrary.CommonProtocol.KeyToken,
}; };
@@ -110,9 +112,9 @@ namespace ClientsLibrary
/// </summary> /// </summary>
public static AdvancedFileClient Net_File_Client { get; set; } = new AdvancedFileClient() public static AdvancedFileClient Net_File_Client { get; set; } = new AdvancedFileClient()
{ {
KeyToken = CommonHeadCode.KeyToken, KeyToken = CommonLibrary.CommonProtocol.KeyToken,
LogNet = LogNet, LogNet = LogNet,
ServerIpEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), CommonLibrary.CommonLibrary.Port_Advanced_File_Server) ServerIpEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), CommonLibrary.CommonProtocol.Port_Advanced_File_Server)
}; };
/// <summary> /// <summary>

View File

@@ -72,7 +72,7 @@ namespace CommonLibrary
{ {
all_list_accounts[i].SmallPortraitMD5 = smallPortraitMD5; all_list_accounts[i].SmallPortraitMD5 = smallPortraitMD5;
all_list_accounts[i].LargePortraitMD5 = largePortraitMD5; all_list_accounts[i].LargePortraitMD5 = largePortraitMD5;
ILogNet?.WriteInfo(Resource.StringResouce.AccountModifyPassword + name); ILogNet?.WriteInfo(Resource.StringResouce.AccountUploadPortrait + name);
break; break;
} }
} }

View File

@@ -274,14 +274,14 @@ namespace CommonLibrary
/// </summary> /// </summary>
public override void LoadByFile() public override void LoadByFile()
{ {
LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonLibrary.Security)); LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonProtocol.Security));
} }
/// <summary> /// <summary>
/// 使用指定的加密实现数据加密 /// 使用指定的加密实现数据加密
/// </summary> /// </summary>
public override void SaveToFile() public override void SaveToFile()
{ {
SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonLibrary.Security)); SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonProtocol.Security));
} }

View File

@@ -86,8 +86,8 @@
<DependentUpon>FormVersionControl.cs</DependentUpon> <DependentUpon>FormVersionControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BasicSupport\SoftSettings.cs" /> <Compile Include="BasicSupport\SoftSettings.cs" />
<Compile Include="Common.cs" /> <Compile Include="ProtocolSupport\Common.cs" />
<Compile Include="HeadCode.cs" /> <Compile Include="ProtocolSupport\HeadCode.cs" />
<Compile Include="OrderSupport\ClassGoods.cs" /> <Compile Include="OrderSupport\ClassGoods.cs" />
<Compile Include="OrderSupport\ClassOrder.cs" /> <Compile Include="OrderSupport\ClassOrder.cs" />
<Compile Include="PortraitSupport\PortraitSupport.cs" /> <Compile Include="PortraitSupport\PortraitSupport.cs" />

View File

@@ -6,9 +6,21 @@ using HslCommunication.BasicFramework;
namespace CommonLibrary namespace CommonLibrary
{ {
public class CommonLibrary
/*****************************************************************************************
*
*
*
*
*
*****************************************************************************************/
public class CommonProtocol
{ {
static CommonLibrary() static CommonProtocol()
{ {
/************************************************************************** /**************************************************************************
* *
@@ -39,7 +51,7 @@ namespace CommonLibrary
/************************************************************************** /**************************************************************************
* *
* 2017914 22:06:27 1.4.0 * 2017919 22:06:27 1.4.0
* *
**************************************************************************/ **************************************************************************/
@@ -48,7 +60,20 @@ namespace CommonLibrary
} }
#region
/************************************************************************************************
*
* GUID码
*
**************************************************************************************************/
/// <summary>
/// 用于整个网络服务交互的身份令牌,可有效的防止来自网络的攻击,重新生成令牌后就无法更改,否则不支持自动升级
/// </summary>
public static Guid KeyToken { get; set; } = new Guid("1275BB9A-14B2-4A96-9673-B0AF0463D474");
//====================================================================================== //======================================================================================
// 此处的所有的网络端口应该重新指定,防止其他人的项目连接到你的程序上 // 此处的所有的网络端口应该重新指定,防止其他人的项目连接到你的程序上
@@ -82,71 +107,13 @@ namespace CommonLibrary
/// 文件管理的服务器端口 /// 文件管理的服务器端口
/// </summary> /// </summary>
public static int Port_Advanced_File_Server { get; } = 24672; public static int Port_Advanced_File_Server { get; } = 24672;
#endregion
/// <summary> /// <summary>
/// 整个系统的加密解密密码 /// 整个系统的加密解密密码
/// </summary> /// </summary>
public const string Security = "qwertyui"; public static string Security { get; } = "qwertyui";
} }
/// <summary>
/// 选项类,包含了所有的标识和文本的对应关系
/// </summary>
public class BasicOptions
{
/// <summary>
/// 测试,用于生成数据状态的信息存储
/// </summary>
public static readonly List<BasicOptions> test = new List<BasicOptions>()
{
new BasicOptions(0,"测试一"),
new BasicOptions(1,"测试二"),
new BasicOptions(2,"测试三"),
};
/// <summary>
/// 实例化一个对象
/// </summary>
public BasicOptions()
{
}
/// <summary>
/// 根据信息实例化一个选项对象
/// </summary>
/// <param name="code"></param>
/// <param name="des"></param>
public BasicOptions(int code, string des)
{
IntegerCode = code;
Description = des;
}
/// <summary>
/// 整数的代号
/// </summary>
public int IntegerCode { get; set; } = 0;
/// <summary>
/// 代号描述的文本
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// 过去描述
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Description;
}
}
} }

View File

@@ -398,10 +398,10 @@ namespace 软件系统客户端Wpf
{ {
try try
{ {
net_socket_client.KeyToken = CommonHeadCode.KeyToken;//新增的身份令牌 net_socket_client.KeyToken = CommonLibrary.CommonProtocol.KeyToken;//新增的身份令牌
net_socket_client.EndPointServer = new System.Net.IPEndPoint( net_socket_client.EndPointServer = new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp), System.Net.IPAddress.Parse(UserClient.ServerIp),
CommonLibrary.CommonLibrary.Port_Main_Net); CommonLibrary.CommonProtocol.Port_Main_Net);
net_socket_client.ClientAlias = $"{UserClient.UserAccount.UserName} ({UserClient.UserAccount.Factory})";//标记客户端在线的名称 net_socket_client.ClientAlias = $"{UserClient.UserAccount.UserName} ({UserClient.UserAccount.Factory})";//标记客户端在线的名称
net_socket_client.ClientStart(); net_socket_client.ClientStart();
} }
@@ -608,8 +608,9 @@ namespace 软件系统客户端Wpf
#endregion #endregion
#region Udp发送示例 #region Udp发送示例
/// <summary> /// <summary>
/// 调用该方法并指定参数即可,最长字符串不得 /// 调用该方法并指定参数即可,最长字符串不得超过服务器定义的数据
/// </summary> /// </summary>
/// <param name="data"></param> /// <param name="data"></param>
private void SendServerUdpData(int customer, string data) private void SendServerUdpData(int customer, string data)
@@ -760,6 +761,8 @@ namespace 软件系统客户端Wpf
#endregion #endregion
private void Button_BackMain_Click(object sender, RoutedEventArgs e) private void Button_BackMain_Click(object sender, RoutedEventArgs e)
{ {
//点击了主页 //点击了主页

View File

@@ -57,10 +57,10 @@ namespace 软件系统客户端Wpf.Views
} }
using (FormSimplyFileUpload upload = new FormSimplyFileUpload( using (FormSimplyFileUpload upload = new FormSimplyFileUpload(
CommonHeadCode.KeyToken, CommonLibrary.CommonProtocol.KeyToken,
UserClient.LogNet, UserClient.LogNet,
UserClient.ServerIp, UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File, CommonLibrary.CommonProtocol.Port_Share_File,
UserClient.UserAccount.UserName)) UserClient.UserAccount.UserName))
{ {
upload.ShowDialog(); upload.ShowDialog();

View File

@@ -32,9 +32,9 @@ namespace 软件系统客户端Wpf.Views
fileClient = new SimpleFileClient() fileClient = new SimpleFileClient()
{ {
KeyToken = CommonLibrary.CommonHeadCode.KeyToken, KeyToken = CommonLibrary.CommonProtocol.KeyToken,
LogNet = UserClient.LogNet, LogNet = UserClient.LogNet,
ServerIpEndPoint =new IPEndPoint(IPAddress.Parse(UserClient.ServerIp),CommonLibrary.CommonLibrary.Port_Advanced_File_Server) ServerIpEndPoint =new IPEndPoint(IPAddress.Parse(UserClient.ServerIp),CommonLibrary.CommonProtocol.Port_Advanced_File_Server)
}; };
} }

View File

@@ -337,10 +337,11 @@ namespace 软件系统客户端模版
{ {
try try
{ {
net_socket_client.KeyToken = CommonHeadCode.KeyToken;//新增的身份令牌 net_socket_client.KeyToken = CommonLibrary.CommonProtocol.KeyToken;// 新增的身份令牌
net_socket_client.LogNet = UserClient.LogNet;
net_socket_client.EndPointServer = new System.Net.IPEndPoint( net_socket_client.EndPointServer = new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp), System.Net.IPAddress.Parse(UserClient.ServerIp),
CommonLibrary.CommonLibrary.Port_Main_Net); CommonLibrary.CommonProtocol.Port_Main_Net);
net_socket_client.ClientAlias = $"{UserClient.UserAccount.UserName} ({UserClient.UserAccount.Factory})";//标记客户端在线的名称 net_socket_client.ClientAlias = $"{UserClient.UserAccount.UserName} ({UserClient.UserAccount.Factory})";//标记客户端在线的名称
net_socket_client.ClientStart(); net_socket_client.ClientStart();
} }

View File

@@ -34,10 +34,10 @@ namespace 软件系统客户端模版.UIControls
// 上传文件 // 上传文件
using (FormSimplyFileUpload upload = new FormSimplyFileUpload( using (FormSimplyFileUpload upload = new FormSimplyFileUpload(
CommonHeadCode.KeyToken, CommonLibrary.CommonProtocol.KeyToken,
UserClient.LogNet, UserClient.LogNet,
UserClient.ServerIp, UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File, CommonLibrary.CommonProtocol.Port_Share_File,
UserClient.UserAccount.UserName)) UserClient.UserAccount.UserName))
{ {
upload.ShowDialog(); upload.ShowDialog();
@@ -71,9 +71,9 @@ namespace 软件系统客户端模版.UIControls
foreach(var m in files) foreach(var m in files)
{ {
FileItemShow item = new FileItemShow( FileItemShow item = new FileItemShow(
CommonHeadCode.KeyToken, CommonLibrary.CommonProtocol.KeyToken,
UserClient.LogNet, UserClient.ServerIp, UserClient.LogNet, UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File, CommonLibrary.CommonProtocol.Port_Share_File,
() => () =>
{ {
if (m.UploadName != UserClient.UserAccount.UserName) if (m.UploadName != UserClient.UserAccount.UserName)

View File

@@ -344,9 +344,9 @@ namespace 软件系统服务端模版
net_soft_update_Server.LogNet = new LogNetSingle(LogSavePath + @"\update_log.txt"); net_soft_update_Server.LogNet = new LogNetSingle(LogSavePath + @"\update_log.txt");
//在服务器的这个路径下放置客户端运行的所有文件不要包含settings文件不要从此处运行 //在服务器的这个路径下放置客户端运行的所有文件不要包含settings文件不要从此处运行
//只放置exe和dll组件必须放置软件自动更新.exe //只放置exe和dll组件必须放置软件自动更新.exe
net_soft_update_Server.KeyToken = CommonHeadCode.KeyToken; net_soft_update_Server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;
net_soft_update_Server.FileUpdatePath = Application.StartupPath + @"\ClientFiles";//客户端文件路径 net_soft_update_Server.FileUpdatePath = Application.StartupPath + @"\ClientFiles";//客户端文件路径
net_soft_update_Server.ServerStart(CommonLibrary.CommonLibrary.Port_Update_Net); net_soft_update_Server.ServerStart(CommonLibrary.CommonProtocol.Port_Update_Net);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -384,8 +384,8 @@ namespace 软件系统服务端模版
net_file_Advanced.FilesDirectoryPath = Application.StartupPath; net_file_Advanced.FilesDirectoryPath = Application.StartupPath;
net_file_Advanced.FilesDirectoryPathTemp = Application.StartupPath + @"\Temp"; net_file_Advanced.FilesDirectoryPathTemp = Application.StartupPath + @"\Temp";
net_file_Advanced.LogNet = new LogNetSingle(LogSavePath + @"\Advanced_file_log.txt"); net_file_Advanced.LogNet = new LogNetSingle(LogSavePath + @"\Advanced_file_log.txt");
net_file_Advanced.KeyToken = CommonHeadCode.KeyToken; net_file_Advanced.KeyToken = CommonLibrary.CommonProtocol.KeyToken;
net_file_Advanced.ServerStart(CommonLibrary.CommonLibrary.Port_Advanced_File_Server); net_file_Advanced.ServerStart(CommonLibrary.CommonProtocol.Port_Advanced_File_Server);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -408,12 +408,12 @@ namespace 软件系统服务端模版
{ {
try try
{ {
net_simplify_server.KeyToken = CommonHeadCode.KeyToken;//设置身份令牌 net_simplify_server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;//设置身份令牌
net_simplify_server.LogNet = new LogNetSingle(LogSavePath + @"\simplify_log.txt");//日志路径 net_simplify_server.LogNet = new LogNetSingle(LogSavePath + @"\simplify_log.txt");//日志路径
net_simplify_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择 net_simplify_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择
net_simplify_server.ReceiveStringEvent += Net_simplify_server_ReceiveStringEvent;//接收到字符串触发 net_simplify_server.ReceiveStringEvent += Net_simplify_server_ReceiveStringEvent;//接收到字符串触发
net_simplify_server.ReceivedBytesEvent += Net_simplify_server_ReceivedBytesEvent;//接收到字节触发 net_simplify_server.ReceivedBytesEvent += Net_simplify_server_ReceivedBytesEvent;//接收到字节触发
net_simplify_server.ServerStart(CommonLibrary.CommonLibrary.Port_Second_Net); net_simplify_server.ServerStart(CommonLibrary.CommonProtocol.Port_Second_Net);
net_simplify_server.ConnectTimeout = 5200; net_simplify_server.ConnectTimeout = 5200;
} }
catch (Exception ex) catch (Exception ex)
@@ -815,7 +815,7 @@ namespace 软件系统服务端模版
{ {
try try
{ {
net_socket_server.KeyToken = CommonHeadCode.KeyToken;//设置身份令牌 net_socket_server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;//设置身份令牌
net_socket_server.LogNet =new LogNetSingle(LogSavePath + @"\net_log.txt"); net_socket_server.LogNet =new LogNetSingle(LogSavePath + @"\net_log.txt");
net_socket_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择 net_socket_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择
net_socket_server.FormatClientOnline = "#IP:{0} Name:{1}";//必须为#开头,具体格式可由自身需求确定 net_socket_server.FormatClientOnline = "#IP:{0} Name:{1}";//必须为#开头,具体格式可由自身需求确定
@@ -826,7 +826,7 @@ namespace 软件系统服务端模版
net_socket_server.MessageAlerts += new HslCommunication.NetBase.IEDelegate<string>(Net_socket_server_MessageAlerts);//服务器产生提示消息触发 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.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.AcceptString += new HslCommunication.NetBase.IEDelegate<AsyncStateOne, int, string>(Net_socket_server_AcceptString);//服务器接收到字符串数据触发
net_socket_server.ServerStart(CommonLibrary.CommonLibrary.Port_Main_Net); net_socket_server.ServerStart(CommonLibrary.CommonProtocol.Port_Main_Net);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1075,7 +1075,7 @@ namespace 软件系统服务端模版
//文件信息存储路径 //文件信息存储路径
FileListName = Application.StartupPath + @"\files.txt" FileListName = Application.StartupPath + @"\files.txt"
}; };
net_simple_file_server.KeyToken = CommonHeadCode.KeyToken; net_simple_file_server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;
net_simple_file_server.ReadFromFile(); net_simple_file_server.ReadFromFile();
net_simple_file_server.LogNet =new LogNetSingle(LogSavePath + @"\share_file_log.txt"); net_simple_file_server.LogNet =new LogNetSingle(LogSavePath + @"\share_file_log.txt");
net_simple_file_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择 net_simple_file_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择
@@ -1083,7 +1083,7 @@ namespace 软件系统服务端模版
net_simple_file_server.FilesDirectoryPath = Application.StartupPath + @"\Files"; net_simple_file_server.FilesDirectoryPath = Application.StartupPath + @"\Files";
net_simple_file_server.FilesDirectoryPathTemp = Application.StartupPath + @"\Temp"; net_simple_file_server.FilesDirectoryPathTemp = Application.StartupPath + @"\Temp";
net_simple_file_server.FileChange += Net_simple_file_server_FileChange; net_simple_file_server.FileChange += Net_simple_file_server_FileChange;
net_simple_file_server.ServerStart(CommonLibrary.CommonLibrary.Port_Share_File); net_simple_file_server.ServerStart(CommonLibrary.CommonProtocol.Port_Share_File);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1144,11 +1144,11 @@ namespace 软件系统服务端模版
net_udp_server = new NetUdpServer(); net_udp_server = new NetUdpServer();
net_udp_server.LogNet =new LogNetSingle(LogSavePath + @"\udp_log.txt");//日志路径 net_udp_server.LogNet =new LogNetSingle(LogSavePath + @"\udp_log.txt");//日志路径
net_udp_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择 net_udp_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);//默认debug及以上级别日志均进行存储根据需要自行选择
net_udp_server.KeyToken = CommonHeadCode.KeyToken; net_udp_server.KeyToken = CommonLibrary.CommonProtocol.KeyToken;
net_udp_server.ReceiveCacheLength = 1024;//单次接收数据的缓冲长度 net_udp_server.ReceiveCacheLength = 1024;//单次接收数据的缓冲长度
net_udp_server.AcceptByte += Net_udp_server_AcceptByte;//接收到字节数据的时候触发事件 net_udp_server.AcceptByte += Net_udp_server_AcceptByte;//接收到字节数据的时候触发事件
net_udp_server.AcceptString += Net_udp_server_AcceptString;//接收到字符串数据的时候触发事件 net_udp_server.AcceptString += Net_udp_server_AcceptString;//接收到字符串数据的时候触发事件
net_udp_server.ServerStart(CommonLibrary.CommonLibrary.Port_Udp_Server); net_udp_server.ServerStart(CommonLibrary.CommonProtocol.Port_Udp_Server);
} }
catch (Exception ex) catch (Exception ex)
{ {