Esempio n. 1
0
        /// <summary>
        /// 认证账户
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public Result RequireAccount(long phone)
        {
            Result result = new Result()
            {
                Status     = true,
                Message    = "验证账户成功",
                StatusCode = "RA000"
            };

            try
            {
                //更改数据库
                if (DBConnectionManager.Instance.Writer.Update(new AccountRequireSpefication(true, phone).Satifasy(), null))
                {
                    IList <AccountInfo> accountlist = DBConnectionManager.Instance.Reader.Select <AccountInfo>(new AccountSelectSpefication(0, phone.ToString()).Satifasy());
                    if (accountlist != null && accountlist.Count > 0)
                    {
                        IAccountInfoCache   service       = ServiceObjectContainer.Get <IAccountInfoCache>();
                        IOnlineAccountCache onlineservice = ServiceObjectContainer.Get <IOnlineAccountCache>();

                        //同步缓存信息
                        service.SaveInfo(accountlist[0]);
                        onlineservice.SaveInfo(accountlist[0].Copy <OnlineAccountInfo>());
                    }
                    DBConnectionManager.Instance.Writer.Commit();
                }
                else
                {
                    result.Status     = false;
                    result.Message    = "验证账户失败";
                    result.StatusCode = "RA001";
                }
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Message    = string.Format("验证账户出错/r/n {0}", ex.Message);
                result.StatusCode = "EX000";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:RequireAccount() .AccountService"), LogType.ErrorLog);
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 更改背景图
        /// </summary>
        /// <param name="backCoverbase64str"></param>
        /// <param name="account"></param>
        /// <returns></returns>
        public Result UpdateBackCover(string backCoverbase64str, string account)
        {
            Result result = new Result()
            {
                Status     = true,
                Message    = "更改背景图成功",
                StatusCode = "UB001"
            };

            try
            {
                result.Status = DBConnectionManager.Instance.Writer.Update(new AccountUpdateImageSpefication(backCoverbase64str, account, 1).Satifasy());
                if (result.Status)
                {
                    //更新缓存
                    IAccountInfoCache   service       = ServiceObjectContainer.Get <IAccountInfoCache>();
                    IOnlineAccountCache onlineservice = ServiceObjectContainer.Get <IOnlineAccountCache>();

                    AccountInfo accountcache = service.SearchInfoByKey(string.Format("DB_AI_{0}", account));
                    if (accountcache != null)
                    {
                        accountcache.BackCorver = backCoverbase64str;
                        //保存
                        service.SaveInfo(accountcache);
                        onlineservice.SaveInfo(accountcache.Copy <OnlineAccountInfo>());
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Message    = "修改背景图出错" + ex.Message;
                result.StatusCode = "UB000";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:UpdateBackCover() .AccountService"), LogType.ErrorLog);
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="signInCode"></param>
        /// <param name="securityCode"></param>
        /// <returns></returns>
        public Result <Account> SignIn(string signInCode, string securityCode)
        {
            Result <Account> result = new Result <Account>()
            {
                Status = false
            };

            try
            {
                //1.检查是否已经登录
                IOnlineAccountCache service        = ServiceObjectContainer.Get <IOnlineAccountCache>();
                IAccountInfoCache   accountservice = ServiceObjectContainer.Get <IAccountInfoCache>();

                string            phonekey        = string.Format("OnlineAI_{0}_*", signInCode);
                string            emailkey        = string.Format("OnlineAI_*_{0}", signInCode);
                string            securityCodeMD5 = MD5Engine.ToMD5String(securityCode);
                OnlineAccountInfo onlineinfo      = null;

                onlineinfo = service.SearchInfoByKey(phonekey);

                if (onlineinfo == null)
                {
                    onlineinfo = service.SearchInfoByKey(emailkey);
                }

                if (onlineinfo == null)
                {
                    //2.直接从数据库拿数据
                    IList <AccountInfo> inforesult = DBConnectionManager.Instance.Reader.Select <AccountInfo>(new AccountSelectSpefication(3, signInCode, securityCodeMD5).Satifasy());
                    if (inforesult != null && inforesult.Count > 0)
                    {
                        result.Status = true;
                        result.Data   = inforesult[0].Copy <Account>();

                        //保存到缓存
                        service.SaveInfo(inforesult[0].Copy <OnlineAccountInfo>());
                        accountservice.SaveInfo(inforesult[0]);
                    }
                    else
                    {
                        result.Message    = "用户名或密码错误";
                        result.StatusCode = "LG000";
                    }
                }
                else
                {
                    //校验密码
                    if (onlineinfo.SecurityCode != securityCodeMD5)
                    {
                        result.Message    = "密码错误";
                        result.StatusCode = "LG000";
                        result.Data       = null;
                    }
                    else
                    {
                        //返回结果
                        result.Status = true;
                        result.Data   = onlineinfo.Copy <Account>();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Status     = false;
                result.Data       = null;
                result.Message    = ex.Message;
                result.StatusCode = "EX000";

                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SignIn() .AccountService"), LogType.ErrorLog);
            }
            return(result);
        }