Skip to content

Commit

Permalink
系统新增分厂配置功能,允许客户端进行配置分厂或是部门之类的
Browse files Browse the repository at this point in the history
  • Loading branch information
dathlin committed Sep 3, 2017
1 parent aa6e21f commit 633f31a
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 69 deletions.
5 changes: 2 additions & 3 deletions ClientsLibrary/FormLogView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions ClientsLibrary/FormRegisterAccount.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions ClientsLibrary/FormRegisterAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@ namespace ClientsLibrary
{
public partial class FormRegisterAccount : Form
{
public FormRegisterAccount()
/// <summary>
/// 实例化对象
/// </summary>
/// <param name="factories"></param>
/// <exception cref="ArgumentNullException"></exception>
public FormRegisterAccount(string[] factories)
{
InitializeComponent();

net_client = UserClient.Net_simplify_client;
Factories = new List<string>(factories);


// 根据自身需求是否添加总公司名称
Factories.Add("总公司");
}


private List<string> Factories = null;

private void FormRegisterAccount_Load(object sender, EventArgs e)
{
comboBox1.DataSource = AccountGrade.GetDescription();
Expand All @@ -29,18 +41,20 @@ private void FormRegisterAccount_Load(object sender, EventArgs e)
comboBox1.SelectedItem = AccountGrade.GetDescription(AccountGrade.Technology);
comboBox2.SelectedItem = "允许";

comboBox_factory.DataSource = Factories.ToArray();

textBox4.Text = (new UserAccount()).ForbidMessage;
}

private NetSimplifyClient net_client = null;

private void userButton_login_Click(object sender, EventArgs e)
{
//点击了注册,先获取数据
// 点击了注册,先获取数据
UserAccount account = new UserAccount();
account.UserName = textBox1.Text;
account.Password = textBox2.Text;
account.Factory = textBox3.Text;
account.Factory = comboBox_factory.SelectedItem.ToString();
switch (comboBox1.SelectedIndex)
{
case 0: account.Grade = AccountGrade.SuperAdministrator; break;
Expand Down
37 changes: 32 additions & 5 deletions ClientsLibrary/UserClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,46 @@
namespace ClientsLibrary
{

//====================================================================================================
// 模版说明:
//====================================================================================================

/***********************************************************************************
*
* 说明:用来存储客户端全局的变量数据,好在任何界面都可以直达数据
*
*
***********************************************************************************/


/// <summary>
/// 一个通用的用户客户端类
/// </summary>
public class UserClient
{
public static JsonSettings JsonSettings = new JsonSettings();



/// <summary>
/// 本软件的当前版本,用来验证更新的关键依据
/// </summary>
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0");



/// <summary>
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试,云端:117.48.203.204
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试,云服务器端:117.48.203.204
/// </summary>
public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址



/// <summary>
/// 系统的分厂信息
/// </summary>
public static List<string> SystemFactories { get; set; } = new List<string>();




/// <summary>
/// 所有版本更新信息的对象
/// </summary>
Expand All @@ -39,7 +59,8 @@ public class UserClient
{
VersionNum=new SystemVersion("1.0.0"),
ReleaseDate=new DateTime(2017,1,1),//该版本发布的日期
UpdateDetails=new StringBuilder("1.本系统第一版本正式发布使用。"+Environment.NewLine+
UpdateDetails=new StringBuilder(
"1.本系统第一版本正式发布使用。"+Environment.NewLine+
"2.提供了多客户端用时在线的功能。"+Environment.NewLine+
"3.需要用户自行添加"),
},
Expand Down Expand Up @@ -85,6 +106,12 @@ public class UserClient
};



/// <summary>
/// 用来处理客户端发生的未捕获的异常,将通过网络组件发送至服务器存储,用于更好的跟踪错误
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception ex)
Expand Down
38 changes: 36 additions & 2 deletions CommonLibrary/BasicSupport/SoftSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,33 @@
using System.IO;
using HslCommunication.BasicFramework;

//2017-02-10



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









namespace CommonLibrary
{


/// <summary>
/// 服务器的常用参数保存,包含了版本号,公告,是否允许登录,不能登录说明
/// </summary>
Expand All @@ -33,6 +56,15 @@ public class ServerSettings : SoftFileSaveBase
/// 不允许登录系统的原因
/// </summary>
public string Account_Forbidden_Reason { get; set; } = "系统处于维护中,请稍后登录。";
/// <summary>
/// 系统的所属分厂
/// </summary>
public List<string> SystemFactories { get; set; } = new List<string>();






/// <summary>
/// 获取需要存储的数据
Expand All @@ -45,7 +77,8 @@ public override string ToSaveString()
{ nameof(SystemVersion), new JValue(SystemVersion.ToString()) },
{ nameof(Announcement), new JValue(Announcement) },
{ nameof(Can_Account_Login), new JValue(Can_Account_Login) },
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) }
{ nameof(Account_Forbidden_Reason), new JValue(Account_Forbidden_Reason) },
{ nameof(SystemFactories), new JArray(SystemFactories) }
};
return json.ToString();
}
Expand All @@ -60,6 +93,7 @@ public override void LoadByString(string content)
Announcement = json.Property(nameof(Announcement)).Value.Value<string>();
Can_Account_Login = SoftBasic.GetValueFromJsonObject(json, nameof(Can_Account_Login), Can_Account_Login);
Account_Forbidden_Reason = SoftBasic.GetValueFromJsonObject(json, nameof(Account_Forbidden_Reason), Account_Forbidden_Reason);
SystemFactories = JArray.Parse(SoftBasic.GetValueFromJsonObject(json, nameof(SystemFactories), "[]")).ToObject<List<string>>();
}

}
Expand Down
3 changes: 3 additions & 0 deletions CommonLibrary/HeadCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public static bool IsCustomerGroupSystem(int customer)
public static int 下载小头 { get; } = 10016;
public static int 请求大头 { get; } = 10017;
public static int 下载大头 { get; } = 10018;
public static int 请求分厂 { get; } = 10019;
public static int 上传分厂 { get; } = 10020;




