Example #1
0
        /// <summary>
        /// 组装二级页面三要素
        /// </summary>
        /// <returns></returns>
        private SystemThreeElementsViewEntity AppendSecondElements(string type)
        {
            SystemThreeElementsViewEntity res = Cache.Factory.CacheFactory.Cache().GetCache <SystemThreeElementsViewEntity>(CacheKeyEnum.SystemThreeElements.ToString() + "__" + type + "__");

            if (res == null)
            {
                res = new SystemThreeElementsViewEntity();

                string keywordTemplate = ConfigHelper.GetValue("SystemElementsKeywords");
                string descTemplate    = ConfigHelper.GetValue("SystemElementsDescription");

                //获取当前彩种配置信息
                SCCConfig config = LotteryConfig.FirstOrDefault(s => s.EnumCode.Equals(type));
                if (config != null)
                {
                    res.Keywords    = keywordTemplate.Replace("$Name$", config.LotteryName);
                    res.Description = descTemplate.Replace("$Name$", config.LotteryName);
                }
                else
                {
                    bool isSucc = Enum.TryParse <SCCLottery>(type, true, out SCCLottery lottery);
                    //SCCLottery type = (SCCLottery)Enum.Parse(typeof(SCCLottery), arg.EnumCode, true);
                    if (isSucc)
                    {
                        res.Keywords    = keywordTemplate.Replace("$Name$", lottery.GetEnumDescription());
                        res.Description = descTemplate.Replace("$Name$", lottery.GetEnumDescription());
                    }
                }
                Cache.Factory.CacheFactory.Cache().WriteCache(res, CacheKeyEnum.SystemThreeElements.ToString() + "__" + type + "__", DateTimeHelper.Now.AddDays(30));
            }
            return(res);
        }
Example #2
0
        /// <summary>
        /// 组装主页面三要素
        /// </summary>
        /// <returns></returns>
        private SystemThreeElementsViewEntity AppendMainElements(string type)
        {
            SystemThreeElementsViewEntity res = Cache.Factory.CacheFactory.Cache().GetCache <SystemThreeElementsViewEntity>(CacheKeyEnum.SystemThreeElements.ToString() + "__" + type + "__");

            if (res == null)
            {
                res = new SystemThreeElementsViewEntity();

                string keywordTemplate = ConfigHelper.GetValue("SystemElementsKeywords");
                string descTemplate    = ConfigHelper.GetValue("SystemElementsDescription");

                StringBuilder        builder = new StringBuilder();
                List <DataItemModel> data    = dataItemCache.GetDataItemList(type);
                foreach (DataItemModel model in data)
                {
                    builder.Append(model.ItemName + ",");
                }

                res.Keywords    = keywordTemplate.Replace("$Name$", builder.ToString());
                res.Description = descTemplate.Replace("$Name$", builder.ToString());

                Cache.Factory.CacheFactory.Cache().WriteCache(res, CacheKeyEnum.SystemThreeElements.ToString() + "__" + type + "__", DateTimeHelper.Now.AddDays(30));
            }
            return(res);
        }
Example #3
0
        public HttpResponseMessage GetSystemThreeElements(SystemThreeElementsArgEntity arg)
        {
            BaseJson <SystemThreeElementsViewEntity> resultMsg = new BaseJson <SystemThreeElementsViewEntity> {
                Status = (int)JsonObjectStatus.Error, Message = "服务器未知错误。", Data = null
            };

            Logger(typeof(CommonController), arg.TryToJson(), "获取系统三要素-GetSystemThreeElements", () =>
            {
                if (!string.IsNullOrEmpty(arg.t) && !string.IsNullOrEmpty(arg.EnumCode))
                {
                    if (arg.t.CheckTimeStamp())
                    {
                        SystemThreeElementsViewEntity res = new SystemThreeElementsViewEntity();
                        switch (arg.Type)
                        {
                        case "1":
                            res = AppendSecondElements(arg.EnumCode);
                            break;

                        case "2":
                            res = AppendMainElements(arg.EnumCode);
                            break;
                        }

                        resultMsg = new BaseJson <SystemThreeElementsViewEntity>
                        {
                            Status  = (int)JsonObjectStatus.Success,
                            Data    = res,
                            Message = JsonObjectStatus.Success.GetEnumText(),
                            BackUrl = null
                        };
                    }
                    else
                    {
                        resultMsg = new BaseJson <SystemThreeElementsViewEntity>
                        {
                            Status  = (int)JsonObjectStatus.Fail,
                            Data    = null,
                            Message = JsonObjectStatus.Fail.GetEnumText() + ",无效参数。",
                            BackUrl = null
                        };
                    }
                }
                else
                {
                    resultMsg = new BaseJson <SystemThreeElementsViewEntity>
                    {
                        Status  = (int)JsonObjectStatus.Fail,
                        Data    = null,
                        Message = JsonObjectStatus.Fail.GetEnumText() + ",请求参数为空。",
                        BackUrl = null
                    };
                }
            }, e =>
            {
                resultMsg = new BaseJson <SystemThreeElementsViewEntity>
                {
                    Status  = (int)JsonObjectStatus.Exception,
                    Data    = null,
                    Message = JsonObjectStatus.Exception.GetEnumText() + ",异常信息:" + e.Message,
                    BackUrl = null
                };
            });

            return(resultMsg.TryToJson().ToHttpResponseMessage());
        }