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(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() {Id = Guid.NewGuid().ToString(), permission = Permission.管理员, UserName = "admin", Password = "admin" }); SaveUser(); } public void SaveUser() { File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); } public string IdProcess() { erp: string id= Guid.NewGuid().ToString(); if (Global.userManager.userInfos.Count > 0) { var res=Global.userManager.userInfos.FirstOrDefault(p => p.Id == id); if (res != null) { goto erp; } else { return id; } } return id; } } }