public async Task <GetViolationInfoResponse> GetList(GetViolationInfoRequest request) { GetViolationInfoResponse response = new GetViolationInfoResponse(); var chuxianCacheKey = CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType); var chuxianKey = string.Format("{0}-violation-key", chuxianCacheKey); ; var cacheValue = string.Format("{0}-violationl", chuxianCacheKey); var cacheKey = CacheProvider.Get <string>(chuxianKey); if (cacheKey == null) { for (int i = 0; i < 100; i++) { cacheKey = CacheProvider.Get <string>(chuxianKey); if (!string.IsNullOrWhiteSpace(cacheKey)) { break; } else { await Task.Delay(TimeSpan.FromSeconds(1)); } } } if (cacheKey != null) { if (cacheKey == "1") { response.List = CacheProvider.Get <IEnumerable <bx_violationlog> >(cacheValue).ToList(); } else { response.List = new List <bx_violationlog>(); } } else { response.List = null; } return(response); }
public async Task <HttpResponseMessage> GetViolationInfo([FromUri] GetViolationInfoRequest request) { logInfo.Info(string.Format("车辆出险信息接口请求串:{0}", Request.RequestUri)); var vm = new GetViolationInfoViewModel(); if (!ModelState.IsValid) { vm.BusinessStatus = -10000; vm.StatusMessage = "输入参数错误,请检查您输入的参数是否有空或者长度不符合要求等"; return(vm.ResponseToJson()); } var response = await _userClaimService.GetViolationList(request, Request.GetQueryNameValuePairs()); if (response.Status == HttpStatusCode.Forbidden) { vm.BusinessStatus = -10001; vm.StatusMessage = "参数校验错误,请检查您的校验码"; } if (response.Status == HttpStatusCode.ExpectationFailed) { vm.BusinessStatus = -10003; vm.StatusMessage = "服务器发生异常"; return(vm.ResponseToJson()); } if (response.List != null) { vm.BusinessStatus = 1; vm.List = response.List.ConverToViewModelList(); } else { vm.BusinessStatus = -10002; vm.StatusMessage = "获取车辆出险信息失败"; } logInfo.Info("车辆:" + request.LicenseNo + "的违章信息:" + vm.ToJson()); return(vm.ResponseToJson()); }
public async Task <GetViolationInfoResponse> GetViolationList(GetViolationInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetViolationInfoResponse response = new GetViolationInfoResponse(); //根据经纪人获取手机号 IBxAgent agentModel = GetAgentModelFactory(request.Agent); if (!agentModel.AgentCanUse()) { response.Status = HttpStatusCode.Forbidden; return(response); } //参数校验 if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode)) { response.Status = HttpStatusCode.Forbidden; return(response); } try { //微信端逻辑 次级代理 if (request.ChildAgent > 0) { request.Agent = request.ChildAgent; } response = await _userClaimCache.GetList(request); if (response == null) { response = new GetViolationInfoResponse(); response.Status = HttpStatusCode.ExpectationFailed; } } catch (Exception ex) { response = new GetViolationInfoResponse(); response.Status = HttpStatusCode.ExpectationFailed; } return(response); }