Esempio n. 1
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">用户密码</param>
        /// <returns></returns>
        public ActionResult UserLogin(string userName, string password)
        {
            password = Common.EncryptHelper.Encrypt(password);
            #region 处理验证
            string yzjg = Verification();
            if (string.IsNullOrEmpty(yzjg) || yzjg == "sb")
            {
                return(Json(SysEnum.失败, "请点击按钮进行验证"));
            }
            #endregion

            #region 处理用户名密码
            var administrator = AdministratorService.LoadEntities(u => u.login_account == userName && u.login_pwd == password).FirstOrDefault();
            if (administrator == null)
            {
                SaveSyslog("用户名或密码错误!", SysLogType.后台日志, userName);
                return(Json(SysEnum.用户名或密码错误, "用户名或密码错误"));
            }
            #endregion
            administrator.last_login_time       = DateTime.Now;
            administrator.last_login_IP_address = Request.UserHostAddress;
            AdministratorService.EditEntity(administrator);

            //添加到缓存里
            CacheHelper.AddCache(administrator.id.ToString(), administrator, DateTime.Now.AddMinutes(60));

            SaveSyslog("登陆后台管理", SysLogType.后台日志, userName);

            dynamic data = new { token = Common.EncryptHelper.Encrypt(string.Format("{0}|{1}", administrator.id.ToString(), Request.UserHostAddress)) };
            return(Json(SysEnum.成功, data, "登录成功"));
        }
Esempio n. 2
0
        public JsonResult Listar()
        {
            if (CacheHelper.GetCache("Gridview") != null)
            {
                return(Json((List <GridViewModel>)CacheHelper.GetCache("Gridview"), JsonRequestBehavior.AllowGet));
            }

            List <GridViewModel> lst = new List <GridViewModel>();

            for (int i = 0; i < 30; i++)
            {
                lst.Add(new GridViewModel()
                {
                    ID          = (i + 1),
                    CompanyName = "CompanyName " + (i + 1),
                    Address     = "Address " + (i + 1),
                    City        = "City " + (i + 1),
                    State       = "State " + (i + 1),
                    Zipcode     = "Zipcode " + (i + 1),
                    Phone       = "Phone " + (i + 1),
                    Fax         = "Fax " + (i + 1),
                    Website     = "Website " + (i + 1)
                });
            }

            CacheHelper.AddCache("Gridview", lst, DateTime.Now.AddMinutes(10));

            return(Json(lst, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public ActionResult GetUser_ChildList(int id)
        {
            var uf = CacheHelper.GetCache($"user_first_child_{id}") as List <user>;

            if (uf == null || uf.Count() == 0)
            {
                uf = UserService.LoadEntities(n => n.pid == id).ToList();
                if (uf.Any())
                {
                    CacheHelper.AddCache($"user_first_child_{id}", uf, DateTime.Now.AddMinutes(10));
                }
            }
            if (uf.Any())
            {
                var item = UserService.LoadEntities(n => n.id == id).FirstOrDefault();
                var data = uf.Select(n => new
                {
                    n.id,
                    n.name,
                    n.state,
                    n.isbuy,
                    children = GetSecondChild(n.id)
                }).ToList();
                var data1 = new
                {
                    item.id,
                    item.name,
                    item.state,
                    children = data,
                };
                return(Json(SysEnum.成功, data1, "获取数据成功", uf.Count()));
            }
            return(Json(SysEnum.失败, "未找到对象"));
        }
Esempio n. 4
0
        private Tuple <List <int>, List <int> > GetFirstLevelChild(int id)
        {
            var uf = CacheHelper.GetCache($"user_first_child_{id}") as List <user>;
            var us = CacheHelper.GetCache($"user_second_child_{id}") as List <user>;
            var f  = new List <int>();
            var s  = new List <int>();

            if (uf == null || uf.Count() == 0)
            {
                uf = UserService.LoadEntities(n => n.pid == id).ToList();
                if (uf.Any())
                {
                    CacheHelper.AddCache($"user_first_child_{id}", uf, DateTime.Now.AddMinutes(10));
                }
            }
            f = uf.Select(n => n.id).ToList();

            if (us == null || us.Count() == 0)
            {
                us = UserService.LoadEntities(n => f.Contains(n.pid)).ToList();
                if (us.Any())
                {
                    CacheHelper.AddCache($"user_second_child_{id}", us, DateTime.Now.AddMinutes(10));
                }
            }
            s = us.Select(n => n.id).ToList();

            return(new Tuple <List <int>, List <int> >(f, s));
        }
Esempio n. 5
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.UserName == "yjq" && model.Pwd == "123456")
         {
             string ticket = CrypHelper.GetNonce();
             CookieHelper.SetCookie("SSO_Ticket", ticket);
             CacheHelper.AddCache(ticket, 1, TimeSpan.FromHours(5));
             if (string.IsNullOrWhiteSpace(model.BackUrl))
             {
                 model.BackUrl = "/Home/Index";
             }
             if (model.BackUrl.IndexOf('?') > 0)
             {
                 model.BackUrl += "&ticket=" + ticket;
             }
             else
             {
                 model.BackUrl += "?ticket=" + ticket;
             }
             return(Redirect(model.BackUrl));
         }
     }
     return(View(model));
 }
