整理代码,更改头像部分移动到我的信息中,服务器适配

This commit is contained in:
dathlin
2017-09-18 17:35:59 +08:00
parent 78c04eadfb
commit 57f5eb83a6
21 changed files with 1050 additions and 486 deletions

View File

@@ -1,56 +0,0 @@
using CommonLibrary;
using HslCommunication.Enthernet;
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;
namespace ClientsLibrary.AccountSupport
{
public partial class AccountDetails : Form
{
public AccountDetails(AdvancedFileClient fileClient, UserPortrait userPortrait)
{
InitializeComponent();
FileClient = fileClient;
UserPortrait = userPortrait;
}
private void AccountDetails_Shown(object sender, EventArgs e)
{
// 加载各种数据
textBox_Factory.Text = UserClient.UserAccount.Factory;
textBox_GradeDescription.Text = AccountGrade.GetDescription(UserClient.UserAccount.Grade);
textBox_LastLoginIpAddress.Text = UserClient.UserAccount.LastLoginIpAddress;
textBox_LastLoginTime.Text = UserClient.UserAccount.LastLoginTime.ToString();
textBox_LastLoginWay.Text = UserClient.UserAccount.LastLoginWay;
textBox_LoginEnable.Text = UserClient.UserAccount.LoginEnable ? "允许" : "禁止";
textBox_LoginFailedCount.Text = UserClient.UserAccount.LoginFailedCount.ToString();
textBox_LoginFrequency.Text = UserClient.UserAccount.LoginFrequency.ToString();
textBox_NameAlias.Text = UserClient.UserAccount.NameAlias;
textBox_RegisterTime.Text = UserClient.UserAccount.RegisterTime.ToString();
textBox_UserName.Text = UserClient.UserAccount.UserName;
// 加载头像
}
private void AccountDetails_Load(object sender, EventArgs e)
{
Text = "账户详细信息";
}
public AdvancedFileClient FileClient { get; }
public UserPortrait UserPortrait { get; }
}
}

View File

