Esempio n. 1
0
        /// <summary>
        /// 获取用户登录信息
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <UserInfo> GetLoginInfo()
        {
            var loginInfo = new List <UserInfo>();

            if (InfoFile.Exists)
            {
                XmlSerializer xml = new XmlSerializer(loginInfo.GetType());
                using (Stream s = InfoFile.OpenRead())
                {
                    loginInfo = xml.Deserialize(s) as List <UserInfo>;
                }
            }
            var tList = new ObservableCollection <UserInfo>();

            foreach (var item in loginInfo)
            {
                tList.Add(new UserInfo
                {
                    AutomaticLogon = item.AutomaticLogon,
                    RememberPwd    = item.RememberPwd,
                    UserName       = CryptInfoHelper.GetDecrypte(item.UserName),
                    UserPwd        = CryptInfoHelper.GetDecrypte(item.UserPwd),
                    Tid            = item.Tid
                });
            }
            return(tList);
        }
Esempio n. 2
0
        /// <summary>
        /// 生成Xml文件
        /// </summary>
        /// <param name="loginInfo"></param>
        private void Create_Xml(List <UserInfo> loginInfo)
        {
            var tList = new List <UserInfo>();

            foreach (var item in loginInfo)
            {
                tList.Add(new UserInfo
                {
                    AutomaticLogon = item.AutomaticLogon,
                    RememberPwd    = item.RememberPwd,
                    UserName       = CryptInfoHelper.GetEncrypt(item.UserName),
                    UserPwd        = CryptInfoHelper.GetEncrypt(item.UserPwd),
                    Tid            = item.Tid
                });
            }
            XmlSerializer xmls = new XmlSerializer(tList.GetType());

            if (InfoFile.Exists)
            {
                InfoFile.Delete();
            }
            using (Stream s = InfoFile.OpenWrite())
            {
                xmls.Serialize(s, tList);
                //s.Close();
            }
        }
Esempio n. 3
0
 public FinanceResponse ChangePassword(UserChangePasswordRequest request)
 {
     service.ChagePassword(request.Id,
                           CryptInfoHelper.MD5Encode(CryptInfoHelper.GetDecrypte(request.OldPwd)),
                           CryptInfoHelper.MD5Encode(CryptInfoHelper.GetDecrypte(request.NewPwd)));
     return(CreateResponse(FinanceResult.SUCCESS));
 }
Esempio n. 4
0
 public void ChangePassword(string oldpwd, string newpwd)
 {
     Execute(new UserChangePasswordRequest {
         Id     = DataFactory.Instance.GetCacheHashtable().Get(CacheHashkey.UserId),
         OldPwd = CryptInfoHelper.GetEncrypt(oldpwd),
         NewPwd = CryptInfoHelper.GetEncrypt(newpwd)
     });
 }
Esempio n. 5
0
        public long Save(long id, string userName, string password)
        {
            var rsp = Execute(new UserSaveRequest {
                Id = id, UserName = userName, PassWord = CryptInfoHelper.GetEncrypt(password)
            });

            return(rsp.id);
        }
Esempio n. 6
0
 public static bool Verification(string no, string pwd)
 {
     pwd = CryptInfoHelper.MD5Encode(pwd);
     if (DBHelper.DefaultInstance.Exist(string.Format("select 1 from _AccountUser where _no = '{0}' and _pwd = '{1}'", no, pwd)))
     {
         return(true);
     }
     return(false);
 }
Esempio n. 7
0
        public void Login(long tid, string userName, string password)
        {
            UserRequest request = new UserRequest();

            request.UserName = userName;
            request.PassWord = CryptInfoHelper.GetEncrypt(password);
            request.Tid      = tid;
            var rsp = Execute(request);

            DataFactory.Instance.GetCacheHashtable().Set(CacheHashkey.UserId, rsp.UserId);
            DataFactory.Instance.GetCacheHashtable().Set(CacheHashkey.UserName, rsp.UserName);
            DataFactory.Instance.GetCacheHashtable().Set(CacheHashkey.Token, rsp.Token);
        }
Esempio n. 8
0
        public IdResponse Save(UserSaveRequest request)
        {
            var id       = request.Id;
            var userName = request.UserName;
            var password = CryptInfoHelper.GetDecrypte(request.PassWord);

            password = CryptInfoHelper.MD5Encode(password);
            if (id == 0)
            {
                service.AddUser(userName, password);
            }
            else
            {
                service.ModifyUser(id, userName, password);
            }

            return(new IdResponse {
                id = id
            });
        }
Esempio n. 9
0
        public static void AddUser(string no, string name, string pwd)
        {
            if (DBHelper.DefaultInstance.Exist(string.Format("select 1 from _AccountUser where _no = '{0}'", no)))
            {
                throw new FinanceException(FinanceResult.RECORD_EXIST);
            }
            pwd = CryptInfoHelper.MD5Encode(pwd);
            long id    = 1;
            var  maxId = DBHelper.DefaultInstance.ExecuteScalar("select max(_id) from _AccountUser");

            if (maxId != null)
            {
                if (long.TryParse(maxId.ToString(), out id))
                {
                    id++;
                }
            }
            DBHelper.DefaultInstance.ExecuteSql(string.Format(@"INSERT INTO [_AccountUser]([_id],[_no],[_name],[_pwd],[_lastLoginTime])  
VALUES({0},'{1}','{2}','{3}', GETDATE())", id, no, name, pwd));
        }
Esempio n. 10
0
        public FinanceResponse Login(UserRequest request)
        {
            long userId   = 0;
            var  userName = request.UserName;
            var  password = CryptInfoHelper.GetDecrypte(request.PassWord);

            password = CryptInfoHelper.MD5Encode(password);

            userId = service.UserVerification(userName, password);
            if (userId == 0)
            {
                throw new FinanceException(FinanceResult.AUTHENTICATION_ERROR);
            }

            var tid = request.Tid;

            var token = OAuth2Handler.CreateToken(userId, userName, tid, DateTime.Now);

            return(new UserResponse {
                UserId = userId, UserName = userName, Token = token
            });
        }
Esempio n. 11
0
 public static void ChagePwd(string no, string pwd)
 {
     pwd = CryptInfoHelper.MD5Encode(pwd);
     DBHelper.DefaultInstance.ExecuteSql(string.Format("update _AccountUser set _pwd = '{1}' where _no = '{0}'", no, pwd));
 }