public int NotifyMessageCenter(long msgId, string msgUrl, int status) { log.Info(string.Format("消息发送NotifyMessageCenter: msgId:{0},msgUrl:{1},status:{2}", msgId, msgUrl, status)); string ret = string.Empty; int errCode = 0; try { HttpWebAsk.Post(msgUrl + "/UpdateMessageStatus", string.Format("msgId={0}&status={1}", msgId, (int)status), out ret); } catch (Exception) { errCode = -1; } return(errCode); }
public MessageResult SendToMessageCenter(string data, string msgUrl, string queueName = "") { MessageResult message = new MessageResult(); string url = string.Format("{0}/SetBusinessMessage", msgUrl); string postData = string.Format("data={0}&queueName={1}", data, queueName); string result; try { int ret = HttpWebAsk.Post(url, postData, out result); message = result.FromJson <MessageResult>(); log.Info(string.Format("消息发送SendToMessageCenter: data:{0},url:{1},响应结果:{2}", postData, url, result)); } catch (Exception ex) { log.Info("消息发送SendToMessageCenter: data:" + postData + ",url:" + url + "\n 异常信息:" + ex.StackTrace + " \n " + ex.Message); throw new Exception("消息发送异常", new MessageException()); } return(message); }
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); }
public SmsResultViewModel SendSms(SmsRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { var response = new SmsResultViewModel(); //参数校验 //获取顶级经纪人信息 bx_agent agentModel = _agentRepository.GetAgent(request.Agent); //获取当前经纪人信息 bx_agent curagentModel = _agentRepository.GetAgent(request.CurAgent); if (agentModel == null || curagentModel == null) { response.Status = HttpStatusCode.Forbidden; return(response); } if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; return(response); } if ((int)request.BusinessType == 3 && string.IsNullOrWhiteSpace(request.LicenseNo)) { response.Status = HttpStatusCode.UnsupportedMediaType; return(response); } bool isByTopAgent = IsPayByTopAgent(request.CurAgent); //true为走顶级代理人账户,否则走当前账户 int sendAgent = 0; //以哪个代理人id创建 int messagePayType = 0; //当前代理人是顶级代理人可以充值 if (isByTopAgent) {//顶级 sendAgent = request.Agent; messagePayType = agentModel.MessagePayType.HasValue?agentModel.MessagePayType.Value:0; } else {//当前代理 sendAgent = request.CurAgent; messagePayType = curagentModel.MessagePayType.HasValue ? curagentModel.MessagePayType.Value : 0; } //获取代理人的短信信息 var smsAcount = _smsContentRepository.Find(sendAgent); if (smsAcount == null) { response.MessagePayType = messagePayType; response.Status = HttpStatusCode.NoContent; return(response); } string posturl = string.Format("{0}/{1}", _smsCenter, _smsCenterSendSmsMethod); string postData = string.Format("account={0}&password={1}&mobile={2}&smscontent={3}&businessType={4}", smsAcount.sms_account, smsAcount.sms_password, request.Mobile, request.SmsContent, (int)request.BusinessType); string result; try { int ret = HttpWebAsk.Post(posturl, postData, out result); //result = "{\"ResponseType\":\"SubmitSms\",\"TradeTime\":\"2016-05-19 19:35:03\",\"ResultCode\":0,\"Message\":\"提交成功!\"}"; if (!string.IsNullOrEmpty(result)) { var smsResult = result.FromJson <SmsResultModel>(); if (smsResult.ResultCode == 0) { //调取后台接口,将短信发送内容保存到bx_sms_account_content string getData = string.Format("agent_id={0}&sent_mobile={1}&content={2}&agent_name={3}&sent_type={4}&&businessType={5}&license_no={6}", sendAgent, request.Mobile, request.SmsContent, curagentModel.AgentName, request.SentType, (int)request.BusinessType, request.LicenseNo); string getUrl = _smsSqlInterfaceUrl + getData; logInfo.Info(string.Format("短信内容入库请求串:{0}", getUrl)); //string getResult = HttpWebAsk.HttpGet(getUrl); string insertsms = string.Empty; int insertret = HttpWebAsk.Post(_smsSqlInterfaceUrl, getData, out insertsms); logInfo.Info(string.Format("短信内容入库返回结果:{0}", insertsms)); response.BusinessStatus = 1; response.MessagePayType = messagePayType; response.StatusMessage = "短信发送成功"; response.SmsResultModel = smsResult; } else { response.BusinessStatus = 0; response.MessagePayType = messagePayType; response.StatusMessage = smsResult.Message; } } else { response.BusinessStatus = 0; response.MessagePayType = messagePayType; response.StatusMessage = "短信发送失败"; } } catch (Exception ex) { response = new SmsResultViewModel(); response.MessagePayType = messagePayType; response.Status = HttpStatusCode.ExpectationFailed; logError.Info("短信请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); }