Skip to content

Commit 633f31a

Browse files
committed
系统新增分厂配置功能,允许客户端进行配置分厂或是部门之类的
1 parent aa6e21f commit 633f31a

File tree

12 files changed

+209
-69
lines changed

12 files changed

+209
-69
lines changed

ClientsLibrary/FormLogView.Designer.cs

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ClientsLibrary/FormRegisterAccount.Designer.cs

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ClientsLibrary/FormRegisterAccount.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,25 @@ namespace ClientsLibrary
1414
{
1515
public partial class FormRegisterAccount : Form
1616
{
17-
public FormRegisterAccount()
17+
/// <summary>
18+
/// 实例化对象
19+
/// </summary>
20+
/// <param name="factories"></param>
21+
/// <exception cref="ArgumentNullException"></exception>
22+
public FormRegisterAccount(string[] factories)
1823
{
1924
InitializeComponent();
2025

2126
net_client = UserClient.Net_simplify_client;
27+
Factories = new List<string>(factories);
28+
29+
30+
// 根据自身需求是否添加总公司名称
31+
Factories.Add("总公司");
2232
}
23-
33+
34+
private List<string> Factories = null;
35+
2436
private void FormRegisterAccount_Load(object sender, EventArgs e)
2537
{
2638
comboBox1.DataSource = AccountGrade.GetDescription();
@@ -29,18 +41,20 @@ private void FormRegisterAccount_Load(object sender, EventArgs e)
2941
comboBox1.SelectedItem = AccountGrade.GetDescription(AccountGrade.Technology);
3042
comboBox2.SelectedItem = "允许";
3143

44+
comboBox_factory.DataSource = Factories.ToArray();
45+
3246
textBox4.Text = (new UserAccount()).ForbidMessage;
3347
}
3448

3549
private NetSimplifyClient net_client = null;
3650

3751
private void userButton_login_Click(object sender, EventArgs e)
3852
{
39-
//点击了注册,先获取数据
53+
// 点击了注册,先获取数据
4054
UserAccount account = new UserAccount();
4155
account.UserName = textBox1.Text;
4256
account.Password = textBox2.Text;
43-
account.Factory = textBox3.Text;
57+
account.Factory = comboBox_factory.SelectedItem.ToString();
4458
switch (comboBox1.SelectedIndex)
4559
{
4660
case 0: account.Grade = AccountGrade.SuperAdministrator; break;

ClientsLibrary/UserClient.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,46 @@
99
namespace ClientsLibrary
1010
{
1111

12-
//====================================================================================================
13-
// 模版说明:
14-
//====================================================================================================
12+
13+
/***********************************************************************************
14+
*
15+
* 说明:用来存储客户端全局的变量数据,好在任何界面都可以直达数据
16+
*
17+
*
18+
***********************************************************************************/
19+
1520

1621
/// <summary>
1722
/// 一个通用的用户客户端类
1823
/// </summary>
1924
public class UserClient
2025
{
2126
public static JsonSettings JsonSettings = new JsonSettings();
27+
28+
29+
2230
/// <summary>
2331
/// 本软件的当前版本,用来验证更新的关键依据
2432
/// </summary>
2533
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0");
2634

35+
36+
2737
/// <summary>
28-
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试,云端:117.48.203.204
38+
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试,云服务器端:117.48.203.204
2939
/// </summary>
3040
public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址
3141

42+
43+
44+
/// <summary>
45+
/// 系统的分厂信息
46+
/// </summary>
47+
public static List<string> SystemFactories { get; set; } = new List<string>();
48+
49+
50+
51+
3252
/// <summary>
3353
/// 所有版本更新信息的对象
3454
/// </summary>
@@ -39,7 +59,8 @@ public class UserClient
3959
{
4060
VersionNum=new SystemVersion("1.0.0"),
4161
ReleaseDate=new DateTime(2017,1,1),//该版本发布的日期
42-
UpdateDetails=new StringBuilder("1.本系统第一版本正式发布使用。"+Environment.NewLine+
62+
UpdateDetails=new StringBuilder(
63+
"1.本系统第一版本正式发布使用。"+Environment.NewLine+
4364
"2.提供了多客户端用时在线的功能。"+Environment.NewLine+
4465
"3.需要用户自行添加"),
4566
},
@@ -85,6 +106,12 @@ public class UserClient
85106
};
86107

87108

109+
110+
/// <summary>
111+
/// 用来处理客户端发生的未捕获的异常,将通过网络组件发送至服务器存储,用于更好的跟踪错误
112+
/// </summary>
113+
/// <param name="sender"></param>
114+
/// <param name="e"></param>
88115
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
89116
{
90117
if (e.ExceptionObject is Exception ex)

CommonLibrary/BasicSupport/SoftSettings.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,33 @@
66
using System.IO;
77
using HslCommunication.BasicFramework;
88

9-
//2017-02-10
9+
10+
11+
12+
/*************************************************************************************
13+
*
14+
* 时间:2017年9月3日 09:18:21
15+
* 说明:本文档主要包含一个主要内容,关于客户端和服务器的一些本地参数存储解析
16+
*
17+
* 服务器:此处存储了系统版本号,公告,是否允许用户登录,分厂信息等等共享
18+
* 客户端:此处存储了用户名,密码,上次登录时间,机器码等等,用于客户端自我校验
19+
*
20+
* 格式:存储采用json字符串存储,客户端还进行了双向加密,防止用户直接打开更改
21+
*
22+
*************************************************************************************/
23+
24+
25+
26+
27+
28+
29+
30+
1031

1132
namespace CommonLibrary
1233
{
34+
35+
1336
/// <summary>
1437
/// 服务器的常用参数保存,包含了版本号,公告,是否允许登录,不能登录说明
1538
/// </summary>
@@ -33,6 +56,15 @@ public class ServerSettings : SoftFileSaveBase
3356
/// 不允许登录系统的原因
3457
/// </summary>
3558
public string Account_Forbidden_Reason { get; set; } = "系统处于维护中,请稍后登录。";
59+
/// <summary>
60+
/// 系统的所属分厂
61+
/// </summary>
62+
public List<string> SystemFactories { get; set; } = new List<string>();
63+
64+
65+
66+
67+
3668

3769
/// <summary>
3870
/// 获取需要存储的数据
@@ -45,7 +77,8 @@ public override string ToSaveString()
4577
{ nameof(SystemVersion), new JValue(SystemVersion.ToString()) },
4678
{ nameof(Announcement), new JValue(Announcement) },
4779
{ nameof(Can_Account_Login), new JValue(Can_Account_Login) },
48-
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) }
80+
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) },
81+
{ nameof(SystemFactories), new JArray(SystemFactories) }
4982
};
5083
return json.ToString();
5184
}
@@ -60,6 +93,7 @@ public override void LoadByString(string content)
6093
Announcement = json.Property(nameof(Announcement)).Value.Value<string>();
6194
Can_Account_Login = SoftBasic.GetValueFromJsonObject(json, nameof(Can_Account_Login), Can_Account_Login);
6295
Account_Forbidden_Reason = SoftBasic.GetValueFromJsonObject(json, nameof(Account_Forbidden_Reason), Account_Forbidden_Reason);
96+
SystemFactories = JArray.Parse(SoftBasic.GetValueFromJsonObject(json, nameof(SystemFactories), "[]")).ToObject<List<string>>();
6397
}
6498

6599
}