@@ -1,6 +1,6 @@
namespace ClientsLibrary.AccountSupport
namespace ClientsLibrary
{
partial class AccountDetails
partial class FormAccountDetails
{
/// <summary>
/// Required designer variable.
@@ -28,39 +28,40 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("我的文件(下载中)");
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox_UserName = new System.Windows.Forms.TextBox();
this.textBox_NameAlias = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox_Factory = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox_GradeDescription = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox_RegisterTime = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox_LoginEnable = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox_LoginFrequency = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox_LastLoginTime = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.textBox_LastLoginIpAddress = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.textBox_LastLoginWay = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.pictureBox_UserPortrait = new System.Windows.Forms.PictureBox();
this.label12 = new System.Windows.Forms.Label();
this.textBox_LoginFailedCount = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.textBox_LastLoginWay = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.textBox_LastLoginIpAddress = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.textBox_LastLoginTime = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.textBox_LoginFrequency = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox_LoginEnable = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox_RegisterTime = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox_GradeDescription = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox_Factory = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox_NameAlias = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
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.userButton_upload = new HslCommunication.Controls.UserButton();
this.userButton1 = new HslCommunication.Controls.UserButton();
this.userButton2 = new HslCommunication.Controls.UserButton();
this.label12 = new System.Windows.Forms.Label();
this.pictureBox_UserPortrait = new System.Windows.Forms.PictureBox();
this.userButton1 = new HslCommunication.Controls.UserButton();
this.userButton_upload = new HslCommunication.Controls.UserButton();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox_UserPortrait)).BeginInit();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
@@ -98,167 +99,44 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "账户信息";
//
// label1
// pictureBox_UserPortrait
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 167);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
this.pictureBox_UserPortrait.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox_UserPortrait.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox_UserPortrait.Location = new System.Drawing.Point(112, 22);
this.pictureBox_UserPortrait.Name = "pictureBox_UserPortrait";
this.pictureBox_UserPortrait.Size = new System.Drawing.Size(136, 136);
this.pictureBox_UserPortrait.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox_UserPortrait.TabIndex = 23;
this.pictureBox_UserPortrait.TabStop = false;
this.pictureBox_UserPortrait.Click += new System.EventHandler(this.pictureBox_UserPortrait_Click);
//
// textBox_UserName
// label12
//
this.textBox_UserName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_UserName.Location = new System.Drawing.Point(112, 164);
this.textBox_UserName.Name = "textBox_UserName";
this.textBox_UserName.ReadOnly = true;
this.textBox_UserName.Size = new System.Drawing.Size(177, 23);
this.textBox_UserName.TabIndex = 1;
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(20, 24);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(44, 17);
this.label12.TabIndex = 22;
this.label12.Text = "头像:";
//
// textBox_NameAlias
// textBox_LoginFailedCount
//
this.textBox_NameAlias.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_NameAlias.Location = new System.Drawing.Point(112, 194);
this.textBox_NameAlias.Name = "textBox_NameAlias";
this.textBox_NameAlias.ReadOnly = true;
this.textBox_NameAlias.Size = new System.Drawing.Size(177, 23);
this.textBox_NameAlias.TabIndex = 3;
this.textBox_LoginFailedCount.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginFailedCount.Location = new System.Drawing.Point(112, 459);
this.textBox_LoginFailedCount.Name = "textBox_LoginFailedCount";
this.textBox_LoginFailedCount.ReadOnly = true;
this.textBox_LoginFailedCount.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginFailedCount.TabIndex = 21;
//
// label2
// label11
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 197);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 17);
this.label2.TabIndex = 2;
this.label2.Text = "别名";
//
// textBox_Factory
//
this.textBox_Factory.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_Factory.Location = new System.Drawing.Point(112, 223);
this.textBox_Factory.Name = "textBox_Factory";
this.textBox_Factory.ReadOnly = true;
this.textBox_Factory.Size = new System.Drawing.Size(177, 23);
this.textBox_Factory.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 226);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17);
this.label3.TabIndex = 4;
this.label3.Text = "工厂:";
//
// textBox_GradeDescription
//
this.textBox_GradeDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_GradeDescription.Location = new System.Drawing.Point(112, 251);
this.textBox_GradeDescription.Name = "textBox_GradeDescription";
this.textBox_GradeDescription.ReadOnly = true;
this.textBox_GradeDescription.Size = new System.Drawing.Size(177, 23);
this.textBox_GradeDescription.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 254);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 17);
this.label4.TabIndex = 6;
this.label4.Text = "权限:";
//
// textBox_RegisterTime
//
this.textBox_RegisterTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_RegisterTime.Location = new System.Drawing.Point(112, 279);
this.textBox_RegisterTime.Name = "textBox_RegisterTime";
this.textBox_RegisterTime.ReadOnly = true;
this.textBox_RegisterTime.Size = new System.Drawing.Size(177, 23);
this.textBox_RegisterTime.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 282);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(68, 17);
this.label5.TabIndex = 8;
this.label5.Text = "注册时间:";
//
// textBox_LoginEnable
//
this.textBox_LoginEnable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginEnable.Location = new System.Drawing.Point(112, 308);
this.textBox_LoginEnable.Name = "textBox_LoginEnable";
this.textBox_LoginEnable.ReadOnly = true;
this.textBox_LoginEnable.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginEnable.TabIndex = 11;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(20, 311);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(92, 17);
this.label6.TabIndex = 10;
this.label6.Text = "是否允许登录:";
//
// textBox_LoginFrequency
//
this.textBox_LoginFrequency.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginFrequency.Location = new System.Drawing.Point(112, 338);
this.textBox_LoginFrequency.Name = "textBox_LoginFrequency";
this.textBox_LoginFrequency.ReadOnly = true;
this.textBox_LoginFrequency.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginFrequency.TabIndex = 13;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(20, 341);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 17);
this.label7.TabIndex = 12;
this.label7.Text = "总登录次数:";
//
// textBox_LastLoginTime
//
this.textBox_LastLoginTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LastLoginTime.Location = new System.Drawing.Point(112, 368);
this.textBox_LastLoginTime.Name = "textBox_LastLoginTime";
this.textBox_LastLoginTime.ReadOnly = true;
this.textBox_LastLoginTime.Size = new System.Drawing.Size(177, 23);
this.textBox_LastLoginTime.TabIndex = 15;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 371);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(92, 17);
this.label8.TabIndex = 14;
this.label8.Text = "上次登录时间:";
//
// textBox_LastLoginIpAddress
//
this.textBox_LastLoginIpAddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LastLoginIpAddress.Location = new System.Drawing.Point(112, 398);
this.textBox_LastLoginIpAddress.Name = "textBox_LastLoginIpAddress";
this.textBox_LastLoginIpAddress.ReadOnly = true;
this.textBox_LastLoginIpAddress.Size = new System.Drawing.Size(177, 23);
this.textBox_LastLoginIpAddress.TabIndex = 17;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(20, 401);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(92, 17);
this.label9.TabIndex = 16;
this.label9.Text = "上次登录地址:";
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(20, 462);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(92, 17);
this.label11.TabIndex = 20;
this.label11.Text = "登录失败次数";
//
// textBox_LastLoginWay
//
@@ -278,23 +156,167 @@
this.label10.TabIndex = 18;
this.label10.Text = "上次登录方式:";
//
// textBox_LoginFailedCount
// textBox_LastLoginIpAddress
//
this.textBox_LoginFailedCount.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginFailedCount.Location = new System.Drawing.Point(112, 459);
this.textBox_LoginFailedCount.Name = "textBox_LoginFailedCount";
this.textBox_LoginFailedCount.ReadOnly = true;
this.textBox_LoginFailedCount.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginFailedCount.TabIndex = 21;
this.textBox_LastLoginIpAddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LastLoginIpAddress.Location = new System.Drawing.Point(112, 398);
this.textBox_LastLoginIpAddress.Name = "textBox_LastLoginIpAddress";
this.textBox_LastLoginIpAddress.ReadOnly = true;
this.textBox_LastLoginIpAddress.Size = new System.Drawing.Size(177, 23);
this.textBox_LastLoginIpAddress.TabIndex = 17;
//
// label11
// label9
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(20, 462);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(92, 17);
this.label11.TabIndex = 20;
this.label11.Text = "登录失败次数";
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(20, 401);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(92, 17);
this.label9.TabIndex = 16;
this.label9.Text = "上次登录地址";
//
// textBox_LastLoginTime
//
this.textBox_LastLoginTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LastLoginTime.Location = new System.Drawing.Point(112, 368);
this.textBox_LastLoginTime.Name = "textBox_LastLoginTime";
this.textBox_LastLoginTime.ReadOnly = true;
this.textBox_LastLoginTime.Size = new System.Drawing.Size(177, 23);
this.textBox_LastLoginTime.TabIndex = 15;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 371);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(92, 17);
this.label8.TabIndex = 14;
this.label8.Text = "上次登录时间:";
//
// textBox_LoginFrequency
//
this.textBox_LoginFrequency.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginFrequency.Location = new System.Drawing.Point(112, 338);
this.textBox_LoginFrequency.Name = "textBox_LoginFrequency";
this.textBox_LoginFrequency.ReadOnly = true;
this.textBox_LoginFrequency.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginFrequency.TabIndex = 13;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(20, 341);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 17);
this.label7.TabIndex = 12;
this.label7.Text = "总登录次数:";
//
// textBox_LoginEnable
//
this.textBox_LoginEnable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_LoginEnable.Location = new System.Drawing.Point(112, 308);
this.textBox_LoginEnable.Name = "textBox_LoginEnable";
this.textBox_LoginEnable.ReadOnly = true;
this.textBox_LoginEnable.Size = new System.Drawing.Size(177, 23);
this.textBox_LoginEnable.TabIndex = 11;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(20, 311);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(92, 17);
this.label6.TabIndex = 10;
this.label6.Text = "是否允许登录:";
//
// textBox_RegisterTime
//
this.textBox_RegisterTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_RegisterTime.Location = new System.Drawing.Point(112, 279);
this.textBox_RegisterTime.Name = "textBox_RegisterTime";
this.textBox_RegisterTime.ReadOnly = true;
this.textBox_RegisterTime.Size = new System.Drawing.Size(177, 23);
this.textBox_RegisterTime.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 282);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(68, 17);
this.label5.TabIndex = 8;
this.label5.Text = "注册时间:";
//
// textBox_GradeDescription
//
this.textBox_GradeDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_GradeDescription.Location = new System.Drawing.Point(112, 251);
this.textBox_GradeDescription.Name = "textBox_GradeDescription";
this.textBox_GradeDescription.ReadOnly = true;
this.textBox_GradeDescription.Size = new System.Drawing.Size(177, 23);
this.textBox_GradeDescription.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 254);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 17);
this.label4.TabIndex = 6;
this.label4.Text = "权限:";
//
// textBox_Factory
//
this.textBox_Factory.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_Factory.Location = new System.Drawing.Point(112, 223);
this.textBox_Factory.Name = "textBox_Factory";
this.textBox_Factory.ReadOnly = true;
this.textBox_Factory.Size = new System.Drawing.Size(177, 23);
this.textBox_Factory.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 226);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17);
this.label3.TabIndex = 4;
this.label3.Text = "工厂:";
//
// textBox_NameAlias
//
this.textBox_NameAlias.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_NameAlias.Location = new System.Drawing.Point(112, 194);
this.textBox_NameAlias.Name = "textBox_NameAlias";
this.textBox_NameAlias.ReadOnly = true;
this.textBox_NameAlias.Size = new System.Drawing.Size(177, 23);
this.textBox_NameAlias.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 197);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 17);
this.label2.TabIndex = 2;
this.label2.Text = "别名:";
//
// textBox_UserName
//
this.textBox_UserName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox_UserName.Location = new System.Drawing.Point(112, 164);
this.textBox_UserName.Name = "textBox_UserName";
this.textBox_UserName.ReadOnly = true;
this.textBox_UserName.Size = new System.Drawing.Size(177, 23);
this.textBox_UserName.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 167);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// groupBox2
//
@@ -317,37 +339,14 @@
| 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;
//
// userButton_upload
//
this.userButton_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.userButton_upload.BackColor = System.Drawing.Color.Transparent;
this.userButton_upload.CustomerInformation = "";
this.userButton_upload.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton_upload.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton_upload.Location = new System.Drawing.Point(10, 460);
this.userButton_upload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton_upload.Name = "userButton_upload";
this.userButton_upload.Size = new System.Drawing.Size(65, 23);
this.userButton_upload.TabIndex = 8;
this.userButton_upload.UIText = "上传";
//
// userButton1
//
this.userButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton1.Location = new System.Drawing.Point(81, 460);
this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(65, 23);
this.userButton1.TabIndex = 9;
this.userButton1.UIText = "下载";
//
// userButton2
//
this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -361,25 +360,37 @@
this.userButton2.Size = new System.Drawing.Size(65, 23);
this.userButton2.TabIndex = 10;
this.userButton2.UIText = "删除";
this.userButton2.Click += new System.EventHandler(this.userButton2_Click);
//
// label12
// userButton1
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(20, 24);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(44, 17);
this.label12.TabIndex = 22;
this.label12.Text = "头像:";
this.userButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton1.Location = new System.Drawing.Point(81, 460);
this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(65, 23);
this.userButton1.TabIndex = 9;
this.userButton1.UIText = "下载";
this.userButton1.Click += new System.EventHandler(this.userButton1_Click);
//
// pictureBox_UserPortrait
// userButton_upload
//
this.pictureBox_UserPortrait.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox_UserPortrait.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox_UserPortrait.Location = new System.Drawing.Point(112, 22);
this.pictureBox_UserPortrait.Name = "pictureBox_UserPortrait";
this.pictureBox_UserPortrait.Size = new System.Drawing.Size(136, 136);
this.pictureBox_UserPortrait.TabIndex = 23;
this.pictureBox_UserPortrait.TabStop = false;
this.userButton_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.userButton_upload.BackColor = System.Drawing.Color.Transparent;
this.userButton_upload.CustomerInformation = "";
this.userButton_upload.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton_upload.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton_upload.Location = new System.Drawing.Point(10, 460);
this.userButton_upload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton_upload.Name = "userButton_upload";
this.userButton_upload.Size = new System.Drawing.Size(65, 23);
this.userButton_upload.TabIndex = 8;
this.userButton_upload.UIText = "上传";
this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click);
//
// AccountDetails
//
@@ -400,8 +411,8 @@
this.Shown += new System.EventHandler(this.AccountDetails_Shown);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox_UserPortrait)).EndInit();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}

