using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Drawing; using HDL_ON.DAL; using HDL_ON.DAL.Server; namespace HDL_ON { [System.Serializable] public class UserInfo { public static readonly string ConfigFile = "UserInfo_File"; /// /// 通用方法 /// private static UserInfo m_Current = null; /// /// 通用方法 /// public static UserInfo Current { get { if (m_Current == null) { try { UserInfo temp = Newtonsoft.Json.JsonConvert.DeserializeObject(System.Text.Encoding.UTF8.GetString(FileUtils.ReadFile(ConfigFile))); if (temp == null) { m_Current = new UserInfo() { }; Utlis.WriteLine("UserInfo null"); } else { m_Current = temp; Utlis.WriteLine("UserInfo Current"); } } catch { m_Current = new UserInfo() { }; Utlis.WriteLine("UserInfo null"); } } return m_Current; } } #region 新增保存参数 /// /// 账号注册服务器信息 /// public string RequestHttpsHost = "https://china.hdlcontrol.com"; /// /// /// public GlobalRegionListRes GlobalRegion; /// /// 是否同意协议 /// public bool isAgreePrivacyPolicy; /// /// 忽略更新的版本号 /// public string IgnoreUpdateVersion = string.Empty; #endregion /// /// 用户名称 /// public string userName = ""; /// /// 用户 /// public string accountString = ""; ///// ///// 用户密码 ///// //public string password = ""; //string aesPassword = ""; ///// ///// 用户密码 ///// //public string password //{ // get // { // return Shared.Securitys.EncryptionService.AesDecryptTopic(aesPassword, "85521566HDLONPRO"); // } // set // { // aesPassword = Shared.Securitys.EncryptionService.AesEncryptTopic(value, "85521566HDLONPRO"); // } //} /// /// 用户手机号码 /// public string userMobileInfo = ""; /// /// 用户邮箱信息 /// public string userEmailInfo = ""; /// /// 用户ID /// public string ID; /// /// 用户选择显示的语言 /// public string language = "Chinese"; /// /// 用户区域 /// public string areaCode = "86"; /// /// 用户头像图片 /// public string headImagePagePath = "LoginIcon/2.png"; /// /// 用户头像byte数据 /// public byte[] headImagePageBytes = null; /// /// 上一次登录时间 /// public DateTime lastTime = DateTime.MinValue; /// /// 是否是登录状态 /// public bool IsLogin { get { return (DateTime.Now - lastTime).TotalDays < 7; } } /// /// /// public string loginTokenString; /// /// /// public string refreshToken; /// /// UserType B端账号 C端账号 /// public string userType = "USER_C"; /// /// 用户住宅列表 /// public List regionList = new List(); public void SaveUserInfo() { FileUtils.WriteFileByBytes(ConfigFile, Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); } private byte[] convertByte(Image img) { MemoryStream ms = new MemoryStream(); img.Save(ms, img.RawFormat); //byte[] bytes = new byte[ms.Length]; //ms.Read(bytes, 0, Convert.ToInt32(ms.Length)); //以上两句改成下面两句 byte[] bytes = ms.ToArray(); ms.Close(); return bytes; } private Image convertImg(byte[] datas) { MemoryStream ms = new MemoryStream(datas); Image img = Image.FromStream(ms, true);//在这里出错 //流用完要及时关闭 ms.Close(); return img; } } }