Esempio n. 6
0
        /// <summary>
        /// 查询当前分类的玄机图库
        /// </summary>
        /// <param name="newsId">新闻Id</param>
        /// <param name="newsTitle">新闻标题</param>
        /// <param name="lType">彩种Id</param>
        /// <returns></returns>
        public List <Gallery> GetGalleries(long newsId, string newsTitle, int lType)
        {
            string memKey = string.Format(RedisKeyConst.Base_GalleryId, newsId); //"base_gallery_id_" + newsId;
            var    list   = CacheHelper.GetCache <List <Gallery> >(memKey);

            if (list != null && list.Any())
            {
                return(list);
            }

            string sql = @"select a.Id, a.FullHead as Name,a.[TypeId],right(ISNULL(a.LotteryNumber,''),3) as Issue, c.RPath as Picture 
from News a
left join ResourceMapping c on c.FkId=a.Id and c.[Type]=1
where a.FullHead=@FullHead and a.[TypeId]=@TypeId and DeleteMark=0 and EnabledMark=1  
order by a.LotteryNumber desc";

            var parameters = new[]
            {
                new SqlParameter("@FullHead", SqlDbType.NVarChar),
                new SqlParameter("@TypeId", SqlDbType.Int)
            };

            parameters[0].Value = newsTitle;
            parameters[1].Value = lType;

            list = Util.ReaderToList <Gallery>(sql, parameters) ?? new List <Gallery>();

            //CacheHelper.WriteCache(memKey, list);
            CacheHelper.AddCache(memKey, list);
            return(list);
        }
Esempio n. 7
0
 public ActionResult GetMenu()
 {
     //获取当前管理员所有菜单信息
     if (!(CacheHelper.GetCache($"adminactionidList_{nowManager.id}") is List <int> adminactionidList) || adminactionidList.Count == 0)
     {
         adminactionidList = new List <int>();
         foreach (var item in nowManager.role.ToList())
         {
             var acid = item.action.ToList().Select(n => n.id).ToList();
             adminactionidList.AddRange(acid);
         }
         adminactionidList.Distinct();
         if (adminactionidList.Count > 0)
         {
             CacheHelper.AddCache($"adminactionidList_{nowManager.id}", adminactionidList, DateTime.Now.AddHours(2));
         }
     }
     if (adminactionidList.Any())
     {
         var            actionList = ActionService.LoadEntities(n => adminactionidList.Contains(n.id) && n.del_flag == (int)Del_flag.正常 && n.type == (int)ActionType.菜单权限).ToList();
         List <dynamic> data       = new List <dynamic>();
         if (actionList.Any())
         {
             data = GetMenuTree(actionList.OrderBy(n => n.sort).ToList());
         }
         return(Json(SysEnum.成功, data, "获取数据成功", data.Count));
     }
     return(Json(SysEnum.权限不足, "权限不足"));
 }
