Ejemplo n.º 1
0
        /// <summary>
        /// 返回fid与categoryid对应的JSON数据
        /// </summary>
        /// <returns>JSON数据</returns>
        public static string GetGoodsCategoryWithFid()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string categoryfid          = cache.RetrieveObject("/Mall/MallSetting/GoodsCategoryWithFid") as string;

            if (categoryfid == null)
            {
                categoryfid = "[";

                IDataReader iDataReader = DbProvider.GetInstance().GetGoodsCategoryWithFid();
                if (iDataReader != null)
                {
                    while (iDataReader.Read())
                    {
                        categoryfid += string.Format("{{'fid' : {0}, 'categoryid' : {1}}},",
                                                     iDataReader["fid"],
                                                     iDataReader["categoryid"]);
                    }
                    iDataReader.Dispose();
                }
                if (categoryfid.EndsWith(","))
                {
                    categoryfid = categoryfid.Substring(0, categoryfid.Length - 1);
                }

                categoryfid += "]";
                cache.AddObject("/Mall/MallSetting/GoodsCategoryWithFid", categoryfid);
            }

            return(categoryfid);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得模板变量列表
        /// </summary>
        /// <param name="forumpath">模板路径</param>
        /// <param name="skinName">皮肤名</param>
        /// <returns></returns>
        public static DataTable GetTemplateVarList(string forumpath, string skinName)
        {
            Discuz.Cache.DNTCache cache = Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Forum/" + skinName + "/TemplateVariable") as DataTable;

            if (dt == null)
            {
                DataSet dsSrc = new DataSet("template");

                string[] filename = { Utils.GetMapPath(forumpath + "templates/" + skinName + "/templatevariable.xml") };

                if (Utils.FileExists(filename[0]))
                {
                    dsSrc.ReadXml(filename[0]);
                    if (dsSrc.Tables.Count == 0)
                    {
                        dsSrc.Tables.Add(TemplateVariableTable());
                    }
                }
                else
                {
                    dsSrc.Tables.Add(TemplateVariableTable());
                }
                dt = dsSrc.Tables[0];
                cache.AddObject("/Forum/" + skinName + "/TemplateVariable", dt, filename);
            }
            return(dt);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将缓存中的表情信息返回为SmiliesInfo[],不包括表情分类
        /// </summary>
        /// <returns></returns>
        public static SmiliesInfo[] GetSmiliesListWithInfo()
        {
            Discuz.Cache.DNTCache cache           = Discuz.Cache.DNTCache.GetCacheService();
            SmiliesInfo[]         smilieslistinfo = cache.RetrieveObject("/UI/SmiliesListWithInfo") as SmiliesInfo[];
            if (smilieslistinfo == null)
            {
                DataTable dt = GetSmiliesListWithoutType();
                if (dt == null)
                {
                    return(null);
                }
                if (dt.Rows.Count <= 0)
                {
                    return(null);
                }

                smilieslistinfo = new SmiliesInfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    smilieslistinfo[i]              = new SmiliesInfo();
                    smilieslistinfo[i].Id           = Utils.StrToInt(dt.Rows[i]["id"], 0);
                    smilieslistinfo[i].Code         = dt.Rows[i]["Code"].ToString();
                    smilieslistinfo[i].Displayorder = Utils.StrToInt(dt.Rows[i]["Displayorder"], 0);
                    smilieslistinfo[i].Type         = Utils.StrToInt(dt.Rows[i]["Type"], 0);
                    smilieslistinfo[i].Url          = dt.Rows[i]["Url"].ToString();
                }
                cache.AddObject("/UI/SmiliesListWithInfo", smilieslistinfo);

                //表情缓存重新加载时重新初始化表情正则对象数组
                ResetRegexSmilies(smilieslistinfo);
            }
            return(smilieslistinfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 按查询字符串得到广告列表
        /// </summary>
        /// <param name="selectstr">查询字符串</param>
        /// <returns>广告列表</returns>
        private static AdShowInfo[] GetAdsTable(string selectstr)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Advertisements") as DataTable;

            if (dt == null)
            {
                dt = DatabaseProvider.GetInstance().GetAdsTable();
                cache.AddObject("/Advertisements", dt);
            }

            DataRow[] drs      = dt.Select(selectstr);
            int       adlength = drs.Length;

            AdShowInfo[] adarray = new AdShowInfo[adlength];

            for (int i = 0; i < adlength; i++)
            {
                adarray[i]              = new AdShowInfo();
                adarray[i].Advid        = Convert.ToInt32(drs[i]["advid"].ToString());
                adarray[i].Displayorder = Convert.ToInt32(drs[i]["displayorder"].ToString());
                adarray[i].Code         = drs[i]["code"].ToString().Trim();
                adarray[i].Parameters   = drs[i]["parameters"].ToString().Trim();
            }

            return(adarray);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获得所有版主信息
        /// </summary>
        /// <returns>所有版主信息</returns>
        public static ModeratorInfo[] GetModeratorList()
        {
            Discuz.Cache.DNTCache cache     = Discuz.Cache.DNTCache.GetCacheService();
            ModeratorInfo[]       infoArray = cache.RetrieveObject("/ModeratorList") as ModeratorInfo[];
            if (infoArray == null)
            {
                DataTable dt = DatabaseProvider.GetInstance().GetModeratorList();
                infoArray = new ModeratorInfo[dt.Rows.Count];
                ModeratorInfo info;
                // id为索引
                int id = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    info              = new ModeratorInfo();
                    info.Uid          = Int32.Parse(dr["uid"].ToString());
                    info.Fid          = Int16.Parse(dr["fid"].ToString());
                    info.Displayorder = Int16.Parse(dr["Displayorder"].ToString());
                    info.Inherited    = Int16.Parse(dr["inherited"].ToString());
                    infoArray[id]     = info;
                    id++;
                }

                cache.AddObject("/ModeratorList", infoArray);
            }
            return(infoArray);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获得置顶主题信息列表
        /// </summary>
        /// <param name="fid">版块ID</param>
        /// <param name="pageSize">每页显示主题数</param>
        /// <param name="pageIndex">当前页数</param>
        /// <param name="tids">主题id列表</param>
        /// <returns>主题信息列表</returns>
        public static Discuz.Common.Generic.List <TopicInfo> GetTopTopicList(int fid, int pageSize, int pageIndex, string tids, int autocloseTime, int topicTypePrefix)
        {
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            Discuz.Common.Generic.List <TopicInfo> list;
            //只有在应用memcached的情况下才可以使用主题缓存
            if ((mcci != null && mcci.ApplyMemCached) || (rci != null && rci.ApplyRedis))
            {
                Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
                list = cache.RetrieveObject("/Forum/ShowTopic/TopList/" + fid + "/") as List <TopicInfo>;

                if (list == null)
                {
                    list = Data.Topics.GetTopTopicList(fid, pageSize, pageIndex, tids);
                    LoadTopTopicListExtraInfo(topicTypePrefix, list);
                    cache.AddObject("/Forum/ShowTopic/TopList/" + fid + "/", list, 300);
                }
            }
            else
            {
                list = Data.Topics.GetTopTopicList(fid, pageSize, pageIndex, tids);
                LoadTopTopicListExtraInfo(topicTypePrefix, list);
            }
            return(list);
        }
Ejemplo n.º 7
0
        public static DataTable GetForumAggerationHotTopics()
        {
            //从缓存读取主题列表
            Discuz.Cache.DNTCache cache        = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             hotTopicList = cache.RetrieveObject("/Aggregation/Hottopiclist") as DataTable;

            if (hotTopicList != null)
            {
                return(hotTopicList);
            }

            //无缓存查检config文件存在否
            string configPath = HttpContext.Current.Server.MapPath(BaseConfigs.GetForumPath + "config/agg_hottopics.config");

            if (!File.Exists(configPath))
            {
                return(new DataTable());
            }

            //从config文件中重建缓存
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(configPath);
                XmlNode node = xmlDoc.SelectSingleNode("/Aggregationinfo/Forum");
                if (node != null)
                {
                    DataSet topicDataSet = new DataSet();
                    using (MemoryStream topicListXml = new MemoryStream(Encoding.UTF8.GetBytes(Regex.Replace(node.InnerXml, "[\x00-\x08|\x0b-\x0c|\x0e-\x1f]", ""))))
                    {
                        topicDataSet.ReadXml(topicListXml);
                    }
                    if (topicDataSet.Tables.Count != 0)
                    {
                        hotTopicList = topicDataSet.Tables[0];
                    }
                    else
                    {
                        hotTopicList = new DataTable();
                    }
                }
                else
                {
                    hotTopicList = new DataTable();
                }
            }
            catch
            {
                hotTopicList = new DataTable();
            }

            //声明新的缓存策略接口
            //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy();
            //ics.TimeOut = 300;
            //cache.LoadCacheStrategy(ics);
            cache.AddObject("/Aggregation/Hottopiclist", hotTopicList, 300);
            //cache.LoadDefaultCacheStrategy();
            return(hotTopicList);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获得前台有效的模板ID列表
        /// </summary>
        /// <returns>模板ID列表</returns>
        public static string GetValidTemplateIDList()
        {
            lock (SynObject)
            {
                Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
                string templateidlist       = cache.RetrieveObject("/TemplateIDList") as string;
                if (templateidlist == null)
                {
                    DataTable     dt = DatabaseProvider.GetInstance().GetValidTemplateIDList();
                    StringBuilder sb = new StringBuilder();
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.Append(",");
                        sb.Append(dr[0].ToString());
                    }

                    try
                    {
                        if (!Utils.StrIsNullOrEmpty(sb.ToString()))
                        {
                            templateidlist = sb.ToString().Substring(1);
                        }
                        cache.AddObject("/TemplateIDList", templateidlist);
                    }
                    finally
                    {
                        dt.Dispose();
                    }
                }
                return(templateidlist);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获得在线用户总数量
        /// </summary>
        /// <returns>用户数量</returns>
        public static int GetOnlineAllUserCount()
        {
            int onlineUserCountCacheMinute = GeneralConfigs.GetConfig().OnlineUserCountCacheMinute;

            if (onlineUserCountCacheMinute == 0)
            {
                return(Discuz.Data.OnlineUsers.GetOnlineAllUserCount());
            }

            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            int onlineAllUserCount      = TypeConverter.ObjectToInt(cache.RetrieveObject("/Forum/OnlineUserCount"));

            if (onlineAllUserCount != 0)
            {
                return(onlineAllUserCount);
            }

            onlineAllUserCount = Discuz.Data.OnlineUsers.GetOnlineAllUserCount();
            //Discuz.Cache.ICacheStrategy ics = new RssCacheStrategy();
            //ics.TimeOut = onlineUserCountCacheMinute * 60;
            //cache.LoadCacheStrategy(ics);
            cache.AddObject("/Forum/OnlineUserCount", onlineAllUserCount, onlineUserCountCacheMinute * 60);
            //cache.LoadDefaultCacheStrategy();
            return(onlineAllUserCount);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 重建统计缓存
        /// </summary>
        public static void ReSetStatisticsCache()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataRow dr = DatabaseProvider.GetInstance().GetStatisticsRow();

            cache.RemoveObject("/Statistics");
            cache.AddObject("/Statistics", dr);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 获得到指定管理组信息
 /// </summary>
 /// <returns>管理组信息</returns>
 public static AdminGroupInfo[] GetAdminGroupList()
 {
     Discuz.Cache.DNTCache cache           = Discuz.Cache.DNTCache.GetCacheService();
     AdminGroupInfo[]      admingroupArray = cache.RetrieveObject("/Forum/AdminGroupList") as AdminGroupInfo[];
     if (admingroupArray == null)
     {
         admingroupArray = Discuz.Data.AdminGroups.GetAdminGroupList();
         cache.AddObject("/Forum/AdminGroupList", admingroupArray);
     }
     return(admingroupArray);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 得到用户在一分钟内搜索的次数。
        /// </summary>
        /// <returns></returns>
        public static int GetStatisticsSearchcount()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            int searchcount             = Utils.StrToInt(cache.RetrieveObject("/StatisticsSearchcount"), 0);

            if (searchcount == 0)
            {
                searchcount = 1;
                cache.AddObject("/StatisticsSearchcount", searchcount);
            }
            return(Utils.StrToInt(searchcount, 1));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取指定层数的商品分类
        /// </summary>
        /// <returns>json格式信息串</returns>
        public static string GetRootGoodsCategoriesJson()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string goodsCategoriesJson  = cache.RetrieveObject("/Mall/MallSetting/RootGoodsCategories") as string;

            if (goodsCategoriesJson == null)
            {
                goodsCategoriesJson = GetGoodsCategoryJsonData(DbProvider.GetInstance().GetGoodsCategoriesByLayer(1));
                cache.AddObject("/Mall/MallSetting/RootGoodsCategories", goodsCategoriesJson);
            }
            return(goodsCategoriesJson);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获得全部指定时间段内的前n条公告列表
        /// </summary>
        /// <param name="startDateTime">开始时间</param>
        /// <param name="endDateTime">结束时间</param>
        /// <param name="maxcount">最大记录数,小于0返回全部</param>
        /// <returns>公告列表</returns>
        public static DataTable GetSpecificAnnouncementList(string starttime, string endtime, int maxcount)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Forum/SimplifiedAnnouncementList") as DataTable;

            if (dt == null)
            {
                dt = Data.Announcements.GetAnnouncementList(maxcount);
                cache.AddObject("/Forum/SimplifiedAnnouncementList", dt);
            }
            return(dt);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 得到上一次执行搜索操作的时间
        /// </summary>
        /// <returns></returns>
        public static string GetStatisticsSearchtime()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string searchtime           = cache.RetrieveObject("/StatisticsSearchtime") as string;

            if (searchtime == null)
            {
                searchtime = DateTime.Now.ToString();
                cache.AddObject("/StatisticsSearchtime", searchtime);
            }
            return(searchtime);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 获得统计列
        /// </summary>
        /// <returns>统计列</returns>
        public static DataRow GetStatisticsRow()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataRow dr = cache.RetrieveObject("/Statistics") as DataRow;

            if (dr == null)
            {
                dr = DatabaseProvider.GetInstance().GetStatisticsRow();
                cache.AddObject("/Statistics", dr);
            }
            return(dr);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 获得用户组数据
        /// </summary>
        /// <returns>用户组数据</returns>
        public static List <UserGroupInfo> GetUserGroupList()
        {
            Discuz.Cache.DNTCache cache             = Discuz.Cache.DNTCache.GetCacheService();
            List <UserGroupInfo>  userGruopInfoList = cache.RetrieveObject("/Forum/UserGroupList") as List <UserGroupInfo>;

            if (userGruopInfoList == null)
            {
                userGruopInfoList = Discuz.Data.UserGroups.GetUserGroupList();
                cache.AddObject("/Forum/UserGroupList", userGruopInfoList);
            }
            return(userGruopInfoList);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 获得全部指定时间段内的前n条公告列表
        /// </summary>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        /// <param name="maxcount">最大记录数,小于0返回全部</param>
        /// <returns>公告列表</returns>
        public static DataTable GetSimplifiedAnnouncementList(string starttime, string endtime, int maxcount)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/SimplifiedAnnouncementList") as DataTable;

            if (dt == null)
            {
                dt = DatabaseProvider.GetInstance().GetSimplifiedAnnouncementList(starttime, endtime, maxcount);
                cache.AddObject("/SimplifiedAnnouncementList", dt);
            }
            return(dt);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 将店铺主题表以DataTable的方式存入缓存
        /// </summary>
        /// <returns>商品分类表</returns>
        public static DataTable GetShopThemesTable()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/Mall/MallSetting/ShopTheme") as DataTable;

            if (dt == null)
            {
                dt = DbProvider.GetInstance().GetShopThemes();
                cache.AddObject("/Mall/MallSetting/ShopTheme", dt);
            }
            return(dt);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 获得所有版主信息
        /// </summary>
        /// <returns>所有版主信息</returns>
        public static List <ModeratorInfo> GetModeratorList()
        {
            Discuz.Cache.DNTCache cache          = Discuz.Cache.DNTCache.GetCacheService();
            List <ModeratorInfo>  morderatorList = cache.RetrieveObject("/Forum/ModeratorList") as List <ModeratorInfo>;

            if (morderatorList == null)
            {
                morderatorList = Discuz.Data.Moderators.GetModeratorList();
                cache.AddObject("/Forum/ModeratorList", morderatorList);
            }
            return(morderatorList);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 获取指定路径下模板的宽度
        /// </summary>
        /// <param name="templatePath">模板名称</param>
        /// <returns></returns>
        public static int GetTemplateWidth(string templatePath)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            string width = cache.RetrieveObject("/Forum/TemplateWidth/" + templatePath) as string;

            if (width == null)
            {
                width = GetTemplateAboutInfo(Utils.GetMapPath(BaseConfigs.GetForumPath + "templates/" + templatePath + "/")).width;
                cache.AddObject("/Forum/TemplateWidth/" + templatePath, width);
            }
            return(TypeConverter.StrToInt(width));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 将系统设置的附件类型以DataTable的方式存入缓存
        /// </summary>
        /// <returns>系统设置的附件类型</returns>
        public static DataTable GetAttachmentType()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             dt    = cache.RetrieveObject("/ForumSetting/AttachmentType") as DataTable;

            if (dt == null)
            {
                dt = DatabaseProvider.GetInstance().GetAttachmentType();

                cache.AddObject("/ForumSetting/AttachmentType", dt);
            }
            return(dt);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 以CustomEditorButtonInfo数组形式返回自定义按钮
        /// </summary>
        /// <returns></returns>
        public static CustomEditorButtonInfo[] GetCustomEditButtonListWithInfo()
        {
            Discuz.Cache.DNTCache    cache       = Discuz.Cache.DNTCache.GetCacheService();
            CustomEditorButtonInfo[] buttonArray = cache.RetrieveObject("/Forum/UI/CustomEditButtonInfo") as CustomEditorButtonInfo[];
            if (buttonArray == null)
            {
                buttonArray = Discuz.Data.Editors.GetCustomEditButtonListWithInfo();
                cache.AddObject("/Forum/UI/CustomEditButtonInfo", buttonArray);

                // 表情缓存重新加载时重新初始化表情正则对象数组
                ResetRegexCustomTag(buttonArray);
            }
            return(buttonArray);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// 获得前台有效的模板列表
 /// </summary>
 /// <returns>模板列表</returns>
 public static DataTable GetValidTemplateList()
 {
     lock (SynObject)
     {
         Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
         DataTable             dt    = cache.RetrieveObject("/TemplateList") as DataTable;
         if (dt == null)
         {
             dt = DatabaseProvider.GetInstance().GetValidTemplateList();
             cache.AddObject("/TemplateList", dt);
         }
         return(dt);
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 获取帮助列表
        /// </summary>
        /// <returns>帮助列表</returns>
        public static List <HelpInfo> GetHelpList()
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
            helpListTree = cache.RetrieveObject("/Forum/helplist") as List <HelpInfo>;

            if (helpListTree == null)
            {
                helpListTree = new List <HelpInfo>();
                List <HelpInfo> helpList = Discuz.Data.Help.GetHelpList();

                CreateHelpTree(helpList, 0);
                cache.AddObject("/Forum/helplist", helpListTree);
            }
            return(helpListTree);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 返回在线用户图例
        /// </summary>
        /// <returns>在线用户图例</returns>
        private static DataTable GetOnlineGroupIconTable()
        {
            lock (SynObject)
            {
                Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
                DataTable             dt    = cache.RetrieveObject("/Forum/OnlineIconTable") as DataTable;

                if (dt == null)
                {
                    dt = Discuz.Data.OnlineUsers.GetOnlineGroupIconTable();
                    cache.AddObject("/Forum/OnlineIconTable", dt);
                }
                return(dt);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 获得帖子列表
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="views">最小浏览量</param>
        /// <param name="fid">板块ID</param>
        /// <param name="timetype">期限类型,一天、一周、一月、不限制</param>
        /// <param name="ordertype">排序类型,时间倒序、浏览量倒序、最后回复倒序</param>
        /// <param name="isdigest">是否精华</param>
        /// <param name="cachetime">缓存的有效期(单位:分钟)</param>
        /// <returns></returns>
        public static DataTable GetTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg)
        {
            //防止恶意行为
            if (cachetime == 0)
            {
                cachetime = 1;
            }
            if (count > 50)
            {
                count = 50;
            }
            if (count < 1)
            {
                count = 1;
            }

            string cacheKey = "/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}";

            cacheKey = string.Format(cacheKey,
                                     count,
                                     views,
                                     fid,
                                     timetype,
                                     ordertype,
                                     isdigest,
                                     onlyimg
                                     );

            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            DataTable dt = cache.RetrieveObject(cacheKey) as DataTable;

            if (dt == null)
            {
                dt = DatabaseProvider.GetInstance().GetFocusTopicList(count, views, fid, GetStartDate(timetype), GetFieldName(ordertype), Forums.GetVisibleForum(), isdigest, onlyimg);

                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new ForumCacheStrategy();
                ics.TimeOut = cachetime;
                cache.LoadCacheStrategy(ics);
                cache.AddObject(cacheKey, dt);
                cache.LoadDefaultCacheStrategy();
            }

            return(dt);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 返回在线用户图例
 /// </summary>
 /// <returns>在线用户图例</returns>
 private static DataTable GetOnlineGroupIconTable()
 {
     lock (SynObject)
     {
         Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();
         DataTable             dt    = cache.RetrieveObject("/OnlineIconTable") as DataTable;
         if (dt != null)
         {
             return(dt);
         }
         else
         {
             dt = DatabaseProvider.GetInstance().GetOnlineGroupIconTable();
             cache.AddObject("/OnlineIconTable", dt);
             return(dt);
         }
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// 获取用户单位时间内的发帖数
        /// </summary>
        /// <param name="topNumber">Top条数</param>
        /// <param name="dateType">时间类型</param>
        /// <param name="dateNum">时间数</param>
        /// <returns></returns>
        public List <UserPostCountInfo> GetUserPostCountList(int topNumber, DateType dateType, int dateNum)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            List <UserPostCountInfo> userPostCountInfoList = cache.RetrieveObject("/Aggregation/UserPostCountList") as List <UserPostCountInfo>;

            if (userPostCountInfoList == null)
            {
                userPostCountInfoList = Posts.GetUserPostCountList(topNumber, dateType, (dateNum > 1 ? dateNum : 1));

                //声明新的缓存策略接口
                //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy();
                //ics.TimeOut = 120;
                //cache.LoadCacheStrategy(ics);
                cache.AddObject("/UserPostCountList", userPostCountInfoList, 120);
                //cache.LoadDefaultCacheStrategy();
            }
            return(userPostCountInfoList);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 得到热门版块列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetHotForumList(int topnumber)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            DataTable __forumList = cache.RetrieveObject("/Aggregation/HotForumList") as DataTable;

            if (__forumList == null)
            {
                __forumList = DatabaseProvider.GetInstance().GetWebSiteAggHotForumList(topnumber <= 0 ? 10 : topnumber);

                //声明新的缓存策略接口
                Discuz.Cache.ICacheStrategy ics = new Discuz.Forum.ForumCacheStrategy();
                ics.TimeOut = 5;
                cache.LoadCacheStrategy(ics);
                cache.AddObject("/Aggregation/HotForumList", __forumList);
                cache.LoadDefaultCacheStrategy();
            }
            return(__forumList);
        }