using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Drawing; namespace HDL_ON { [System.Serializable] public class UserInfo { /// /// 用户名称 /// public string userName = ""; /// /// 用户 /// public string accountString = ""; /// /// 用户密码 /// public string password = ""; /// /// 用户手机号码 /// public string userMobileInfo = ""; /// /// 用户邮箱信息 /// public string userEmailInfo = ""; /// /// 用户ID /// public int 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 int accountType = 0; public int masterID = 0; public string loginTokenString { get { var result = Encoding.UTF8.GetBytes(password); var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); var output = md5.ComputeHash(result); var md5Password = BitConverter.ToString(output).Replace("-", ""); var account_md5Pssword = accountString + ":" + md5Password; var tokenBytes = Encoding.UTF8.GetBytes(account_md5Pssword); return Convert.ToBase64String(tokenBytes).Replace("=", "%3D"); } } /// /// 用户住宅列表 /// public List regionList = new List(); /// /// /// 可视对讲使用的登录账号 /// public string SIP_Account; public void SaveUserInfo() { FileUtils.WriteFileByBytes("Register_File", Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); } /// /// 软件解锁界面 /// 1:启动时 /// 2:布防撤防时 /// 3:远程开锁时 /// //[Newtonsoft.Json.JsonIgnore] public List appUnlockPage = new List(); /// /// 软件解锁方式 /// 1:数字密码 /// 2:手势密码 /// 3:指纹密码 /// 4:面容ID /// public List appUnlockType = new List(); /// /// 软件解锁密码 /// //[Newtonsoft.Json.JsonIgnore] public string appUnlockPasswrod = ""; 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; } } }