完善了文件共享的功能,等待最后的调试

This commit is contained in:
hsl
2017-04-06 22:00:34 +08:00
parent c399a7a8d6
commit aa27f219cf
6 changed files with 226 additions and 76 deletions

View File

@@ -31,6 +31,7 @@ namespace CommonLibrary
public static string { get; } = "A008";
public static string { get; } = "A009";
public static string { get; } = "A010";
public static string { get; } = "AA01";

View File

@@ -50,6 +50,8 @@
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel1 = new System.Windows.Forms.Panel();
this.label_file_count = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.linkLabel_logout = new System.Windows.Forms.LinkLabel();
this.label_factory = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
@@ -68,8 +70,6 @@
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label_Announcement = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label_file_count = new System.Windows.Forms.Label();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
@@ -146,7 +146,7 @@
this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(921, 33);
this.menuStrip1.Size = new System.Drawing.Size(921, 35);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
@@ -159,41 +159,41 @@
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "管理员ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(84, 29);
this.ToolStripMenuItem.Size = new System.Drawing.Size(84, 31);
this.ToolStripMenuItem.Text = "管理员";
//
// 更改公告ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更改公告ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "更改公告";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 日志查看ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "日志查看ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "日志查看";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 远程更新ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "远程更新ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "远程更新";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 注册账号ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "注册账号ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "注册账号";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
@@ -202,13 +202,13 @@
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "设置ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 29);
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 31);
this.ToolStripMenuItem.Text = "设置";
//
// 修改密码ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "修改密码ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "修改密码";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
@@ -219,27 +219,27 @@
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 29);
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 31);
this.ToolStripMenuItem.Text = "关于";
//
// 关于本软件ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "关于本软件ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "关于本软件";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 更新日志ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更新日志ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "更新日志";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 版本号说明ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本号说明ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "版本号说明";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
@@ -267,11 +267,32 @@
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel1.Location = new System.Drawing.Point(697, 33);
this.panel1.Location = new System.Drawing.Point(697, 35);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(224, 421);
this.panel1.Size = new System.Drawing.Size(224, 419);
this.panel1.TabIndex = 2;
//
// label_file_count
//
this.label_file_count.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label_file_count.Cursor = System.Windows.Forms.Cursors.Hand;
this.label_file_count.Location = new System.Drawing.Point(82, 143);
this.label_file_count.Name = "label_file_count";
this.label_file_count.Size = new System.Drawing.Size(129, 17);
this.label_file_count.TabIndex = 18;
this.label_file_count.Text = "0";
this.label_file_count.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.label_file_count.Click += new System.EventHandler(this.label_file_count_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(8, 143);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(68, 17);
this.label8.TabIndex = 17;
this.label8.Text = "文件数量:";
//
// linkLabel_logout
//
this.linkLabel_logout.AutoSize = true;
@@ -321,7 +342,7 @@
this.listBox1.Location = new System.Drawing.Point(11, 183);
this.listBox1.Name = "listBox1";
this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.listBox1.Size = new System.Drawing.Size(200, 208);
this.listBox1.Size = new System.Drawing.Size(200, 242);
this.listBox1.TabIndex = 12;
//
// label_address
@@ -445,25 +466,6 @@
this.label_Announcement.Text = "[公告]";
this.label_Announcement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(8, 143);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(68, 17);
this.label8.TabIndex = 17;
this.label8.Text = "文件数量:";
//
// label_file_count
//
this.label_file_count.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label_file_count.Location = new System.Drawing.Point(82, 143);
this.label_file_count.Name = "label_file_count";
this.label_file_count.Size = new System.Drawing.Size(129, 17);
this.label_file_count.TabIndex = 18;
this.label_file_count.Text = "0";
this.label_file_count.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// FormMainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

View File

@@ -340,6 +340,15 @@ namespace 软件系统客户端模版
#endregion
#region
/// <summary>
/// 文件显示的控件
/// </summary>
private UIControls.ShareFilesRender UIControls_Files { get; set; }
/// <summary>
/// 所有在主界面显示的控件集
/// </summary>
@@ -354,6 +363,21 @@ namespace 软件系统客户端模版
private void MainRenderInitialization()
{
//将所有的子集控件添加进去
/*
* 例如此处展示了文件控件是如何添加进去的
* 1.先进行实例化,赋值初始参数
* 2.添加进项目
* 3.显示
*/
UIControls_Files = new UIControls.ShareFilesRender()
{
Parent = this,
Dock = DockStyle.Fill,
Visible = true,
};
all_main_render.Add(UIControls_Files);
}
private void SetShowRenderControl(UserControl control)
@@ -379,6 +403,16 @@ namespace 软件系统客户端模版
if (control != null) SetShowRenderControl(control);
}
private void label_file_count_Click(object sender, EventArgs e)
{
SetShowRenderControl(UIControls_Files);
UIControls_Files.UpdateFiles();
}
#endregion
}
}

View File

