/// <summary>
        /// 获取临时用户登录Passport
        /// </summary>
        /// <returns></returns>
        protected static JObject GetTempUser()
        {
            var tempUser = CachingHelper <HttpRuntimeCaching> .Get <JObject>(KeyModel.Cache.DataCenterTempUser);

            if (VerifyHelper.IsEmpty(tempUser))
            {
                var tempUserAccount = StringHelper.Get(DataCenterConfig.GetValue(KeyModel.Config.DataCenter.KeyApiTempUser)).Split('|');
                if (VerifyHelper.IsEmpty(tempUserAccount))
                {
                    throw new DefaultException("数据中心TempUser配置错误");
                }

                var data = new JObject();
                data["AppId"]    = DataCenterConfig.GetValue(KeyModel.Config.DataCenter.KeyAppId);
                data["ClientId"] = DataCenterConfig.GetValue(KeyModel.Config.DataCenter.KeyClientId);
                data["Version"]  = DataCenterConfig.GetValue(KeyModel.Config.DataCenter.KeyVersion);
                data["ip"]       = BrowserHelper.GetClientIP();
                data["Account"]  = tempUserAccount.Length > 0 ? tempUserAccount[0] : "";
                data["Password"] = tempUserAccount.Length > 1 ? tempUserAccount[1] : "";

                var result = Request(DataCenterConfig.GetApiUrl(KeyModel.Config.DataCenter.KeyAccountLogin), JsonHelper.Serialize(data), resultKey: null, errorKey: null);
                if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功) && !VerifyHelper.IsEmpty(result.Obj))
                {
                    tempUser = result.Obj;
                }
            }
            return(VerifyHelper.IsEmpty(tempUser) ? new JObject() : tempUser);
        }
示例#2
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="mobile">手机号</param>
        /// <param name="content">消息内容</param>
        /// <param name="taskId">发送任务Id</param>
        /// <returns></returns>
        public bool SendSms(string mobile, string content, out Guid taskId)
        {
            if (VerifyHelper.IsEmpty(mobile) || VerifyHelper.IsEmpty(content))
            {
                throw new DefaultException(EnumResultCode.参数错误, "mobile", "content");
            }


            taskId = Guid.Empty;
            var model = new
            {
                Mobile  = mobile,
                Content = content
            };
            var result = DataCenterHelper.Post(DataCenterConfig.GetApiUrl(KeyModel.Config.DataCenter.KeySmsSend), model);

            if (result.Code == EnumHelper.GetValue(EnumResultCode.操作成功))
            {
                return(true);
            }
            return(false);
        }