Esempio n. 8
0
        /// <summary>
        /// 获取新闻资讯彩种分类列表
        /// </summary>
        /// <returns></returns>
        public ApiResult <List <LotteryTypeResDto> > GetLotteryTypeList()
        {
            string             cachekey = RedisKeyConst.Base_LotteryType;
            List <LotteryType> list     = CacheHelper.GetCache <List <LotteryType> >(cachekey);

            if (list == null)
            {
                list = Util.GetEntityAll <LotteryType>().OrderBy(x => x.SortCode).ToList();

                //CacheHelper.WriteCache("base_lottery_type", list);
                CacheHelper.AddCache(cachekey, list);
            }
            var resDto = list.Select(x => new LotteryTypeResDto()
            {
                Id        = x.Id,
                LType     = Util.GetlTypeById(x.Id.ToInt32()),
                LTypeName = x.TypeName,
                SortCode  = x.SortCode
            }).ToList();


            return(new ApiResult <List <LotteryTypeResDto> >()
            {
                Data = resDto
            });
        }
Esempio n. 9
0
        public ActionResult Watch()
        {
            #region Parameter Verify
            string id = Request.QueryString[Const.VIDEOID].ToString();
            if (string.IsNullOrEmpty(id))
            {
                id = "8";
            }
            int ids = 0;
            if (!int.TryParse(id, out ids))
            {
                return(View());
            }
            #endregion

            //Get Cache
            StartRecommendModel modelCache = CacheHelper.GetCacheBy(id) as StartRecommendModel;
            if (modelCache != null)
            {
                return(View(modelCache));
            }
            //if no cache,serach data from db,add to cache.
            StartRecommendModel model = _service.GetSpecialVideoBy(ids);
            CacheHelper.AddCache(id, model);
            return(View(model));
        }
Esempio n. 10
0
    //区间下拉
    private void BindRegionTypeListBox()
    {
        DataTable dt = new DataTable();

        if (Cache["regiontype"] != null)
        {
            dt = (DataTable)Cache["regiontype"];
        }
        else
        {
            dt = bll.GetListBoxData(userId, "RegionTypeFull", "RegionType", "ASC");
            CacheHelper.AddCache("regiontype", dt, CacheItemPriority.Normal);
        }
        this.RegionTypeListBox.DataSource     = dt;
        this.RegionTypeListBox.DataTextField  = "RegionTypeFull";
        this.RegionTypeListBox.DataValueField = "RegionType";
        this.RegionTypeListBox.DataBind();

        string[] arr = regionType.Split(',');
        foreach (ListItem item in this.RegionTypeListBox.Items)
        {
            foreach (string str in arr)
            {
                if (item.Value == str)
                {
                    item.Selected = true;
                }
            }
        }
    }
Esempio n. 11
0
        public static bool ShowDiscountProduct(DateTime date)
        {
            bool          result = false;
            DiscountModel model  = new DiscountModel();

            try
            {
                if (CacheHelper.IsCacheDB($"DiscountProduct-{DateTime.Now.ToString("ddMMyyyy")}"))
                {
                    result = CommonLib.IsNullBool(CacheHelper.GetCache($"DiscountProduct-{DateTime.Now.ToString("ddMMyyyy")}"));
                }
                else
                {
                    var list = JsonCacheHepler.GetJsonContent <List <DiscountModel> >("/Upload/xml", "DiscountProduct");
                    if (list != null && list.Count > 0)
                    {
                        var item = list.Where(m => m.StartDate <= date && m.EndDate >= date && m.IsShow == 1).FirstOrDefault();
                        if (item != null)
                        {
                            result = true;
                        }
                    }
                    CacheHelper.AddCache($"DiscountProduct-{DateTime.Now.ToString("ddMMyyyy")}", result, 24 * 60);
                }
            }
            catch (Exception ex)
            {
                WriteLog.Current.WriteFileLog("DataAccess\\ProductRP", "ProductRP=>ShowDiscountProduct", ex);
            }

            return(result);
        }