View File

@@ -0,0 +1,231 @@
using CommonLibrary;
using HslCommunication.Enthernet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using HslCommunication;
using HslCommunication.BasicFramework;
namespace ClientsLibrary
{
public partial class FormAccountDetails : Form
{
#region Constructor
public FormAccountDetails(UserPortrait userPortrait)
{
InitializeComponent();
UserPortrait = userPortrait;
}
#endregion
#region Load Show Close
private void AccountDetails_Shown(object sender, EventArgs e)
{
// 加载各种数据
textBox_Factory.Text = UserClient.UserAccount.Factory;
textBox_GradeDescription.Text = AccountGrade.GetDescription(UserClient.UserAccount.Grade);
textBox_LastLoginIpAddress.Text = UserClient.UserAccount.LastLoginIpAddress;
textBox_LastLoginTime.Text = UserClient.UserAccount.LastLoginTime.ToString();
textBox_LastLoginWay.Text = UserClient.UserAccount.LastLoginWay;
textBox_LoginEnable.Text = UserClient.UserAccount.LoginEnable ? "允许" : "禁止";
textBox_LoginFailedCount.Text = UserClient.UserAccount.LoginFailedCount.ToString();
textBox_LoginFrequency.Text = UserClient.UserAccount.LoginFrequency.ToString();
textBox_NameAlias.Text = UserClient.UserAccount.NameAlias;
textBox_RegisterTime.Text = UserClient.UserAccount.RegisterTime.ToString();
textBox_UserName.Text = UserClient.UserAccount.UserName;
// 加载头像
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolLoadPortrait), null);
// 加载文件列表
DownloadUserFileNames();
}
private void AccountDetails_Load(object sender, EventArgs e)
{
Text = "账户详细信息";
treeView1.ImageList = new ImageList();
treeView1.ImageList.Images.Add(Properties.Resources.ExtensionManager_vsix_OSReg_16x);
treeView1.ImageList.Images.Add(Properties.Resources.Flagthread_7317);
treeView1.Nodes[0].ImageIndex = 0;
treeView1.Nodes[0].SelectedImageIndex = 0;
}
#endregion
#region
public UserPortrait UserPortrait { get; }
private void LoadPortraitByFileName(string fileName)
{
if(IsHandleCreated)
{
if(InvokeRequired)
{
BeginInvoke(new Action(() =>
{
LoadPortraitByFileName(fileName);
}));
return;
}
try
{
pictureBox_UserPortrait.LoadAsync(fileName);
}
catch(Exception ex)
{
UserClient.LogNet?.WriteException("加载图片异常!", ex);
}
}
}
private void ThreadPoolLoadPortrait(object obj)
{
UserPortrait.LoadUserLargePortraint(LoadPortraitByFileName);
}
private void pictureBox_UserPortrait_Click(object sender, EventArgs e)
{
UserPortrait.ChangePortrait();
UserPortrait.LoadUserLargePortraint(LoadPortraitByFileName);
}
#endregion
#region
public void DownloadUserFileNames()
{
treeView1.Nodes[0].Text = "我的云端文件(下载中)";
treeView1.Nodes[0].Nodes.Clear();
treeView1.Refresh();
// 向服务器请求自身的文件列表
OperateResult result = UserClient.Net_File_Client.DownloadPathFileNames(
out string[] files, "Files", "Personal", UserClient.UserAccount.UserName
);
if (result.IsSuccess)
{
if (files != null)
{
foreach(var m in files)
{
TreeNode node = new TreeNode(m, 1, 1);
treeView1.Nodes[0].Nodes.Add(node);
}
treeView1.Nodes[0].Text = "我的云端文件(" + files.Length + "";
}
else
{
treeView1.Nodes[0].Text = "我的云端文件NULL";
}
}
else
{
treeView1.Nodes[0].Text = "我的云端文件(下载失败)";
}
treeView1.ExpandAll();
}
private void userButton_upload_Click(object sender, EventArgs e)
{
// 上传个人文件
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Multiselect = true;
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FormFileOperate upload = new FormFileOperate(UserClient.Net_File_Client,
openFileDialog.FileNames,
"Files",
"Personal",
UserClient.UserAccount.UserName);
upload.ShowDialog();
// 更新文件列表
DownloadUserFileNames();
}
}
}
private void userButton1_Click(object sender, EventArgs e)
{
// 下载选择文件
TreeNode treeNode = treeView1.SelectedNode;
if (treeNode.Name != "files_root")
{
// 选择文件夹
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
{
folderBrowserDialog.Description = "请选择保存路径,如果有重名文件,将会覆盖!";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
FormFileOperate download = new FormFileOperate(UserClient.Net_File_Client,
new string[] { treeNode.Text },
"Files",
"Personal",
UserClient.UserAccount.UserName,
folderBrowserDialog.SelectedPath + "\\" + treeNode.Text
);
download.ShowDialog();
}
}
}
}
private void userButton2_Click(object sender, EventArgs e)
{
// 删除选中文件
TreeNode treeNode = treeView1.SelectedNode;
if (treeNode.Name != "file_root")
{
using (FormPasswordCheck passwordCheck = new FormPasswordCheck(UserClient.UserAccount.Password))
{
if (passwordCheck.ShowDialog() == DialogResult.OK)
{
OperateResult result = UserClient.Net_File_Client.DeleteFile(
treeNode.Text,
"Files",
"Personal",
UserClient.UserAccount.UserName);
if(result.IsSuccess)
{
// 更新文件列表
DownloadUserFileNames();
}
else
{
MessageBox.Show("删除失败,原因:" + result.Message);
}
}
}
}
}
#endregion
}
}

