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

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)
};