Esempio n. 12
0
 public ActionResult GetUseMsgLink(int id)
 {
     if (!(CacheHelper.GetCache($"user_msg_record") is List <user_msg_record> list) || list.Count == 0)
     {
         var d = DateTime.Now.AddDays(-61);
         list = User_msg_recordService.LoadEntities(n => n.msg_type == (int)Msg_type.提问 && n.add_time < d).ToList();                //最近61天内的数据
         if (list.Any())
         {
             CacheHelper.AddCache($"user_msg_record", list, DateTime.Now.AddMinutes(20));
         }
     }
     if (list.Any())
     {
         var data = new List <user_msg_record>();
         data.Add(GetParentMsg(list, id));
         if (data.Any())
         {
             var res = data.OrderBy(n => n.add_time).Select(n => new {
                 n.id,
                 user_name = n.user.name,
                 n.user_id,
                 n.title,
                 n.msg_content,
                 n.isread,
                 msg_type = Enum.GetName(typeof(Msg_type), n.msg_type),
                 add_time = n.add_time.ToString(),
                 n.remark,
                 admin_name = n.administrator == null ? string.Empty : n.administrator.name,
             }).ToList();
             return(Json(SysEnum.成功, data, "获取数据成功", list.Count()));
         }
         return(Json(SysEnum.失败, "没有任何数据"));
     }
     return(Json(SysEnum.失败, "没有任何数据"));
 }
