终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

49 řádky
1.7 KiB

  1. using BPA.Message;
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace FryPot_DosingSystem.Model
  10. {
  11. internal class LoginInfoConfig
  12. {
  13. private volatile static LoginInfoConfig _Instance;
  14. public static LoginInfoConfig GetInstance => _Instance ?? (_Instance = new LoginInfoConfig());
  15. private LoginInfoConfig() { }
  16. public void Init()
  17. {
  18. if (File.Exists("LoginUp.hbl"))
  19. {
  20. var result = JsonConvert.DeserializeObject<UserManage>(File.ReadAllText("LoginUp.hbl").AESDecrypt());
  21. if (result == null || (result != null && result.userInfos.Count <= 0))//无用户登陆相关信息
  22. {
  23. }
  24. else
  25. {
  26. Global.userManager = result;
  27. }
  28. }
  29. else
  30. {
  31. AddData();
  32. }
  33. }
  34. private void AddData()
  35. {
  36. Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.管理员, UserName = "admin", Password = "123456",UserId="123" });
  37. //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.操作员, UserName = "czy", Password = "123456" });
  38. //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.观察员, UserName = "gcy", Password = "123456" });
  39. //Global.userManager.userInfos.Add(new UserInfo() { Authority = Authority.技术员, UserName = "jsy", Password = "123456" });
  40. File.WriteAllText("LoginUp.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
  41. }
  42. }
  43. }