网络组件代码重构,文件传输标准重写,完成winform适配。其他待完成

This commit is contained in:
dathlin
2017-09-13 21:08:18 +08:00
parent 38e7700c5b
commit 8e2e3c8562
9 changed files with 653 additions and 194 deletions

View File

@@ -36,7 +36,7 @@ namespace ClientsLibrary
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
using (FormFileOperate fUpload = new FormFileOperate(CommonHeadCode.KeyToken, new System.Net.IPEndPoint(
using (FormFileOperate fUpload = new FormFileOperate(CommonHeadCode.KeyToken,UserClient.LogNet, new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp), CommonLibrary.CommonLibrary.Port_Update_Remote),
ofd.FileNames, "", "", ""))
{

View File

@@ -105,6 +105,10 @@ namespace ClientsLibrary
KeyToken = CommonHeadCode.KeyToken,
};
/// <summary>
/// 客户端的日志纪录对象
/// </summary>
public static HslCommunication.LogNet.ILogNet LogNet { get; set; }
/// <summary>

View File

@@ -17,7 +17,7 @@ namespace ClientsLibrary
/// </summary>
public class UserPortrait
{
public UserPortrait(string filePath,Action<string> loadPic,Action disPic)
public UserPortrait(string filePath, Action<string> loadPic, Action disPic)
{
if (!System.IO.Directory.Exists(filePath))
{
@@ -52,7 +52,7 @@ namespace ClientsLibrary
bitmap300.Dispose();
bitmap32.Dispose();
using (FormFileOperate ffo = new FormFileOperate(CommonHeadCode.KeyToken, new System.Net.IPEndPoint(
using (FormFileOperate ffo = new FormFileOperate(CommonHeadCode.KeyToken,UserClient.LogNet, new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp), CommonLibrary.CommonLibrary.Port_Portrait_Server),
new string[]
{
@@ -127,7 +127,7 @@ namespace ClientsLibrary
public void ThreadPoolDownloadSizeLarge()
{
string path = FileSavePath;
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName, null, null);
if (result.IsSuccess)
{
if (result.Content[0] == 'Y')

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@ using HslCommunication;
using HslCommunication.Enthernet;
using HslCommunication.BasicFramework;
using ClientsLibrary;
using HslCommunication.LogNet;
/***************************************************************************************
@@ -46,6 +47,9 @@ namespace 软件系统客户端模版
public FormMainWindow()
{
InitializeComponent();
// 处理异常
UserClient.LogNet = new LogNetDateTime(Application.StartupPath + @"\Logs", GenerateMode.ByEveryDay);
}
#region
@@ -662,6 +666,5 @@ namespace 软件系统客户端模版
#endregion
}
}

View File

@@ -20,23 +20,23 @@ namespace 软件系统客户端模版
[STAThread]
static void Main()
{
//捕获未处理的异常
// 捕获未处理的异常
AppDomain.CurrentDomain.UnhandledException += ClientsLibrary.UserClient.CurrentDomain_UnhandledException;
//=====================================================================
//为了强制只启动一个应用程序的实例
// 为了强制只启动一个应用程序的实例
Process process = Process.GetCurrentProcess();
//遍历应用程序的同名进程组
// 遍历应用程序的同名进程组
foreach (Process p in Process.GetProcessesByName(process.ProcessName))
{
//不是同一进程则关闭刚刚创建的进程
// 不是同一进程则关闭刚刚创建的进程
if (p.Id != process.Id)
{
//此处显示原先的窗口需要一定的时间,不然无法显示
// 此处显示原先的窗口需要一定的时间,不然无法显示
ShowWindowAsync(p.MainWindowHandle, 9);
SetForegroundWindow(p.MainWindowHandle);
System.Threading.Thread.Sleep(10);
Application.Exit();//关闭当前的应用程序
Application.Exit();// 关闭当前的应用程序
return;
}
}
@@ -44,7 +44,7 @@ namespace 软件系统客户端模版
Application.SetCompatibleTextRenderingDefault(false);
//===================================================================
//运行主窗口之前先进行账户的验证
// 运行主窗口之前先进行账户的验证
P1:
FormLogin login = new FormLogin();
@@ -55,7 +55,7 @@ namespace 软件系统客户端模版
Application.Run(fmw);
if (QuitCode == 1)
{
//继续显示登录窗口
// 继续显示登录窗口
QuitCode = 0;
goto P1;
}

View File

@@ -33,6 +33,8 @@ namespace 软件系统客户端模版.UIControls
}
using (FormSimplyFileUpload upload = new FormSimplyFileUpload(
CommonHeadCode.KeyToken,
UserClient.LogNet,
UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File,
UserClient.UserAccount.UserName))
@@ -67,7 +69,9 @@ namespace 软件系统客户端模版.UIControls
//添加子控件
foreach(var m in files)
{
FileItemShow item = new FileItemShow(UserClient.ServerIp,
FileItemShow item = new FileItemShow(
CommonHeadCode.KeyToken,
UserClient.LogNet, UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File,
() =>
{

View File

@@ -17,7 +17,7 @@ using HslCommunication.LogNet;
/******************************************************************************************
*
* 模版日期 2017-09-02
* 模版日期 2017-09-13
* 创建人 Richard.Hu
* 版权所有 Richard.Hu
* 授权说明 模版仅授权个人使用如需商用请联系hsl200909@163.com洽谈
@@ -359,7 +359,7 @@ namespace 软件系统服务端模版
/// <summary>
/// 用于局域网异地更新服务器的客户端程序的引擎,仅限客户端
/// </summary>
private NetFileServer net_file_update = new NetFileServer();
private AdvancedFileServer net_file_update = new AdvancedFileServer();
/// <summary>
/// 软件异地更新的初始化,如不需要可以不启动,该功能支持发送客户端文件至服务器实现覆盖更新
/// </summary>
@@ -367,7 +367,8 @@ namespace 软件系统服务端模版
{
try
{
net_file_update.FilesPath = Application.StartupPath + @"\ClientFiles";//服务器客户端需要更新的路径,与上述一致
net_file_update.FilesDirectoryPath = Application.StartupPath + @"\ClientFiles";//服务器客户端需要更新的路径,与上述一致
net_file_update.FilesDirectoryPathTemp= Application.StartupPath + @"\Temp";
net_file_update.LogNet = new LogNetSingle(LogSavePath + @"\update_file_log.txt");
net_file_update.KeyToken = CommonHeadCode.KeyToken;
net_file_update.ServerStart(CommonLibrary.CommonLibrary.Port_Update_Remote);
@@ -1066,7 +1067,7 @@ namespace 软件系统服务端模版
/// <summary>
/// 共享文件服务器引擎
/// </summary>
private SimpleShareFileServer net_simple_file_server { get; set; } = null;
private SimpleFileServer net_simple_file_server { get; set; } = null;
/// <summary>
/// 共享文件服务引擎初始化
/// </summary>
@@ -1074,16 +1075,18 @@ namespace 软件系统服务端模版
{
try
{
net_simple_file_server = new SimpleShareFileServer()
net_simple_file_server = new SimpleFileServer()
{
//文件信息存储路径
FileSavePath = Application.StartupPath + @"\files.txt"
FileListName = Application.StartupPath + @"\files.txt"
};
net_simple_file_server.KeyToken = CommonHeadCode.KeyToken;
net_simple_file_server.ReadFromFile();
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.File_save_path = Application.StartupPath + @"\Files";
net_simple_file_server.FilesDirectoryPath = Application.StartupPath + @"\Files";
net_simple_file_server.FilesDirectoryPathTemp = Application.StartupPath + @"\Temp";
net_simple_file_server.FileChange += Net_simple_file_server_FileChange;
net_simple_file_server.ServerStart(CommonLibrary.CommonLibrary.Port_Share_File);
}
@@ -1359,7 +1362,7 @@ namespace 软件系统服务端模版
/// <summary>
/// 用于用户账户的头像文件保存
/// </summary>
private NetFileServer net_file_Portrait = new NetFileServer();
private AdvancedFileServer net_file_Portrait = new AdvancedFileServer();
/// <summary>
/// 用户头像管理服务的引擎
/// </summary>
@@ -1367,7 +1370,8 @@ namespace 软件系统服务端模版
{
try
{
net_file_Portrait.FilesPath = Application.StartupPath;
net_file_Portrait.FilesDirectoryPath = Application.StartupPath;
net_file_Portrait.FilesDirectoryPathTemp= Application.StartupPath + @"\Temp";
net_file_Portrait.LogNet =new LogNetSingle(LogSavePath + @"\Portrait_file_log.txt");
net_file_Portrait.KeyToken = CommonHeadCode.KeyToken;
net_file_Portrait.ServerStart(CommonLibrary.CommonLibrary.Port_Portrait_Server);