/// <summary> /// 获取渠道及状态 /// </summary> /// <param name="request"></param> /// <param name="pairs"></param> /// <returns></returns> public GetSingelChannelStatusResponse GetChannelStatusByUkeyId(GetChannelStatusByUkeyIdRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetSingelChannelStatusResponse response = new GetSingelChannelStatusResponse(); try { //参数校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } string url = request.Url;//mac地址和url前端判断 bx_agent_ukey agentukey = new bx_agent_ukey(); if (request.IsId == 1) { agentukey = _agentUKeyRepository.GetModel(request.UkeyId); if (agentukey == null || agentukey.id == 0) { response.Status = HttpStatusCode.Forbidden; return(response); } if (agentukey != null && agentukey.isurl.HasValue) { url = agentukey.isurl == 1 ? agentukey.url : agentukey.macurl; } } //取缓存渠道模型 AgentCacheChannelModel channelmodel = new AgentCacheChannelModel(); channelmodel = _channelModelMapRedisService.GetAgentCacheChannel(url); //判断是否有值 if (channelmodel != null)//&& channelmodel.ChannelId!=0) { //如果修改成功,则保存用户名 response.Status = HttpStatusCode.OK; response.CacheChannel = channelmodel; } else { //修改失败 response.ErrCode = 0; response.ErrMsg = "获取信息失败"; } } catch (Exception ex) { response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取渠道及状态请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",返回对象信息:" + request.ToJson()); } return(response); }
public BaseResponse EditAgentUKey(EditAgentUKeyRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { BaseResponse response = new BaseResponse(); try { IBxAgent agentModel = GetAgentModelFactory(request.Agent); if (!agentModel.AgentCanUse()) { response.Status = HttpStatusCode.Forbidden; return(response); } if (request.ReqSource == 1) {//对外的接口才做这一层校验 var validateUrl = string.Format("UserCode={0}&UkeyId={1}&OldPassWord={2}&NewPassWord={3}&Agent={4}", request.UserCode, request.UkeyId, request.OldPassWord, request.NewPassWord, request.Agent); if (!ValidatePostReqest(validateUrl, agentModel.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; return(response); } } //查询ukey信息 var ukeyModel = _iagentAgentUKeyRepository.GetModel(request.UkeyId); if (ukeyModel == null) { response.ErrCode = -1; response.ErrMsg = "未查到Ukey信息"; return(response); } //请求中心修改密码接口 string strUrl = string.Format("{0}/api/ChangePassWord/ChangePwd", _baoxianCenter); string oldPwd = request.ReqSource == 1 ? request.OldPassWord : string.Empty; var objPost = new { UserCode = request.UserCode, UkeyId = request.UkeyId, OldPassWord = oldPwd, NewPassWord = request.NewPassWord }; StringBuilder postData = new StringBuilder(); postData.Append("UserCode=").Append(request.UserCode) .Append("&UkeyId=").Append(request.UkeyId) .Append("&OldPassWord="******"&NewPassWord="******"&ReqSource=").Append(request.ReqSource); string result = string.Empty; int i = HttpWebAsk.Post(strUrl, postData.ToString(), out result); logInfo.Info("调用中心修改密码接口Url:" + strUrl + ";请求参数为:" + objPost.ToJson() + ";返回结果为:" + result); if (!string.IsNullOrWhiteSpace(result)) { var ret = result.FromJson <UKeyEdit>(); if (ret.ErrCode == 0) {//修改成功 response.Status = HttpStatusCode.OK; //如果修改成功,则保存用户名 if (string.IsNullOrEmpty(ukeyModel.InsuranceUserName)) { ukeyModel.InsuranceUserName = request.UserCode; int u = _iagentAgentUKeyRepository.UpdateModel(ukeyModel); logInfo.Info(string.Format("修改保司密码成功,数据库修改{0}条记录。", u)); } } else { //修改失败 response.ErrCode = -1; response.ErrMsg = ret.ErrMsg; } } } catch (Exception ex) { response = new BaseResponse(); response.Status = HttpStatusCode.ExpectationFailed; logError.Info("修改保司密码请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",返回对象信息:" + request.ToJson()); } return(response); }