public void PostSubmitInfo_MessageCenterIsNull_ReturnOK() { //配置 IValidateService validateService = Substitute.For <IValidateService>(); IMessageCenter messageCenter = Substitute.For <IMessageCenter>(); IRemoveHeBaoKey removeHeBaoKey = Substitute.For <IRemoveHeBaoKey>(); IPostValidate postValidate = Substitute.For <IPostValidate>(); validateService.Validate(Arg.Any <PostSubmitInfoRequest>(), Arg.Any <IEnumerable <KeyValuePair <string, string> > >()).Returns(new BaseResponse() { Status = HttpStatusCode.OK }); postValidate.SubmitInfoValidate(Arg.Any <PostSubmitInfoRequest>()).Returns(Tuple.Create <BaseResponse, bx_userinfo, bx_submit_info>(new BaseResponse() { Status = HttpStatusCode.OK }, new bx_userinfo(), new bx_submit_info())); removeHeBaoKey.RemoveHeBao(Arg.Any <PostSubmitInfoRequest>()).Returns(x => "test-string"); messageCenter.SendToMessageCenter(Arg.Any <string>(), Arg.Any <string>()).Returns(x => null); PostSubmitInfoService postSubmitInfoService = new PostSubmitInfoService(validateService, messageCenter, removeHeBaoKey, postValidate); //操作 var result = postSubmitInfoService.PostSubmitInfo(new PostSubmitInfoRequest() { Source = 1 }, null); //断言 Assert.AreEqual(HttpStatusCode.OK, result.Status); }
/// <summary> /// 发送上传图片消息 /// </summary> /// <param name="buid"></param> /// <param name="ulImgKey"></param> private void SendMsg(long buid, string ulImgKey, int source) { CacheProvider.Remove(ulImgKey); //初始化ulImgKey缓存,标记1 ReMsg reMsg = new ReMsg { ErrCode = 1, ErrMsg = string.Empty, Version = string.Empty, VersionType = string.Empty }; CacheProvider.Set(ulImgKey, reMsg, 3600);//缓存1h //20171025改为redis保存对象 var msgBody = new { UploadType = 1,//上传图片方式,0,base64 1,url地址(20171031新增字段) B_Uid = buid, IsCloseSms = 0, NotifyCacheKey = ulImgKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Source = source }; logInfo.Info("发送的消息体:" + msgBody.ToJson()); //发送请求上传图片消息 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxPicName"]); logInfo.Info("返回:" + msgbody.ToJson()); }
/// <summary> /// 从中心获取品牌型号 /// </summary> /// <param name="carVin"></param> /// <param name="moldName"></param> /// <param name="agent">顶级代理Id</param> /// <param name="cityCode"></param> /// <returns></returns> public async Task <GetMoldNameResponse> GetMoldNameService(string carVin, string moldName, int agent, int cityCode) { GetMoldNameResponse response = new GetMoldNameResponse(); if (string.IsNullOrWhiteSpace(carVin) || carVin.Length <= 5 || string.IsNullOrWhiteSpace(moldName)) { response.MoldName = string.Empty; response.BusinessMessage = "不符合查询条件,不返回对应的品牌型号"; response.BusinessStatus = -10000; return(response); } var frontCarVin = carVin.ToUpper().Substring(0, 5); if (carVin.StartsWith("L") || moldName.ToUpper().IndexOf(frontCarVin, System.StringComparison.Ordinal) < 0) { response.MoldName = string.Empty; response.BusinessMessage = "不符合查询条件,不返回对应的品牌型号"; response.BusinessStatus = -10000; return(response); } string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(carVin); var xuBaoKey = string.Format("{0}-ModelName-key", xuBaoCacheKey); CacheProvider.Remove(xuBaoKey); var msgBody = new { Agent = agent,//顶级 CarVin = carVin, cityId = cityCode, NotifyCacheKey = xuBaoCacheKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; //发送续保信息 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["FindMoldName"]); try { var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(0.5)); } } } if (cacheKey == null) { response.BusinessStatus = -1;//超时 response.BusinessMessage = "请求超时"; response.MoldName = string.Empty; } else { WaPaAutoModelResponse model = new WaPaAutoModelResponse(); string itemsCache = string.Format("{0}-ModelName", xuBaoCacheKey); if (cacheKey == "1") { var temp = CacheProvider.Get <string>(itemsCache); model = temp.FromJson <WaPaAutoModelResponse>(); if (model.ErrCode == 0) { response.MoldName = model.AutoModeType != null ? model.AutoModeType.autoModelName : string.Empty; if (model.AutoModeType == null) { response.BusinessMessage = "没有取到对应的品牌型号"; } else { response.BusinessMessage = "获取成功"; } } else { response.MoldName = string.Empty; response.BusinessMessage = "没有取到对应的品牌型号"; response.BusinessStatus = -10002; } } else { response.MoldName = string.Empty; response.BusinessMessage = "没有取到对应的品牌型号"; response.BusinessStatus = -10002; } } } catch (Exception ex) { response = new GetMoldNameResponse(); response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取车型请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(response); #region 以前的逻辑 //if (!string.IsNullOrWhiteSpace(carVin) && carVin.Length > 5) //{ // var frontCarVin = carVin.Substring(0, 5); // if (!carVin.StartsWith("L") && moldName.ToUpper().IndexOf(frontCarVin, System.StringComparison.Ordinal) >= 0) // { // using (HttpClient client = new HttpClient()) // { // client.BaseAddress = new Uri(_url); // var getUrl = string.Format("api/taipingyang/gettaipycarinfoby?carvin={0}", carVin); // HttpResponseMessage responseVin = client.GetAsync(getUrl).Result; // var resultVin = responseVin.Content.ReadAsStringAsync().Result; // var carinfo = resultVin.FromJson<WaGetTaiPyCarInfoResponse>(); // if (carinfo != null && carinfo.CarInfo != null) // { // return carinfo.CarInfo.moldName; // } // } // } //} #endregion }
public async Task <GetFloatingInfoResponse> GetFloatingInfo(GetFloatingInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetFloatingInfoResponse response = new GetFloatingInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } //校验:2报价基础信息 UserInfoValidateRequest validateRequest = new UserInfoValidateRequest() { LicenseNo = request.LicenseNo, CustKey = request.CustKey, ChildAgent = request.ChildAgent == 0 ? request.Agent : request.ChildAgent, RenewalCarType = request.RenewalCarType }; //校验2 var validateResult = _userInfoValidateService.UserInfoValidate(validateRequest); if (validateResult.Item1.Status == HttpStatusCode.NotAcceptable) { response.Status = HttpStatusCode.NotAcceptable; return(response); } //校验:4是否存在核保记录 bx_submit_info submitInfo = _submitInfoRepository.GetSubmitInfo(validateResult.Item2.Id, SourceGroupAlgorithm.GetOldSource(request.Source)); string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); string notifyCacheKey = string.Format("{0}-gzd", baojiaCacheKey); //通知中心 var msgBody = new { B_Uid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), BiztNo = submitInfo != null ? submitInfo.biz_tno : "", ForcetNo = submitInfo != null ? submitInfo.force_tno : "", NotifyCacheKey = notifyCacheKey }; //发送安心核保消息 try { string baojiaKey = string.Format("{0}-Informing", notifyCacheKey); CacheProvider.Remove(baojiaKey); var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["bxAnXinGaoZhi"]); var cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey == null) { for (int i = 0; i < 180; i++) { cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey != null) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } JSFloatingNotificationPrintListResponse jsonModel = new JSFloatingNotificationPrintListResponse(); if (!string.IsNullOrEmpty(cacheKey)) { jsonModel = cacheKey.FromJson <JSFloatingNotificationPrintListResponse>(); } response.JSFloatingNotificationPrintList = jsonModel.JSFloatingNotificationPrintListResponseMain; } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } return(response); }
public async Task <SpecialListResponse> GetSpeciaList(GetSpecialListRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { SpecialListResponse response = new SpecialListResponse(); string ukeyId; var agentConfig = _agentConfig.FindBy(request.AgentId, request.CityId).FirstOrDefault(conf => conf.source == SourceGroupAlgorithm.GetOldSource(request.Source)); if (agentConfig == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "没有找到代理人配置"; return(response); } else { ukeyId = agentConfig.ukey_id.ToString(); } bx_agent agentModel = GetAgent(request.AgentId); //参数校验 if (agentModel == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "没有找到代理人"; return(response); } if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10001; response.BusinessMessage = "参数校验失败"; return(response); } string SpecicalCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.AgentId.ToString() + request.CityId.ToString() + request.Source.ToString()); var key = string.Format("{0}-SpecialOptions-key", SpecicalCacheKey); string cacheKey = CacheProvider.Get <string>(key); if (cacheKey != null) { if (cacheKey == "1") { string listcachekey = string.Format("{0}-SpecialOptions", SpecicalCacheKey); response = CacheProvider.Get <SpecialListResponse>(listcachekey); response.Status = HttpStatusCode.OK; response.BusinessStatus = 1; response.BusinessMessage = "获取特约成功"; response.Key = listcachekey; return(response); } else { CacheProvider.Remove(key); } } object msgBody; msgBody = new { Source = SourceGroupAlgorithm.GetOldSource(request.Source), CityId = request.CityId, TopAgentId = request.AgentId, ukeyId = ukeyId, NotifyCacheKey = SpecicalCacheKey }; _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["SpecialOption"]); for (int i = 0; i < 115; i++) { cacheKey = CacheProvider.Get <string>(key); //step1val = xuBaoKey; //step1va2 = cacheKey; if (!string.IsNullOrWhiteSpace(cacheKey)) { if (cacheKey == "0" || cacheKey == "1") { break; } } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } if (cacheKey == null) { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = -10003;//缓存异常 response.BusinessMessage = "请求超时或缓存异常,请重试"; response.Key = ""; return(response); } else if (cacheKey == "0") { response.Status = HttpStatusCode.Forbidden; response.BusinessStatus = 0; response.BusinessMessage = "获取特约检索失败"; response.Key = ""; return(response); } else { string listcachekey = string.Format("{0}-SpecialOptions", SpecicalCacheKey); response = CacheProvider.Get <SpecialListResponse>(listcachekey); response.Status = HttpStatusCode.OK; response.BusinessStatus = 1; response.BusinessMessage = "获取特约成功"; response.Key = listcachekey; return(response); } }
public async Task <BaseViewModel> RecordNewCar(RecordNewCarRequest request) { int source = SourceGroupAlgorithm.GetOldSource(request.Source); bx_car_record model = _carRecordRepository.GetModel(request.CarVin, request.EngineNo); if (model != null && model.Id > 0) { if (model.RecordStatus > 0) { //如果1分钟之内提交过,则不允许再请求 return(new BaseViewModel() { BusinessStatus = -10001, StatusMessage = "该车已提交过备案,请勿重复提交!" }); } if (model.UpdateTime.Value.AddSeconds(30) > DateTime.Now) { //如果30s之内提交过,则不允许再请求 return(new BaseViewModel() { BusinessStatus = -10001, StatusMessage = "刚提交过新车备案,请稍后再试!" }); } //此处else省略是因为下面可以通用,只修改updatetime } #region 初始化字段,存数据库值 else { model = new bx_car_record(); model.CreateTime = DateTime.Now; } model.CarVin = request.CarVin; model.EngineNo = request.EngineNo; model.DriveLicenseCarTypeName = request.DriveLicenseCarTypeName; model.DriveLicenseCarTypeValue = request.DriveLicenseCarTypeValue; model.LicenseOwner = request.LicenseOwner; model.LicenseOwnerIdType = request.LicenseOwnerIdType; model.LicenseOwnerIdTypeValue = request.LicenseOwnerIdTypeValue; model.LicenseOwnerIdNo = request.LicenseOwnerIdNo; model.TonCountflag = request.TonCountflag; model.CarTonCount = request.CarTonCount; model.CarLotEquQuality = request.CarLotEquQuality; model.VehicleExhaust = request.VehicleExhaust; model.FuelType = request.FuelType; model.FuelTypeValue = request.FuelTypeValue; model.ProofType = request.ProofType; model.ProofTypeValue = request.ProofTypeValue; model.ProofNo = request.ProofNo; model.ProofTime = !string.IsNullOrWhiteSpace(request.ProofTime) ? DateTime.Parse(request.ProofTime) : DateTime.MinValue; model.CarPrice = request.CarPrice; model.VehicleYear = request.VehicleYear; model.VehicleName = request.VehicleName; model.ModelCode = request.ModelCode; model.RecordStatus = 0;//初始化时是0 model.UpdateTime = DateTime.Now; model.Source = source; int record = _carRecordRepository.AddUpdateCarRecord(model); #endregion if (record == 0) { return(new BaseViewModel() { BusinessStatus = 0, StatusMessage = "请求失败,数据未保存成功" }); } #region 给中心发消息 string xuBaoCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.CarVin); var xuBaoKey = string.Format("{0}-CarRecord", xuBaoCacheKey); CacheProvider.Remove(xuBaoKey); var msgBody = new { Source = source, //哪家渠道 ChannelId = request.ChannelId, CarVin = request.CarVin, //车架号 EngineNo = request.EngineNo, //发动机号 NotifyCacheKey = xuBaoCacheKey, RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; //发送续保信息 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxCarRecord"]); try { var cacheKey = CacheProvider.Get <string>(xuBaoKey); if (cacheKey == null) { for (int i = 0; i < 60; i++) { cacheKey = CacheProvider.Get <string>(xuBaoKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey == null) { return(new BaseViewModel() { BusinessStatus = -1, StatusMessage = "请求失败,数据与保司交互超时。" }); } else { WaBaseResponse response = new WaBaseResponse(); response = cacheKey.FromJson <WaBaseResponse>(); if (response.ErrCode == 1) { return(new BaseViewModel() { BusinessStatus = 1, StatusMessage = "请求成功" }); } else { logError.Info(string.Format("新车备案请求调用中心失败:请求参数为:{0},返回值:{1}", request.ToJson(), cacheKey)); return(new BaseViewModel() { BusinessStatus = 0, StatusMessage = response.ErrMsg }); } } } catch (Exception ex) { logError.Info("新车备案请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); return(new BaseViewModel() { BusinessStatus = -10003, StatusMessage = "请求发生异常!" }); } #endregion }
public async Task <BaseResponse> PostIndependentSubmit(PostIndependentSubmitRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetFloatingInfoResponse response = new GetFloatingInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } //校验:2报价基础信息 UserInfoValidateRequest validateRequest = new UserInfoValidateRequest() { LicenseNo = request.LicenseNo, CustKey = request.CustKey, ChildAgent = request.ChildAgent == 0 ? request.Agent : request.ChildAgent, RenewalCarType = request.RenewalCarType }; //校验2 var validateResult = _userInfoValidateService.UserInfoValidate(validateRequest); if (validateResult.Item1.Status == HttpStatusCode.NotAcceptable) { response.Status = HttpStatusCode.NotAcceptable; return(response); } //插库操作 try { bx_userinfo userinfo = validateResult.Item2; userinfo.Source = (userinfo.Source.Value | request.Source); #region 车主信息 if (!string.IsNullOrWhiteSpace(request.Mobile)) { userinfo.Mobile = request.Mobile; } if (!string.IsNullOrWhiteSpace(request.CarOwnersName)) { userinfo.LicenseOwner = request.CarOwnersName; } if (!string.IsNullOrWhiteSpace(request.IdCard)) { userinfo.IdCard = request.IdCard; } if (request.OwnerIdCardType >= 0) { userinfo.OwnerIdCardType = request.OwnerIdCardType; } #endregion #region 被保险人信息 if (!string.IsNullOrWhiteSpace(request.InsuredName)) { userinfo.InsuredName = request.InsuredName.Trim(); } if (!string.IsNullOrWhiteSpace(request.InsuredIdCard)) { userinfo.InsuredIdCard = request.InsuredIdCard.ToUpper(); //if (request.InsuredIdCard.IsValidIdCard()) //{ // request.InsuredIdType = 1; //} } if (!string.IsNullOrWhiteSpace(request.InsuredEmail)) { userinfo.InsuredEmail = request.InsuredEmail; } if (!string.IsNullOrWhiteSpace(request.InsuredMobile)) { userinfo.InsuredMobile = request.InsuredMobile.Trim(); } if (request.InsuredIdType >= 0) { userinfo.InsuredIdType = request.InsuredIdType; } userinfo.InsuredAddress = request.InsuredAddress; //userinfo.InsuredCertiStartdate = request.InsuredCertiStartdate; //userinfo.InsuredCertiEnddate = request.InsuredCertiEnddate; //userinfo.InsuredSex = request.InsuredSex; //userinfo.InsuredBirthday = request.InsuredBirthday; //userinfo.InsuredIssuer = request.InsuredAuthority; //userinfo.InsuredNation = request.InsuredNation; #endregion #region 投保人信息 if (!string.IsNullOrWhiteSpace(request.HolderEmail)) { userinfo.HolderEmail = request.HolderEmail; } if (!string.IsNullOrWhiteSpace(request.HolderName)) { userinfo.HolderName = request.HolderName.Trim(); } if (!string.IsNullOrWhiteSpace(request.HolderIdCard)) { userinfo.HolderIdCard = request.HolderIdCard.ToUpper(); //if (request.HolderIdCard.IsValidIdCard()) //{ // request.HolderIdType = 1; //} } if (!string.IsNullOrWhiteSpace(request.HolderMobile)) { userinfo.HolderMobile = request.HolderMobile.Trim(); } if (request.HolderIdType >= 0) { userinfo.HolderIdType = request.HolderIdType; } userinfo.HolderAddress = request.HolderAddress; //userinfo.HolderCertiStartdate = request.HolderCertiStartdate; //userinfo.HolderCertiEnddate = request.HolderCertiEnddate; //userinfo.HolderSex = request.HolderSex; //userinfo.HolderBirthday = request.HolderBirthday; //userinfo.HolderIssuer = request.HolderAuthority; //userinfo.HolderNation = request.HolderNation; #endregion _userInfoRepository.Update(userinfo); bx_submit_info submitinfo = _submitInfoRepository.GetSubmitInfo(validateResult.Item2.Id, SourceGroupAlgorithm.GetOldSource(request.Source)); bx_anxin_delivery oldData = _anxindeliveryRepository.Search(l => l.b_uid == validateResult.Item2.Id && l.status == 1).FirstOrDefault(); if (oldData != null && oldData.id != 0) { oldData.status = 0; oldData.updatetime = DateTime.Now; _anxindeliveryRepository.Update(oldData); } //先删除,再插入 bx_anxin_delivery model = new bx_anxin_delivery() { b_uid = validateResult.Item2.Id, signincnm = request.SignerName, //签收人姓名 signintel = request.SignerTel, //签收人手机号 sendorderaddr = request.SingerAddress, //签收人地址 zipcde = request.ZipCode, //邮政编码 sy_plytyp = request.BizPolicyType, //商业保单形式 sy_invtype = request.BizElcInvoice, //商业电子发票形式 sy_appno = submitinfo != null ? submitinfo.biz_tno : "", //request.BizNo,//商业投保单号 jq_invtype = request.ForceElcInvoice, //交强电子发票类型 jq_plytyp = request.ForcePolicyType, //交强投保单形式 jq_appno = submitinfo != null ? submitinfo.force_tno : "", //request.ForceNO,//交强投保单号 appvalidateno = request.ProductNo, //产品代码 status = 1, //删除状态标示 0标识删除 createtime = DateTime.Now, updatetime = DateTime.Now }; _anxindeliveryRepository.Insert(model); } catch (Exception ex) { } //实现 //清理缓存 string baojiaCacheKey = string.Empty; try { PostSubmitInfoRequest newrequest = new PostSubmitInfoRequest() { LicenseNo = request.LicenseNo, ChildAgent = request.ChildAgent == 0 ? request.Agent : request.ChildAgent, Agent = request.Agent, RenewalCarType = request.RenewalCarType, CustKey = request.CustKey, Source = request.Source }; baojiaCacheKey = _removeHeBaoKey.RemoveHeBao(newrequest); } catch (RedisOperateException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } //通知中心 var msgBody = new { BUid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), RedisKey = baojiaCacheKey, //20180509新增 PayFinishUrl = request.PayFinishUrl, PayCancelUrl = request.PayCancelUrl, BgRetUrl = string.IsNullOrWhiteSpace(request.BgRetUrl) ? "http://buc.91bihu.com/api/PayOut/GetAXPayBack" : request.BgRetUrl, PayErrorUrl = request.PayErrorUrl, Attach = request.Attach }; //发送安心核保消息 try { var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxAnXinHeBao"]); } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } return(response); }
public async Task <WaBxSysJyxResponse> GetAccidentList(GetAccidentListRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { WaBxSysJyxResponse response = new WaBxSysJyxResponse(); //参数校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = -1; return(response); } string SpecicalCacheKey = CommonCacheKeyFactory.CreateKeyWithLicense(request.Agent.ToString() + request.CityCode.ToString() + request.Source.ToString()); var key = string.Format("{0}-RiskOfdrive-key", SpecicalCacheKey); string cacheKey = CacheProvider.Get <string>(key); if (cacheKey != null) { if (cacheKey == "1") { string listcachekey = string.Format("{0}-RiskOfdrive", SpecicalCacheKey); response = CacheProvider.Get <WaBxSysJyxResponse>(listcachekey); //response.Status = HttpStatusCode.OK; response.ErrCode = 1; response.ErrMsg = "获取成功"; //response.Key = listcachekey; return(response); } else { CacheProvider.Remove(key); } } object msgBody; msgBody = new { Source = SourceGroupAlgorithm.GetOldSource(request.Source), CityId = request.CityCode, TopAgentId = request.Agent, NotifyCacheKey = SpecicalCacheKey }; _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["JYOption"]); for (int i = 0; i < 115; i++) { cacheKey = CacheProvider.Get <string>(key); //step1val = xuBaoKey; //step1va2 = cacheKey; if (!string.IsNullOrWhiteSpace(cacheKey)) { if (cacheKey == "0" || cacheKey == "1") { break; } } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } if (cacheKey == null) { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = -10003;//缓存异常 response.ErrMsg = "请求超时或缓存异常,请重试"; //response.Key = ""; return(response); } else if (cacheKey == "0") { //response.Status = HttpStatusCode.Forbidden; response.ErrCode = 0; response.ErrMsg = "获取特约检索失败"; //response.Key = ""; return(response); } else { string listcachekey = string.Format("{0}-RiskOfdrive", SpecicalCacheKey); response = CacheProvider.Get <WaBxSysJyxResponse>(listcachekey); //response.Status = HttpStatusCode.OK; response.ErrCode = 1; response.ErrMsg = "获取特约成功"; //response.Key = listcachekey; return(response); } }
public async Task <bool> GetInfo(bx_userinfo userinfo) { #region 修改前的方法 //bool isSuccess = true; //var requestmodel = new //{ // //Mobile = userinfo.Mobile, // LicenseNo = userinfo.LicenseNo, // CityCode = userinfo.CityCode, // RenewalIdNo = userinfo.RenewalIdNo, // Agent = userinfo.Agent, // Id = userinfo.Id //}; //logInfo.Info("行驶证信息请求进来额:" + requestmodel.ToJson()); //try //{ // using (var client = new HttpClient()) // { // client.BaseAddress = new Uri(_url); // HttpContent content = new StringContent(requestmodel.ToJson()); // content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // HttpResponseMessage responseCheck = client.PostAsync("api/userinfo/CheckNeedAdd", content).Result; // var resultJson = responseCheck.Content.ReadAsStringAsync().Result; // if (resultJson == "false") // { // logInfo.Info("太平洋check信息返回成功:" + requestmodel.ToJson()); // } // else // { // isSuccess = false; // logError.Info("太平洋check信息返回失败:" + requestmodel.ToJson()); // } // } //} //catch (Exception ex) //{ // logError.Info("checkneed 出现异常:" + requestmodel.ToJson()); // return false; //} //return isSuccess; #endregion bool isSuccess = false; string xuBaoCacheKey = userinfo.Id.ToString(); var msgBody = new { B_Uid = userinfo.Id, NotifyCacheKey = xuBaoCacheKey }; //发送获取车辆信息队列 var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxVehicle"]); var cacheKey = string.Format("{0}-findvehicle", xuBaoCacheKey); var cacheValue = CacheProvider.Get <string>(cacheKey); if (cacheValue == null) { for (int i = 0; i < 60; i++) { cacheValue = CacheProvider.Get <string>(cacheKey); if (!string.IsNullOrWhiteSpace(cacheValue)) { break; } else { await Task.Delay(TimeSpan.FromMilliseconds(500)); } } } return(isSuccess); }
public async Task <GetSpecialAssumpsitResponse> GetSpecialAssumpsit(GetSpecialAssumpsitRequest request, IEnumerable <KeyValuePair <string, string> > pair) { GetSpecialAssumpsitResponse response = new GetSpecialAssumpsitResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pair); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } //校验:2报价基础信息 UserInfoValidateRequest validateRequest = new UserInfoValidateRequest() { LicenseNo = request.LicenseNo, CustKey = request.CustKey, ChildAgent = request.ChildAgent == 0 ? request.Agent : request.ChildAgent, RenewalCarType = request.RenewalCarType }; //校验2 var validateResult = _userInfoValidateService.UserInfoValidate(validateRequest); if (validateResult.Item1.Status == HttpStatusCode.NotAcceptable) { response.Status = HttpStatusCode.NotAcceptable; return(response); } //正式逻辑============= string baojiaCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); //通知中心 var msgBody = new { B_Uid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), NotifyCacheKey = baojiaCacheKey, }; //发送安心核保消息 try { var baojiaKey = string.Format("{0}-GenerateSpecial-key", baojiaCacheKey); CacheProvider.Remove(baojiaKey); var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["bxAnXinTeYue"]); var cacheKey = CacheProvider.Get <string>(baojiaKey); if (cacheKey == null) { for (int i = 0; i < 180; i++) { cacheKey = CacheProvider.Get <string>(baojiaKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey == "1") { var msgModel = CacheProvider.Get <AXGainFixSpecInfoResponse>(string.Format("{0}-GenerateSpecial", baojiaCacheKey)); List <SpecialVO> SpecialContents = new List <SpecialVO>(); if (msgModel != null) { //取交强模型 if (msgModel.PackageJQVO != null) { if (msgModel.PackageJQVO.FixSpecList != null) { foreach (var item in msgModel.PackageJQVO.FixSpecList) { SpecialContents.Add(new SpecialVO() { CSpecNo = item.cSpecNo, CSysSpecContent = item.cSysSpecContent, Type = 1 }); } } } //取商业模型 if (msgModel.PackageSYVO != null) { if (msgModel.PackageSYVO.FixSpecList != null) { foreach (var item in msgModel.PackageSYVO.FixSpecList) { SpecialContents.Add(new SpecialVO() { CSpecNo = item.cSpecNo, CSysSpecContent = item.cSysSpecContent, Type = 2 }); } } } } response.SpecialContents = SpecialContents; } } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } return(response); }
public PostSubmitInfoResponse PostSubmitInfo(PostSubmitInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { PostSubmitInfoResponse response = new PostSubmitInfoResponse(); //校验:1基础校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } //校验2 var validateResult = _postValidate.SubmitInfoValidate(request); if (validateResult.Item1.Status == HttpStatusCode.NotAcceptable) { response.Status = HttpStatusCode.NotAcceptable; return(response); } //实现 //清理缓存 string baojiaCacheKey = string.Empty; try { baojiaCacheKey = _removeHeBaoKey.RemoveHeBao(request); } catch (RedisOperateException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } //中心传的商业险投保单号赋值 string strBizNo = string.Empty; //中心传的商业险投保单号赋值 string strForceNo = string.Empty; if (request.Source == 4 || request.Source == 1) { //人保、太保用tno strBizNo = validateResult.Item3.biz_tno ?? ""; strForceNo = validateResult.Item3.force_tno ?? ""; } else { //非人保、非太保的用pno strBizNo = validateResult.Item3.biz_pno ?? ""; strForceNo = validateResult.Item3.force_pno ?? ""; } //通知中心 var msgBody = new { B_Uid = validateResult.Item2.Id, Source = SourceGroupAlgorithm.GetOldSource(request.Source), BiztNo = strBizNo, ForcetNo = strForceNo, LicenseNo = validateResult.Item2.LicenseNo, NotifyCacheKey = baojiaCacheKey }; //发送重新核保消息 try { var msgbody = _messageCenter.SendToMessageCenter(msgBody.ToJson(), ConfigurationManager.AppSettings["MessageCenter"], ConfigurationManager.AppSettings["BxHeBaoAgainName"]); } catch (MessageException exception) { response.Status = HttpStatusCode.ExpectationFailed; response.ErrMsg = exception.Message; return(response); } response.Status = HttpStatusCode.OK; return(response); }