コード例 #1
0
        public GetPrecisePriceReponse GetPrecisePrice(GetPrecisePriceRequest request)
        {
            ///获取报价信息和 核保信息,我发送的key都是一样的 ,不能按照险种信息hash,因为我取的时候 ,请求参数是没有险种的 ,
            /// 如果换成的key跟险种信息有关,导致缓存中 会有过的垃圾数据,客户端用不到 。
            /// 也就是说  缓存只存放最新的一条报价信息和核保信息
            GetPrecisePriceReponse response = new GetPrecisePriceReponse();

            var baojiaKey = new
            {
                LicenseNo        = request.LicenseNo,
                IntentionCompany = request.IntentionCompany,
                Agent            = request.Agent
            };
            var baojiaCacheKey = CommonCacheKeyFactory.MakeCacheKey(baojiaKey);
            var xuBaoKey       = string.Format("{0}-bj-{1}-{2}", baojiaCacheKey, request.IntentionCompany, "key");

            //获取报价信息
            //需要的表
            //bx_userinfo
            //bx_LastInfo
            //bx_SaveQuote
            //bx_QuoteResult
            //bx_SubmitInfo
            //bx_renewalquote

            //步骤1  续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:bbbb。

            //步骤2   中心在续保的时候 ,需要根据这个key 设置3个开关(人太平)
            //eg:
            //bbbb-bj-0-key:,
            //bbbb-bj-1-key:,
            //bbbb-bj-2-key:,
            //放在缓存中,人太平报价成功的时候分别要置1,刚开始是空值
            //等报价结束后,先将上面列出的表写入缓存
            //其中: 键值分别是:
            //bx_userinfo        :bbbb-userinfo
            //bx_LastInfo        :bbbb-lastinfo
            //bx_renewalquote    :bbbb-renewal
            //bx_SaveQuote       :bbbb-savequote

            //bx_QuoteResult     :bbbb-0-quoteresult
            //bx_SubmitInfo      :bbbb-0-submitinfo



            return(response);
        }
