Beispiel #1
0
 public ResponseDataEntity Set()
 {
     //日志等级由系统维护,通过配置参数获取
     //系统临时设置日志级别,log4可直接设置为ALL级别,如果需要测试接口等其他级别可通过这个配置调整
     CacheUtil.Add("LogLevel", "ERROR", new TimeSpan(0, 5, 0));
     return(ResponseUtil.Success());
 }
        /// <summary>显示产品详细内容的页面
        /// </summary>
        /// <param name="id">要显示的产品的ID</param>
        /// <returns>产品详细页面</returns>
        public ActionResult Detail(int id)
        {
            Cart     cart = (User as SolemartUser).Cart;
            CartItem item = cart.CartItems.FirstOrDefault(c => c.ProductID == id);

            if (item != null)
            {
                ViewBag.CartItem = item.Amount;
            }
            else
            {
                ViewBag.CartItem = 0;
            }

            string cacheKey = string.Format("product_{0}", id);
            ProductDetailViewModel model = null;

            if (CacheUtil.Exist(cacheKey))
            {
                model = CacheUtil.Get <ProductDetailViewModel>(cacheKey);
            }
            else
            {
                SaledProductItem        saleInfo = ProductManager.GetSaledProductByID(id);
                ProductItem             product  = ProductManager.GetProductWithBrandByID(id);
                List <ProductImageItem> images   = ProductManager.GetProductNoLogoImage(id);
                int commentCount = ProductManager.GetProductCommentCount(id);

                string remainAmountString = string.Empty;
                if (product.Unit == "斤")
                {
                    remainAmountString = string.Format("{0}", product.StockCount - product.ReserveCount);
                }
                else
                {
                    remainAmountString = string.Format("{0:d}", (int)(product.StockCount - product.ReserveCount));
                }
                model = new ProductDetailViewModel
                {
                    ProductID          = id,
                    ProductName        = product.ProductName,
                    ProductDescription = product.Description,
                    Price            = saleInfo.Price,
                    Unit             = product.Unit,
                    Discount         = saleInfo.Discount,
                    SpecialFlag      = saleInfo.SpecialFlag,
                    RemainAmount     = remainAmountString,
                    BrandDescription = product.Brand.Description,
                    BrandLogo        = product.Brand.BrandLogo,
                    BrandUrl         = product.Brand.BrandUrl,
                    BrandName        = product.Brand.ZhName,
                    CommentCount     = commentCount,
                    Images           = images
                };
                CacheUtil.Add <ProductDetailViewModel>(cacheKey, model, 600);
            }


            return(View(model));
        }
        /// <summary>
        /// 内部方法初始交易时间
        /// 初始交易时间要先初始化交易所,
        /// 因为这里是取交易所ID来作主键,如果交易所没有交易时间,这里不添加记录
        /// </summary>
        private void privateInitTradeTime()
        {
            List <CM_BourseType> btList = bourseTypes.GetAll();
            List <CM_TradeTime>  ttList = GetAllTradeTime();

            tradeTimes.Reset();//重新初始化先清空再ADD
            if (Utils.IsNullOrEmpty(btList) || Utils.IsNullOrEmpty(ttList))
            {
                return;
            }
            foreach (var item in btList)
            {
                var cacheList = new List <CM_TradeTime>();
                foreach (var model in ttList)
                {
                    if ((int)model.BourseTypeID == item.BourseTypeID)
                    {
                        cacheList.Add(model);
                    }
                }
                if (!Utils.IsNullOrEmpty(cacheList))
                {
                    tradeTimes.Add(item.BourseTypeID, cacheList);
                }
            }
        }
        /// <summary>
        /// 向内部缓存数据添加数据初始化
        /// 程序启动时对些方法调用一次
        /// </summary>
        public void Initialize()
        {
            try
            {
                ShowMessage.Instanse.ShowFormTitleMessage("正在获取管理中心数据初始化内部参数");

                commotity.Fill(key => key.CommodityCode, GetAllCommodity());
                bourseTypes.Fill(key => key.BourseTypeID, GetAllBourseType());
                breedClasss.Fill(key => key.BreedClassID, GetAllBreedClass());
                breedClassTypes.Fill(key => key.BreedClassTypeID, GetAllBreedClassType());
                //缓存根据期货品种类型缓存相关代码
                privateInitCommotityByBreedClassID();
                //===========

                commodityFuses.Fill(key => key.CommodityCode, GetAllCommodityFuse());
                //fieldRanages.Fill(key => key.FieldRangeID, GetAllFieldRange());
                fuseTimeSections.Fill(key => key.TimesectionID, GetAllFuseTimesection());
                //minChangePriceValues.Fill(key => key.BreedClassID.ToString() + "@" + key.FieldRangeID.ToString(), GetAllMinChangePriceValue());
                qh_HighLowStopScopeType.Fill(key => key.HighLowStopScopeID, GetAllQH_HighLowStopScopeType());
                qh_FuturesTradeRules.Fill(key => key.BreedClassID, GetAllQH_FutureTradeRules());
                RC_MatchCenter model         = GetMatchCenterByAddress();
                int            matchCenterID = model.MatchCenterID;
                matchCenter.Add(matchCenterID, model);
                matchMachine.Fill(key => key.MatchMachineID, GetAllMatchMachineByMatchCenterID(matchCenterID));
                tradeCommodityAssign.Fill(key => key.CommodityCode, GetAllTradeCommodityAssign());
                spotTradeRules.Fill(key => key.BreedClassID, GetAllSpotTradeRules());
                //tradeTimes.Fill(key => key.TradeTimeID, GetAllTradeTime());
                //改由以下以交易所ID为主键
                privateInitTradeTime();
                validDeclareTypes.Fill(key => key.BreedClassValidID, GetAllValidDeclareType());
                validDeclareValues.Fill(key => key.ValidDeclareValueID, GetAllValidDeclareValue());
                xh_SpotHighLowControlType.Fill(key => key.BreedClassHighLowID, GetAllSpotHighLowControlType());
                xh_SpotHighLowValues.Fill(key => key.HightLowValueID, GetAllSpotHighLowValue());
                zFCommodity.Fill(key => key.stkcd.ToString() + "@" + key.paydt.ToString(), GetAllZFCommodity());
                //获取所有非交易日的日期
                cm_notTradeDate.Fill(key => key.BourseTypeID.Value + "@" + key.NotTradeDay.Value.ToString("yyyy-MM-dd"), GetAllCMNotTradeDate());
                qh_LastTradingDay.Fill(key => key.LastTradingDayID, GetAllLastTradingDay());
                #region 港股部分

                hk_MinPriceFiled.Fill(key => key.FieldRangeID, GetHKMinChangePriceFieldRange());
                hk_spotTradeRules.Fill(key => key.BreedClassID, GetHKSpotTradeRules());
                hk_commodity.Fill(key => key.HKCommodityCode, GetAllHKCommodity());
                //hkSpotCosts.Fill(key => key.BreedClassID, get());
                #endregion
                ShowMessage.Instanse.ShowFormTitleMessage("获取管理中心数据初始化内部参数(完)");
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("CH-0002:初始化缓存数据异常0001", ex);
                ShowMessage.Instanse.ShowFormTitleMessage("获取管理中心数据初始化内部参数异常");
                throw ex;
            }
        }