Esempio n. 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = Request.QueryString["url"];

            if (!string.IsNullOrEmpty(url))
            {
                try
                {
                    url = HttpUtility.UrlDecode(url);
                    string state = EncryptHelper.MD5Encrypt(url);
                    //判断url根据MD5生成的密文在缓存中是否存在
                    object objUrl = CacheHelper.GetCache(state);
                    if (objUrl == null)
                    {
                        CacheHelper.AddCache(state, url, 5);//不存在则将url和对应的密文存储在缓存中,存储时长为5分钟
                    }
                    else
                    {
                        CacheHelper.SetCache(state, url, 5);//存在则将url和对应的密文在缓存中更新,更新存储时长为5分钟
                    }
                    Response.Redirect(string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state={2}#wechat_redirect", appId, ConfigurationManager.AppSettings["apppath"] + "/Auth.aspx", state));
                }

                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 微信公众号引导页
        /// </summary>
        /// <param name="url">微信前端传递的跳转url</param>
        /// <returns>成功时,重定向至获取用户信息</returns>
        public ActionResult Index(string url)
        {
            if (!string.IsNullOrEmpty(url))
            {
                url = WXHelper.DecodeBase64(url);
                string state = EncryptHelper.MD5Encrypt(url);
                //判断url根据MD5生成的密文在缓存中是否存在
                object objUrl = CacheHelper.GetCache(state);
                if (objUrl == null)
                {
                    CacheHelper.AddCache(state, url, 5);//不存在则将url和对应的密文存储在缓存中,存储时长为5分钟
                }
                else
                {
                    CacheHelper.SetCache(state, url, 5);//存在则将url和对应的密文在缓存中更新,更新存储时长为5分钟
                }
                return(Redirect(string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state={2}#wechat_redirect", appId, ConfigurationManager.AppSettings["zp_apppath"] + "/Recruitment/Auth/GetUserInfo", state)));
            }
            else
            {
                ViewData["errmsg"] = "重定向url不能为空!";
            }

            return(View());
        }
        public void GetKefu(System.Web.HttpContext context)
        {
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            if (System.Web.HttpRuntime.Cache["kefu"] == null)
            {
                ConfigInfo configInfo = FacadeManage.aideNativeWebFacade.GetConfigInfo(AppConfig.SiteConfigKey.ContactConfig.ToString());
                if (configInfo != null)
                {
                    dictionary["kefu53"]   = configInfo.Field4;
                    dictionary["kefuinfo"] = configInfo.Field5;
                    dictionary["kefudesc"] = configInfo.Field6;
                    dictionary["qq"]       = configInfo.Field7;
                    CacheHelper.AddCache("kefu", dictionary);
                }
            }
            else
            {
                dictionary = (System.Web.HttpRuntime.Cache["kefu"] as System.Collections.Generic.Dictionary <string, string>);
            }
            string        text          = dictionary["kefu53"];
            string        value         = dictionary["kefuinfo"];
            string        value2        = dictionary["kefudesc"];
            string        value3        = dictionary["qq"];
            AjaxJsonValid ajaxJsonValid = new AjaxJsonValid();

            ajaxJsonValid.AddDataItem("kefu53", text);
            if (text == "")
            {
                ajaxJsonValid.AddDataItem("kefuinfo", value);
            }
            ajaxJsonValid.AddDataItem("kefudesc", value2);
            ajaxJsonValid.AddDataItem("qq", value3);
            ajaxJsonValid.SetValidDataValue(true);
            context.Response.Write(ajaxJsonValid.SerializeToJson());
        }
Esempio n. 16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            if (System.Web.HttpRuntime.Cache["kefu"] == null)
            {
                ConfigInfo configInfo = FacadeManage.aideNativeWebFacade.GetConfigInfo(AppConfig.SiteConfigKey.ContactConfig.ToString());
                if (configInfo != null)
                {
                    dictionary["kefu53"]   = configInfo.Field4;
                    dictionary["kefuinfo"] = configInfo.Field5;
                    CacheHelper.AddCache("kefu", dictionary);
                }
            }
            else
            {
                dictionary = (System.Web.HttpRuntime.Cache["kefu"] as System.Collections.Generic.Dictionary <string, string>);
            }
            string text     = dictionary["kefu53"];
            string arg_91_0 = dictionary["kefuinfo"];

            if (text != "")
            {
                base.Response.Redirect(text);
            }
        }
Esempio n. 17
0
        //专题下拉
        private void BindZhuanTiListBox()
        {
            string zttype = string.Format("zttype_{0}", userId);

            DataTable dt = new DataTable();

            if (Cache[zttype] != null)
            {
                dt = (DataTable)Cache[zttype];
            }
            else
            {
                dt = bll.GetListBoxData(userId, "ZhuanTiName", "ZhuanTiID", "ASC");
                CacheHelper.AddCache(zttype, dt, CacheItemPriority.Normal);
            }
            this.ZhuanTiListBox.DataSource     = dt;
            this.ZhuanTiListBox.DataTextField  = "ZhuanTiName";
            this.ZhuanTiListBox.DataValueField = "ZhuanTiID";
            this.ZhuanTiListBox.DataBind();

            string[] arr = ztId.Split(',');
            foreach (ListItem item in this.ZhuanTiListBox.Items)
            {
                foreach (string str in arr)
                {
                    if (item.Value == str)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
Esempio n. 18
0
    //钱包下拉
    private void BindCardListBox()
    {
        DataTable dt = new DataTable();

        if (Cache["cardtype"] != null)
        {
            dt = (DataTable)Cache["cardtype"];
        }
        else
        {
            dt = bll.GetListBoxData(userId, "CardName", "CardID", "ASC");
            CacheHelper.AddCache("cardtype", dt, CacheItemPriority.Normal);
        }
        this.CardListBox.DataSource     = dt;
        this.CardListBox.DataTextField  = "CardName";
        this.CardListBox.DataValueField = "CardID";
        this.CardListBox.DataBind();

        string[] arr = cardId.Split(',');
        foreach (ListItem item in this.CardListBox.Items)
        {
            if (cardId == "")
            {
                item.Selected = true;
            }
            foreach (string str in arr)
            {
                if (item.Value == str)
                {
                    item.Selected = true;
                }
            }
        }
    }
Esempio n. 19
0
        /// <summary>
        /// 检查版本更新
        /// </summary>
        /// <param name="version">客户端版本</param>
        /// <param name="clientType">设备类型</param>
        /// <param name="customerSourceId">客户来源Id</param>
        /// <param name="appName">App编码</param>
        /// <returns></returns>
        public CheckerResDto CheckVersion(ApiVersion version, DevicePlatform clientType, byte customerSourceId,
                                          string appName)
        {
            long versionCode = GetDefaultVersionCode(version.FullVersion, clientType);
            //客户端版本
            string clientSourceKey = string.Format(RedisKeyConst.Installationpackage_ClientSourceKey,
                                                   GetDefaultVersionCode(version.FullVersion, clientType),
                                                   (int)clientType, customerSourceId, appName);

            var resDto = CacheHelper.GetCache <CheckerResDto>(clientSourceKey);

            if (resDto == null)
            {
                var sourceVersion = GetSourceVersion(clientType, customerSourceId, appName, versionCode);

                if (sourceVersion != null)
                {
                    resDto = new CheckerResDto()
                    {
                        Status  = sourceVersion.UpdateType,
                        Content = string.Empty,
                        Downurl = string.Empty
                    };

                    if ((sourceVersion.UpdateType == (int)ClientUpdateStatus.Optional ||
                         sourceVersion.UpdateType == (int)ClientUpdateStatus.Force) && sourceVersion.UpdateToVersionCode > 0)
                    {
                        var updateToSourceVersion = GetSourceVersion(clientType, customerSourceId, appName,
                                                                     sourceVersion.UpdateToVersionCode);
                        if (updateToSourceVersion != null)
                        {
                            resDto.Content = string.IsNullOrWhiteSpace(updateToSourceVersion.ClientVersionDesc)
                                ? ""
                                : updateToSourceVersion.ClientVersionDesc;
                            resDto.Downurl = string.IsNullOrWhiteSpace(updateToSourceVersion.UpdateLink)
                                ? ""
                                : updateToSourceVersion.UpdateLink;
                        }
                    }

                    //CacheHelper.WriteCache(clientSourceKey, resDto, 1440);
                    CacheHelper.AddCache(clientSourceKey, resDto, 1440);
                }
                else
                {
                    resDto = new CheckerResDto()
                    {
                        Status  = (int)ClientUpdateStatus.None,
                        Content = "",
                        Downurl = ""
                    };
                }
            }

            return(resDto);
        }
Esempio n. 20
0
        /// <summary>
        /// 获取广告列表
        /// </summary>
        /// <param name="location">栏目Id</param>
        /// <param name="adtype">广告类型 1=栏目 2=文章 3=六彩栏目</param>
        /// <param name="deviceType">设备类型 1=网页等其他 2=ios 3=安卓</param>
        /// <param name="city">所在城市</param>
        /// <returns></returns>
        public ApiResult <List <AdvertisementResDto> > GetAdvertList(int location, int adtype, int deviceType, string city, string reqIp)
        {
            //string memKey = string.Format("advertisement_{0}_{1}_{2}", location, adtype, deviceType);
            string memKey = string.Format(RedisKeyConst.Advertisement_List, adtype, deviceType, location);

            var list = CacheHelper.GetCache <List <Advertisement> >(memKey);

            if (list == null)
            {
                string strsql;
                if (adtype == 3)
                {
                    //六彩栏目列表
                    strsql = string.Format(@"select * from [dbo].[Advertisement] where charindex(',{1},',','+[where]+',')>0 and 
                   AdType={0} and (State=1 or (State=0 and getdate()>=BeginTime and EndTime>getdate()))", adtype, deviceType);
                }
                else
                {
                    strsql = string.Format(@"select * from [dbo].[Advertisement] where charindex(',{2},',','+[where]+',')>0   
            and charindex(',{0},',','+[Location]+',')>0 and AdType={1} and (State=1 or (State=0 and getdate()>=BeginTime and EndTime>getdate()))", location, adtype, deviceType);
                }
                list = Util.ReaderToList <Advertisement>(strsql);

                if (list != null)
                {
                    // CacheHelper.WriteCache(memKey, list);
                    CacheHelper.AddCache(memKey, list);
                }
            }

            if (list != null)
            {
                string cityId = Tool.GetCityIdByCityandIp(city, reqIp);
                var    resDto = list.Select(x => new AdvertisementResDto()
                {
                    Title          = x.Title,
                    CommentsNumber = x.CommentsNumber,
                    Company        = x.Company,
                    Layer          = x.Layer,
                    ThumbStyle     = x.ThumbStyle,
                    TransferUrl    = x.TransferUrl,
                    ThumbList      = GetAdvertisementPictures(x.ThumbStyle, x.Id),
                    SubTime        = x.SubTime,
                    Display        = IsShow(cityId, x.RestrictedAreas)
                }).ToList();



                return(new ApiResult <List <AdvertisementResDto> >()
                {
                    Data = resDto
                });
            }

            return(new ApiResult <List <AdvertisementResDto> >());
        }
Esempio n. 21
0
 public static List <Models.ExamPlace> GetExamPlaces()
 {
     if (!Utility.CacheHelper.IsExistCache("ExamPlaces"))
     {
         var result = EnterRepository.GetRepositoryEnter().ExamPlaceRepository.LoadEntities().ToList().ToList();
         CacheHelper.AddCache("ExamPlaces", result, 1);
         return(result);
     }
     return(CacheHelper.GetCache("ExamPlaces") as List <Models.ExamPlace>);
 }
Esempio n. 22
0
 private void SaveReadCount(system_msg_record smr)
 {
     if (System_msg_recordService.EditEntity(smr))
     {
         var sysmsg_list = System_msg_recordService.LoadEntities(n => n.del_flag == (int)Del_flag.正常).ToList();
         if (sysmsg_list.Any())
         {
             CacheHelper.AddCache("sysmsg_list", sysmsg_list, DateTime.Now.AddMinutes(5));
         }
     }
 }
Esempio n. 23
0
        public void RedisReadWriteTest()
        {
            for (int i = 0; i < 100000; i++)
            {
                string key = "redis_test_key_" + i;
                CacheHelper.AddCache(key, "qwertyuiopasdfghjklzxcvbnm_" + i);

                var data = CacheHelper.GetCache <string>(key);
                Console.WriteLine("第{0}项->key:{1},value:{2}", i, key, data);
            }
        }
Esempio n. 24
0
 /// <summary>
 /// 产品缓存
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 private List <product> ProductCache(string name)
 {
     if (!(CacheHelper.GetCache(name) is List <product> product_list) || product_list.Count == 0)
     {
         product_list = ProductService.LoadEntities(n => n.del_flag == (int)Del_flag.正常).ToList();
         if (product_list.Any())
         {
             CacheHelper.AddCache(name, product_list, DateTime.Now.AddMinutes(2));
         }
     }
     return(product_list);
 }
Esempio n. 25
0
 /// <summary>
 /// 产品缓存
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 private List <system_msg_record> SystemMsgCache(string name)
 {
     if (!(CacheHelper.GetCache(name) is List <system_msg_record> sysmsg_list) || sysmsg_list.Count == 0)
     {
         sysmsg_list = System_msg_recordService.LoadEntities(n => n.del_flag == (int)Del_flag.正常).ToList();
         if (sysmsg_list.Any())
         {
             CacheHelper.AddCache(name, sysmsg_list, DateTime.Now.AddMinutes(5));
         }
     }
     return(sysmsg_list);
 }
Esempio n. 26
0
 private List <user_score_record> UsrCache(string name, int id)
 {
     if (!(CacheHelper.GetCache(name) is List <user_score_record> list) || list.Count == 0)
     {
         list = User_score_recordService.LoadEntities(n => n.user_id == id).ToList();
         if (list.Any())
         {
             CacheHelper.AddCache(name, list, DateTime.Now.AddMinutes(2));
         }
     }
     return(list);
 }
Esempio n. 27
0
 /// <summary>
 /// 用户积分记录缓存
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public List <user_score_record> CacheUserScoreRecord(string name, int type)
 {
     if (!(CacheHelper.GetCache(name) is List <user_score_record> user_Score_list) || user_Score_list.Count == 0)
     {
         user_Score_list = User_score_recordService.LoadEntities(n => n.type == type).ToList();
         if (user_Score_list.Any())
         {
             CacheHelper.AddCache(name, user_Score_list, DateTime.Now.AddMinutes(5));
         }
     }
     return(user_Score_list);
 }
Esempio n. 28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public List <user> CacheUser(string name)
 {
     if (!(CacheHelper.GetCache(name) is List <user> user_list) || user_list.Count == 0)
     {
         user_list = UserService.LoadEntities(n => true).ToList();
         if (user_list.Any())
         {
             CacheHelper.AddCache(name, user_list, DateTime.Now.AddMinutes(2));
         }
     }
     return(user_list);
 }
Esempio n. 29
0
        /// <summary>
        /// 获取热门新闻
        /// </summary>
        /// <param name="count">查询数量</param>
        /// <returns></returns>
        public ApiResult <List <NewsListResDto> > GetHotNewsList(int count)
        {
            string cachekey            = RedisKeyConst.News_NewsListApi;
            List <NewsListResDto> data = CacheHelper.GetCache <List <NewsListResDto> >(cachekey);

            if (data == null)
            {
                //string hotArticlesql = "SELECT TOP " + count + @" [Id],[FullHead],[SortCode],[Thumb],[ReleaseTime],[ThumbStyle],[TypeId],
                //(SELECT COUNT(1) FROM[dbo].[Comment] WHERE [ArticleId]=a.Id and RefCommentId=0) as CommentCount
                //FROM [dbo].[News] a
                //WHERE  DeleteMark=0 AND EnabledMark=1
                //ORDER BY CommentCount DESC,SortCode ASC ";

                string hotArticlesql = @"select top " + count + @" n.Id,n.FullHead,n.SortCode,n.Thumb,n.ReleaseTime,n.ThumbStyle ,TypeId,
                    count(c.id) as CommentCount
                    from News n
                    left join Comment c on n.id = c.ArticleId and RefCommentId = 0
                    where n.id in(
                    select max(n.Id) from News n 
                    join newsType nt on n.TypeId = nt.Id
                    where nt.lType in (1,2,3,4,6) and nt.SortCode = 1 and n.DeleteMark=0 and n.EnabledMark = 1
                    group by nt.lType
                    )
                    group by n.Id,n.FullHead,n.SortCode,n.Thumb,n.ReleaseTime,n.ThumbStyle,TypeId";

                var list = Util.ReaderToList <News>(hotArticlesql);

                //int sourceType = (int)ResourceTypeEnum.新闻缩略图;
                data = list.Select(x => new NewsListResDto()
                {
                    Id           = x.Id,
                    ParentId     = x.ParentId,
                    CommentCount = x.CommentCount,
                    ReleaseTime  = x.ReleaseTime,
                    SortCode     = x.SortCode,
                    ThumbStyle   = x.ThumbStyle,
                    Title        = x.FullHead,
                    TypeId       = x.TypeId,
                    //ThumbList = sourceService.GetResources(sourceType, x.Id)
                    //                .Select(n => n.RPath).ToList()
                    ThumbList = new List <string>()
                }).ToList();

                //新闻缓存2小时
                CacheHelper.AddCache <List <NewsListResDto> >(cachekey, data, 2 * 60);
            }

            return(new ApiResult <List <NewsListResDto> >()
            {
                Data = data
            });
        }
Esempio n. 30
0
        public ActionResult TotalVideo()
        {
            IList <TopicModel> modelCache = CacheHelper.GetCacheBy(Const.HOME_TOTALVIDEO) as IList <TopicModel>;

            if (modelCache != null)
            {
                return(View(modelCache));
            }
            IList <TopicModel> totalVideo = _service.GetTopicTotalVideo();

            CacheHelper.AddCache(Const.HOME_TOTALVIDEO, totalVideo);
            return(View(totalVideo));
        }