CommonLibrary/HeadCode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public static bool IsCustomerGroupSystem(int customer)
5959
public static int 下载小头 { get; } = 10016;
6060
public static int 请求大头 { get; } = 10017;
6161
public static int 下载大头 { get; } = 10018;
62+
public static int 请求分厂 { get; } = 10019;
63+
public static int 上传分厂 { get; } = 10020;
64+
6265

6366

6467

软件系统客户端Wpf/MainWindow.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
</MenuItem>
6363

6464
<Separator />
65+
<MenuItem Header="分厂配置" x:Name="MenuItem分厂配置" Click="MenuItem分厂配置_Click">
66+
<MenuItem.Icon>
67+
<materialDesign:PackIcon Kind="City" />
68+
</MenuItem.Icon>
69+
</MenuItem>
6570
<MenuItem Header="日志查看" x:Name="MenuItem日志查看" Click="MenuItem日志查看_Click">
6671
<MenuItem.Icon>
6772
<materialDesign:PackIcon Kind="FlagVariant" />

软件系统客户端Wpf/MainWindow.xaml.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ private void Window_ContentRendered(object sender, EventArgs e)
123123
MenuItem注册账户.IsEnabled = false;
124124
MenuItem消息发送.IsEnabled = false;
125125
MenuItem开发中心.IsEnabled = false;
126+
MenuItem分厂配置.IsEnabled = false;
126127
}
127128

128129

@@ -211,7 +212,7 @@ private void MenuItem账户管理_Click(object sender, RoutedEventArgs e)
211212

212213
private void MenuItem注册账户_Click(object sender, RoutedEventArgs e)
213214
{
214-
using (FormRegisterAccount fra = new FormRegisterAccount())
215+
using (FormRegisterAccount fra = new FormRegisterAccount(UserClient.SystemFactories.ToArray()))
215216
{
216217
fra.ShowDialog();
217218
}
@@ -370,6 +371,18 @@ private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
370371
}
371372

372373

374+
private void MenuItem分厂配置_Click(object sender, RoutedEventArgs e)
375+
{
376+
using (FormInputAndAction fiaa = new FormInputAndAction(
377+
str => UserClient.Net_simplify_client.ReadFromServer(
378+
CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess,
379+
JArray.FromObject(UserClient.SystemFactories).ToString(),
380+
"请按照JSON格式更新分厂信息,然后提交:"))
381+
{
382+
fiaa.ShowDialog();
383+
}
384+
}
385+
373386
#endregion
374387

375388

@@ -756,5 +769,7 @@ private async void Button_Dialog_Click(object sender, RoutedEventArgs e)
756769
await Task.Delay(2000);
757770
DialogHostWait.IsOpen = false;
758771
}
772+
773+
759774
}
760775
}

0 commit comments

Comments
 (0)