|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using BPA.Message;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace FryPot_DosingSystem.Model
- {
- internal class LoginInfoConfig
- {
- private volatile static LoginInfoConfig _Instance;
- public static LoginInfoConfig GetInstance => _Instance ?? (_Instance = new LoginInfoConfig());
- private LoginInfoConfig() { }
-
-
- public void Init()
- {
- if (File.Exists("LoginUp.hbl"))
- {
- var result = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
- if (result == null || (result != null && result.userInfos.Count <= 0))//无用户登陆相关信息
- {
-
- }
- else
- {
- Global.userManager = result;
- }
- }
- else
- {
- AddData();
- }
- }
-
- private void AddData()
- {
- Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.管理员, UserName = "admin", Password = "123456",UserId="123" });
- //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.操作员, UserName = "czy", Password = "123456" });
- //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.观察员, UserName = "gcy", Password = "123456" });
- //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.技术员, UserName = "jsy", Password = "123456" });
- File.WriteAllText("LoginUp.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
- }
- }
- }
|