Exemplo n.º 1
0
        public IEnumerable<Caller> GetCallers()
        {
            var callerList = new List<Caller>();
            string query = string.Format(@"SELECT  ID
                                                  ,CallerID
                                                  ,PrivateKey
                                                  ,UserPlatform
                                                  ,CallerGroup
                                                  ,Src
                                                  ,OnlineSrc
                                                  ,UserTokenValidTime
                                                  ,SupportSrcsForQueryOrderList
                                                  ,OperatorID
                                                  ,SupportRcpTypesForBooking
                                                  ,CallerTypeOfCRM
                                                  ,IsGzip
                                                  ,CreateTime
                                                  ,ModifyTime
                                                  ,IsDeleted
                                                  ,CallerPoint
                                                  ,IsTrusted
                                                  ,Invalid
                                                  ,MaxPageSize
                                              FROM Caller with(nolock)");

            DbCommand cmd = DB.GetSqlStringCommand(query);
            var ds = DB.ExecuteDataSet(cmd);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    var callerInfo = new Caller();
                    callerInfo.ID = Convert.ToInt32(row["ID"]);
                    callerInfo.CallerID = row["CallerID"].ToString();
                    callerInfo.PrivateKey = row["PrivateKey"].ToString();
                    callerInfo.UserPlatform = row["UserPlatform"].ToString();
                    callerInfo.CallerGroup = Convert.ToInt32(row["CallerGroup"]);
                    callerInfo.Src = Convert.ToInt32(row["Src"]);
                    callerInfo.OnlineSrc = row["OnlineSrc"].ToString();
                    callerInfo.UserTokenValidTime = Convert.ToInt32(row["UserTokenValidTime"]);
                    callerInfo.SupportSrcsForQueryOrderList = row["SupportSrcsForQueryOrderList"].ToString();
                    callerInfo.OperatorID = row["OperatorID"].ToString();
                    callerInfo.SupportRcpTypesForBooking = row["SupportRcpTypesForBooking"].ToString();
                    callerInfo.CallerTypeOfCRM = Convert.ToInt32(row["CallerTypeOfCRM"]);
                    callerInfo.IsGzip = Convert.ToBoolean(row["IsGzip"]);
                    callerInfo.CreateTime = Convert.ToDateTime(row["CreateTime"]);
                    callerInfo.ModifyTime = Convert.ToDateTime(row["ModifyTime"]);
                    callerInfo.IsDeleted = Convert.ToBoolean(row["IsDeleted"]);
                    callerInfo.CallerPoint = Convert.ToInt32(row["CallerPoint"]);
                    callerInfo.IsTrusted = Convert.ToBoolean(row["IsTrusted"]);
                    callerInfo.Invalid = Convert.ToBoolean(row["Invalid"]);
                    callerInfo.MaxPageSize = Convert.ToInt32(row["MaxPageSize"]);
                    callerList.Add(callerInfo);
                }
            }

            return callerList;
        }
Exemplo n.º 2
0
        public bool Execute(string pName,
            string pPassword,
            Caller pCaller,
            DateTime pLoginTime,
            ref Member pMemberInfo,
            ref string pErrorMsg,
            ref DateTime ValidTime,
            ref string pAccessToken)
        {
            if ((DateTime.Now - pLoginTime).TotalMinutes >= 5)
            {
                pErrorMsg = "无效请求";
                return false;
            }

            #region 获取登陆信息
            int result = 0;
            string extCardNo = null;
            string vno = null;
            PersonMember person = null;
            pErrorMsg = string.Empty;

            if (!CallLoginCheck(pName, pPassword, ref pErrorMsg, ref result, ref person, ref vno, ref extCardNo)) return false;

            try
            {
                pMemberInfo = ConvertToMemberInfo(person, vno);
            }
            catch (Exception exp)
            {
                HZLogger.Error(exp);
                pErrorMsg = "用户名或密码无效";
                return false;
            }

            pMemberInfo.DefaultVCardNo = vno;
            pMemberInfo.DefaultExtCardNo = extCardNo;
            if (pMemberInfo.MemberLevelID == "P") pMemberInfo.CompanyMemberType = (int)CompanyMemberType.NoSet;
            else pMemberInfo.CompanyMemberType = result == 2 ? (int)CompanyMemberType.User : (int)CompanyMemberType.Admin;
            #endregion

            #region 缓存认证信息至redis
            var verifyInfo = new VerifyInfo();
            verifyInfo.VerifiedMember = pMemberInfo;
            verifyInfo.Caller = pCaller.CallerID;
            verifyInfo.PrivateKey = pCaller.PrivateKey;
            verifyInfo.RefreshToken = string.Empty;
            verifyInfo.ValidMinutes = pCaller.UserTokenValidTime;
            verifyInfo.ValidDate = DateTime.Now.AddSeconds(verifyInfo.ValidMinutes);
            ValidTime = verifyInfo.ValidDate;


            StatusCode status = _verifyService.SetVerifyInfo(verifyInfo, pLoginTime);
            if (status.Code == (int)VerifyStatus.Success)
            {
                pAccessToken = verifyInfo.AccessToken;
                return true;
            }
            else
            {
                pErrorMsg = status.Message;
                return false;
            }
            #endregion
        }