Expand Down
5 changes: 5 additions & 0 deletions 软件系统客户端Wpf/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
</MenuItem>

<Separator />
<MenuItem Header="分厂配置" x:Name="MenuItem分厂配置" Click="MenuItem分厂配置_Click">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="City" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="日志查看" x:Name="MenuItem日志查看" Click="MenuItem日志查看_Click">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="FlagVariant" />
Expand Down
17 changes: 16 additions & 1 deletion 软件系统客户端Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private void Window_ContentRendered(object sender, EventArgs e)
MenuItem注册账户.IsEnabled = false;
MenuItem消息发送.IsEnabled = false;
MenuItem开发中心.IsEnabled = false;
MenuItem分厂配置.IsEnabled = false;
}


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

private void MenuItem注册账户_Click(object sender, RoutedEventArgs e)
{
using (FormRegisterAccount fra = new FormRegisterAccount())
using (FormRegisterAccount fra = new FormRegisterAccount(UserClient.SystemFactories.ToArray()))
{
fra.ShowDialog();
}
Expand Down Expand Up @@ -370,6 +371,18 @@ private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
}


private void MenuItem分厂配置_Click(object sender, RoutedEventArgs e)
{
using (FormInputAndAction fiaa = new FormInputAndAction(
str => UserClient.Net_simplify_client.ReadFromServer(
CommonHeadCode.SimplifyHeadCode.上传分厂, str).IsSuccess,
JArray.FromObject(UserClient.SystemFactories).ToString(),
"请按照JSON格式更新分厂信息,然后提交:"))
{
fiaa.ShowDialog();
}
}

#endregion


Expand Down Expand Up @@ -756,5 +769,7 @@ private async void Button_Dialog_Click(object sender, RoutedEventArgs e)
await Task.Delay(2000);
DialogHostWait.IsOpen = false;
}


}
}
Loading

0 comments on commit 633f31a

Please sign in to comment.