Ejemplo n.º 1
0
        private static TxProvider BuildProvider(string userId, string pwd)
        {
            //登录
            String logErrorReason        = null;
            UserLoginSessionInfo session = null;

            if (UserLogin(userId, pwd, out session, out logErrorReason))
            {
                var p   = new TxProvider(session.token);
                var key = $"TxProvider_{userId}";
                if (Common.MemcachedHelper.Instance.Get(key) == null)
                {
                    Common.MemcachedHelper.Instance.Add(key, session);
                }
                else
                {
                    Common.MemcachedHelper.Instance.Remove(key);
                    Common.MemcachedHelper.Instance.Add(key, session);
                }

                return(p);
            }
            else
            {
                throw new BusinessException($"{userId}登录消息系统失败。(原因:{logErrorReason})");
            }
        }
Ejemplo n.º 2
0
        private static bool UserLogin(string userId, string pwd, out UserLoginSessionInfo session, out string logErrorReason)
        {
            logErrorReason = String.Empty;
            session        = null;

            try
            {
                var param = new Dictionary <string, string>();
                param.Add("userid", userId);
                param.Add("pwd", pwd);
                param.Add("clientFlag", Entity.ConstDefined.CLIENT_FLAG_SERVER);

                session = Common.WebApiHelper.Post <UserLoginSessionInfo>(GetIMApiServer() + "/session/login", param.AsHttpParams());

                return(true);
            }
            catch (BusinessException ex)
            {
                logErrorReason = ex.Message;
                return(false);
            }
        }