コード例 #1
0
        public async Task <HttpResponseMessage> GetAccidentList([FromUri] GetAccidentListRequest request)
        {
            GetAccidentListViewModel viewModel = new GetAccidentListViewModel();

            viewModel.CityCode = request.CityCode;

            if (!new long[] { 1, 2, 4 }.Contains(request.Source))
            {
                viewModel.BusinessStatus = 0;
                viewModel.StatusMessage  = "该保险公司不支持特约";
                return(viewModel.ResponseToJson());
            }
            logInfo.Info(string.Format("获取驾意险种列表:{0}", Request.RequestUri));
            WaBxSysJyxResponse response = await _getAccidentListService.GetAccidentList(request, Request.GetQueryNameValuePairs());

            if (response.ErrCode == 1)
            {
                if (request.Source == 2)
                {
                    viewModel.PingAnJyxInfo = response.PingAnJyxInfo;
                }
                else if (request.Source == 1)
                {
                    viewModel.TpyYwxProductInfo = response.TpyYwxProductInfo;
                }
                viewModel.BusinessStatus = 1;
                viewModel.StatusMessage  = "获取信息成功";
            }
            else
            {
                viewModel.BusinessStatus = 0;
                viewModel.StatusMessage  = "获取信息失败";
            }


            return(viewModel.ResponseToJson());
        }
コード例 #2
0
        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);
            }
        }