Beispiel #5
0
        public ResponseWrapper <string> GetClientId()
        {
            ResponseWrapper <string> response = new ResponseWrapper <string>();
            string clientId = TokenUtil.NewToken();

            MyQQEntity myQQEntity = new MyQQEntity();

            myQQEntity.ClientID = clientId;
            myQQEntity.Online   = MyQQEntity.OnlineStatus.None;

            CacheUtil.Add(clientId, myQQEntity);

            response.ReturnCode   = 1;
            response.Message      = "Get client id successfully.";
            response.InnerMessage = "Please remember to append the client id value for the next api request.";
            response.Result       = clientId;

            return(response);
        }
        /// <summary>
        /// 根据商品类别缓存相关代码,目前这里只缓存期货类型下的相关类别,目前现货没有必要缓存
        /// 调用此方法要先初始货品种类型与类别再调用些方法
        /// </summary>
        private void privateInitCommotityByBreedClassID()
        {
            List <CM_BreedClass> list = breedClasss.GetAll();

            foreach (var item in list)
            {
                if (!item.BreedClassTypeID.HasValue)
                {
                    continue;
                }

                //目前只缓存股指期货或者是商品期货的代码
                if ((Types.BreedClassTypeEnum)item.BreedClassTypeID.Value == Types.BreedClassTypeEnum.CommodityFuture ||
                    (Types.BreedClassTypeEnum)item.BreedClassTypeID.Value == Types.BreedClassTypeEnum.StockIndexFuture)
                {
                    List <CM_Commodity> model = new List <CM_Commodity>();
                    model = GetAllCommodityByBreedClass(item.BreedClassID);
                    if (model != null && model.Count > 0)
                    {
                        commotityQHByBreedClassID.Add(item.BreedClassID, model);
                    }
                }
            }
        }
 public static void AddCredentialsCache(string environmentId, Dictionary <string, string> credentialDict)
 {
     CacheUtil.Add(environmentId, credentialDict);
 }