コード例 #2
0
        public async Task <GetPrecisePriceReponse> GetPrecisePrice(GetPrecisePriceRequest request)
        {
            //获取报价信息和 核保信息,我发送的key都是一样的 ,不能按照险种信息hash,因为我取的时候 ,请求参数是没有险种的 ,
            // 如果换成的key跟险种信息有关,导致缓存中 会有过的垃圾数据,客户端用不到 。
            // 也就是说  缓存只存放最新的一条报价信息和核保信息
            GetPrecisePriceReponse response = new GetPrecisePriceReponse();

            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();

            try
            {
                string baojiaCacheKey =
                    CommonCacheKeyFactory.CreateKeyWithLicenseAndAgentAndCustKey(request.LicenseNo, request.Agent, request.CustKey + request.RenewalCarType);
                var baojiaKey = string.Format("{0}-{1}-bj-{2}", baojiaCacheKey, request.IntentionCompany, "key");
                //获取报价信息
                //需要的表
                //bx_userinfo
                //bx_LastInfo
                //bx_SaveQuote
                //bx_QuoteResult
                //bx_SubmitInfo
                //bx_renewalquote

                //步骤1  续保的时候 会发送消息队列 ,这个时候 会把 key传过去eg:bbbb。

                //步骤2   中心在续保的时候 ,需要根据这个key 设置3个开关(人太平)
                //eg:
                //bbbb-bj-0-key:,
                //bbbb-bj-1-key:,
                //bbbb-bj-2-key:,
                //放在缓存中,人太平报价成功的时候分别要置1,刚开始是空值
                //等报价结束后,先将上面列出的表写入缓存
                //其中: 键值分别是:
                //bx_userinfo        :bbbb-userinfo
                //bx_LastInfo        :bbbb-lastinfo
                //bx_car_renewal     :bbbb-renewal
                //bx_SaveQuote       :bbbb-savequote

                //bx_QuoteResult     :bbbb-0-quoteresult
                //bx_SubmitInfo      :bbbb-0-submitinfo
                var cacheKey = CacheProvider.Get <string>(baojiaKey);
                //ExecutionContext.SuppressFlow();

                if (cacheKey == null)
                {
                    for (int i = 0; i < 210; i++)
                    {
                        cacheKey = CacheProvider.Get <string>(baojiaKey);
                        if (!string.IsNullOrWhiteSpace(cacheKey))
                        {
                            break;
                        }
                        else
                        {
                            await Task.Delay(TimeSpan.FromSeconds(1));
                        }
                    }
                }
                //ExecutionContext.RestoreFlow();
                if (cacheKey == "1")
                {
                    response.UserInfo = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", baojiaCacheKey, "userinfo"));
                    response.LastInfo = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", baojiaCacheKey, "lastinfo"));
                    var renewal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo);
                    response.Renewal   = CacheProvider.Get <bx_car_renewal>(string.Format("{0}-{1}", renewal, "renewal"));
                    response.SaveQuote =
                        CacheProvider.Get <bx_savequote>(string.Format("{0}-{1}", baojiaCacheKey, "savequote"));

                    response.QuoteResult =
                        CacheProvider.Get <bx_quoteresult>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                         request.IntentionCompany, "quoteresult"));
                    response.CarInfo = CacheProvider.Get <bx_quoteresult_carinfo>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                                request.IntentionCompany, "quoteresultcarinfo"));
                    response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                           request.IntentionCompany, "submitinfo"));
                    response.BusinessStatus = 1;
                }
                else if (cacheKey == "0")
                {
                    response.UserInfo  = CacheProvider.Get <bx_userinfo>(string.Format("{0}-{1}", baojiaCacheKey, "userinfo"));
                    response.LastInfo  = CacheProvider.Get <bx_lastinfo>(string.Format("{0}-{1}", baojiaCacheKey, "lastinfo"));
                    response.SaveQuote =
                        CacheProvider.Get <bx_savequote>(string.Format("{0}-{1}", baojiaCacheKey, "savequote"));
                    var renewal = CommonCacheKeyFactory.CreateKeyWithLicense(request.LicenseNo);
                    response.Renewal    = CacheProvider.Get <bx_car_renewal>(string.Format("{0}-{1}", renewal, "renewal"));
                    response.SubmitInfo = CacheProvider.Get <bx_submit_info>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                                           request.IntentionCompany, "submitinfo"));
                    response.QuoteResult =
                        CacheProvider.Get <bx_quoteresult>(string.Format("{0}-{1}-{2}", baojiaCacheKey,
                                                                         request.IntentionCompany, "quoteresult"));
                    response.BusinessStatus = 3;
                }
                string baojiaCacheCheckCodeIdKey = string.Format("{0}CheckCodeKey", baojiaCacheKey);
                var    bk = CacheProvider.Get <string>(baojiaCacheCheckCodeIdKey);
                if (!string.IsNullOrWhiteSpace(bk))
                {
                    response.CheckCode = bk;
                }
                #region 新增请求记录
                var reqkey = string.Format("{0}-reqcarinfo", response.UserInfo.Id);
                response.ReqInfo = CacheProvider.Get <bx_quotereq_carinfo>(reqkey);
                #endregion
                //addby gpj 20181122 驾意险
                response.YwxDetails = CacheProvider.Get <List <bx_ywxdetail> >(string.Format("{0}-{1}-jyxinfos", baojiaCacheKey, request.IntentionCompany));
            }
            catch (Exception ex)
            {
                //stopwatch.Stop();

                ILog logError = LogManager.GetLogger("ERROR");

                logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + " 请求数据:" + request.ToJson() + "  响应结果:" + response.ToJson());
                throw;
            }
            //stopwatch.Stop();
            return(response);
        }