|
- using BPA.Message;
- using BPASmartClient.CustomResource.Pages.Enums;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.CustomResource.Pages.Model
- {
- public class Config
- {
- private volatile static Config _Instance;
- public static Config GetInstance => _Instance ?? (_Instance = new Config());
- private Config() { }
-
- public void Init()
- {
- if (File.Exists("up.hbl"))
- {
- var result = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt());
- if (result == null || (result != null && result.userInfos.Count <= 0))
- {
- AddData();
- }
- else
- {
- Global.userManager = result;
- }
- }
- else
- {
- AddData();
- }
- }
-
- private void AddData()
- {
- Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.管理员, UserName = "admin", Password = "admin" });
- Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" });
- Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" });
- Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" });
- SaveUser();
- }
-
- public void SaveUser()
- {
- File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
- }
- }
- }
|