@@ -29,11 +29,11 @@
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.userButton_upload = new BasicFramework.UserButton();
this.userButton_refresh = new BasicFramework.UserButton();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.userButton_refresh = new BasicFramework.UserButton();
this.userButton_upload = new BasicFramework.UserButton();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
@@ -51,29 +51,24 @@
this.panel1.Size = new System.Drawing.Size(605, 35);
this.panel1.TabIndex = 0;
//
// panel2
// textBox1
//
this.panel2.AutoScroll = true;
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel2.Location = new System.Drawing.Point(0, 35);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(605, 291);
this.panel2.TabIndex = 1;
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(439, 5);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(161, 23);
this.textBox1.TabIndex = 9;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// userButton_upload
// label1
//
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(3, 4);
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(71, 25);
this.userButton_upload.TabIndex = 6;
this.userButton_upload.UIText = "上传";
this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click);
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(395, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 17);
this.label1.TabIndex = 8;
this.label1.Text = "搜索:";
//
// userButton_refresh
//
@@ -89,23 +84,29 @@
this.userButton_refresh.UIText = "刷新";
this.userButton_refresh.Click += new System.EventHandler(this.userButton_refresh_Click);
//
// label1
// userButton_upload
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(395, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 17);
this.label1.TabIndex = 8;
this.label1.Text = "搜索:";
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(3, 4);
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(71, 25);
this.userButton_upload.TabIndex = 6;
this.userButton_upload.UIText = "上传";
this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click);
//
// textBox1
// panel2
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(439, 5);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(161, 23);
this.textBox1.TabIndex = 9;
this.panel2.AutoScroll = true;
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel2.Location = new System.Drawing.Point(0, 35);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(605, 291);
this.panel2.TabIndex = 1;
//
// ShareFilesRender
//
@@ -115,6 +116,7 @@
this.Controls.Add(this.panel1);
this.Name = "ShareFilesRender";
this.Size = new System.Drawing.Size(605, 326);
this.Load += new System.EventHandler(this.ShareFilesRender_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);

View File

@@ -6,6 +6,9 @@ using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IndustryEthernet;
using Newtonsoft.Json.Linq;
namespace .UIControls
{
@@ -18,12 +21,115 @@ namespace 软件系统客户端模版.UIControls
private void userButton_upload_Click(object sender, EventArgs e)
{
//
//上传数据,先对权限进行验证
if(UserClient.UserAccount.Grade<BasicFramework.AccountGrade.Technology)
{
MessageBox.Show("权限不够!");
return;
}
using (FormSimplyFileUpload upload = new FormSimplyFileUpload(
UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File,
UserClient.UserAccount.UserName))
{
upload.ShowDialog();
}
}
private void userButton_refresh_Click(object sender, EventArgs e)
{
//向服务器请求数据
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.);
if(result.IsSuccess)
{
Cache_Files = JArray.Parse(result.Content).ToObject<List<File_Save>>();
SetFilesShow(Cache_Files);
}
else
{
MessageBox.Show(result.ToMessageShowString());
}
}
private void SetFilesShow(List<File_Save> files)
{
panel2.SuspendLayout();
//清楚缓存
ClearControls();
if (files?.Count > 0 && panel2.Width > 20)
{
int location_y = 2;
//添加子控件
foreach(var m in files)
{
FileItemShow item = new FileItemShow(UserClient.ServerIp,
CommonLibrary.CommonLibrary.Port_Share_File,
() =>
{
if (m.UploadName != UserClient.UserAccount.UserName)
{
MessageBox.Show("无法删除不是自己上传的文件。");
return false;
}
else
{
return true;
}
});
panel2.Controls.Add(item);
item.Location = new Point(2, location_y);
item.Size = new Size(panel2.Width - 20, item.Size.Height);
item.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
location_y += item.Height + 2;
FilesControls.Push(item);
}
}
panel2.ResumeLayout();
}
public void UpdateFiles()
{
userButton_refresh.PerformClick();
}
private void ClearControls()
{
while (FilesControls.Count > 0)
{
FilesControls.Pop().Dispose();
}
}
/// <summary>
/// 所有文件信息的缓存,以支持直接的搜索
/// </summary>
private List<File_Save> Cache_Files { get; set; } = new List<File_Save>();
/// <summary>
/// 文件控件的缓存列表,方便清除垃圾
/// </summary>
private Stack<IDisposable> FilesControls = new Stack<IDisposable>();
private void ShareFilesRender_Load(object sender, EventArgs e)
{
//选择是否禁用上传键
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//搜索时触发的数据
if(string.IsNullOrEmpty(textBox1.Text))
{
string pattern = textBox1.Text;
SetFilesShow(Cache_Files.Where(f => f.FileName.Contains(pattern) || f.FileNote.Contains(pattern)).ToList());
}
else
{
SetFilesShow(Cache_Files);
}
}
}
}

View File

@@ -19,6 +19,7 @@ using Newtonsoft.Json.Linq;
// 版权所有 胡少林
// 授权说明 模版仅授权个人使用如需商用请联系hsl200909@163.com洽谈
// 说明 JSON组件引用自james newton-king遵循MIT授权协议
// 说明 文件的图标来源于,感谢作者的无私分享
//============================================================================
@@ -387,6 +388,10 @@ namespace 软件系统服务端模版
bool result = UserServer.ServerAccounts.AddNewAccount(object2.Substring(4));
net_simplify_server.SendMessage(object1, result ? "1" : "0");
}
else if(head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, net_simple_file_server.ToJsonString());
}
else
{
net_simplify_server.SendMessage(object1, object2);