View File

@@ -2,6 +2,7 @@
using HslCommunication;
using HslCommunication.BasicFramework;
using HslCommunication.Enthernet;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -17,6 +18,7 @@ namespace ClientsLibrary
*
* 时间2017年9月17日 16:09:05
* 用户头像类,负责更换头像,下载头像,以及初始化登录操作
* 说明:类头像类还没有代码重构好,加载部分块还有部分重复代码,也因为.Net3.5这部分的代码异步比较难处理
*
*********************************************************************************/
@@ -82,7 +84,41 @@ namespace ClientsLibrary
{
ffo.ShowDialog();
}
DownloadUserPortraint();
// 上传文件MD5码
string SmallPortraitMD5 = SoftBasic.CalculateFileMD5(path32);
string LargePortraitMD5 = SoftBasic.CalculateFileMD5(path300);
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
{
MessageBox.Show("上传头像失败!原因:" + result.Message);
}
}
}
}
@@ -90,71 +126,120 @@ namespace ClientsLibrary
#endregion
#region Load Portraint
/// <summary>
/// 加载小尺寸的头像操作,可以放到主线程
/// </summary>
public void LoadUserSmallPortraint()
{
// 先获取服务器端的MD5码
string fileMd5 = UserClient.UserAccount.SmallPortraitMD5;
if(string.IsNullOrEmpty(fileMd5))
{
// 服务器端没有文件,加载结束
return;
}
// 获取本地MD5
string fileName = FileSavePath + @"\" + PortraitSupport.SmallPortrait;
if (System.IO.File.Exists(fileName))
{
// 本地存在文件
string currentMd5 = SoftBasic.CalculateFileMD5(fileName);
// 对比验证
if (fileName == currentMd5)
{
// 加载本地文件
LoadPic?.Invoke(fileName);
return;
}
}
// 本地不存在文件或校验失败,需要重新下载
OperateResult result = UserClient.Net_File_Client.DownloadFile(PortraitSupport.SmallPortrait,
"Files",
"Portrait",
UserClient.UserAccount.UserName,
null,
fileName);
if(result.IsSuccess)
{
// 下载成功
LoadPic?.Invoke(fileName);
}
else
{
MessageBox.Show("头像从服务器下载失败,错误原因:" + result.Message);
}
}
/// <summary>
/// 加载大尺寸的头像方法,需要放到线程池中操作
/// </summary>
/// <param name="largeLoadAction"></param>
public void LoadUserLargePortraint(Action<string> largeLoadAction)
{
// 先获取服务器端的MD5码
string fileMd5 = UserClient.UserAccount.LargePortraitMD5;
if (string.IsNullOrEmpty(fileMd5))
{
// 服务器端没有文件,加载结束
return;
}
// 获取本地MD5
string fileName = FileSavePath + @"\" + PortraitSupport.LargePortrait;
if (System.IO.File.Exists(fileName))
{
// 本地存在文件,先进行加载,如果运算不一致,再重新加载
largeLoadAction?.Invoke(fileName);
string currentMd5 = null;
try
{
currentMd5 = SoftBasic.CalculateFileMD5(fileName);
}
catch(Exception ex)
{
MessageBox.Show("计算文件MD5码错误" + ex.Message);
return;
}
// 对比验证
if (fileMd5 == currentMd5)
{
return;
}
}
// 本地不存在文件或校验失败,需要重新下载
OperateResult result = UserClient.Net_File_Client.DownloadFile(PortraitSupport.LargePortrait,
"Files",
"Portrait",
UserClient.UserAccount.UserName,
null,
fileName);
if (result.IsSuccess)
{
// 下载成功
largeLoadAction?.Invoke(fileName);
}
else
{
MessageBox.Show("头像从服务器下载失败,错误原因:" + result.Message);
}
}
#endregion
#region Download Portraint
/// <summary>
/// 加载头像信息,检查本地是否有相应的文件,没有则向服务器请求下载新的头像,然后加载,应放到线程池中执行
/// </summary>
public void DownloadUserPortraint()
{
string path = FileSavePath;
//获取服务器文件名称
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
if (result.IsSuccess)
{
if (result.Content[0] == 'Y')
{
//服务器存在头像
string fileName = path + @"\" + PortraitSupport.SmallPortrait;
string FileMd5 = result.Content.Substring(1);
if (System.IO.File.Exists(fileName))
{
//文件文件
string currentMd5 = SoftBasic.CalculateFileMD5(fileName);
if (currentMd5 == FileMd5)
{
//加载本地头像
LoadPic?.Invoke(fileName);
}
else
{
//头像已经换了
DownloadUserPortraint(path);
}
}
else
{
//客户端不存在头像
DownloadUserPortraint(path);
}
}
else
{
//服务器不存在头像,本次加载结束
}
}
}
/// <summary>
/// 下载小尺寸的头像并使用委托加载它
/// </summary>
/// <param name="path"></param>
public void DownloadUserPortraint(string path)
{
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
if (result.IsSuccess)
{
if (result.Content[0] == 'Y')
{
byte[] data = Convert.FromBase64String(result.Content.Substring(1));
string path32 = path + @"\" + PortraitSupport.SmallPortrait;
System.IO.File.WriteAllBytes(path32, data);
LoadPic?.Invoke(path32);
}
}
}
/// <summary>
/// 下载大尺寸的头像并打开它,该方法适合线程池
/// </summary>
@@ -163,7 +248,28 @@ namespace ClientsLibrary
string path = FileSavePath;
string path300 = path + @"\" + PortraitSupport.LargePortrait;
// 利用客户端文件引擎去下载文件
if (string.IsNullOrEmpty(UserClient.UserAccount.LargePortraitMD5))
{
// 服务器不存在头像
return;
}
if (System.IO.File.Exists(path300))
{
// 验证文件MD5码是否一致
string currentMd5 = SoftBasic.CalculateFileMD5(path300);
if (UserClient.UserAccount.LargePortraitMD5 == currentMd5)
{
System.Diagnostics.Process.Start(path300);
// 避免屏幕闪烁
Thread.Sleep(1000);
return;
}
}
// 验证不一致时需要利用客户端文件引擎去下载文件
OperateResult operateResult = UserClient.Net_File_Client.DownloadFile(
PortraitSupport.LargePortrait,
"Files",
@@ -179,6 +285,7 @@ namespace ClientsLibrary
System.Diagnostics.Process.Start(path300);
}
// 避免屏幕闪烁
Thread.Sleep(1000);
}