Ejemplo n.º 1
0
        //public static string GetOnlineGroupIconList()
        //{
        //    var cacheService = XCache.Current;
        //    string text = cacheService.RetrieveObject(CacheKeys.FORUM_UI_ONLINE_ICON_LIST) as string;
        //    if (text.IsNullOrEmpty())
        //    {
        //        StringBuilder stringBuilder = new StringBuilder();
        //        IDataReader onlineGroupIconList = DatabaseProvider.GetInstance().GetOnlineGroupIconList();
        //        string getForumPath = BaseConfigs.GetForumPath;
        //        try
        //        {
        //            while (onlineGroupIconList.Read())
        //            {
        //                stringBuilder.AppendFormat("<img src=\"{0}images/groupicons/{1}\" /> {2} &nbsp; &nbsp; &nbsp; ", getForumPath, onlineGroupIconList["img"], onlineGroupIconList["title"]);
        //            }
        //            text = stringBuilder.ToString();
        //            XCache.Add(CacheKeys.FORUM_UI_ONLINE_ICON_LIST, text);
        //        }
        //        finally
        //        {
        //            onlineGroupIconList.Close();
        //        }
        //    }
        //    return text;
        //}

        //public static string[,] GetBanWordList()
        //{
        //    var cacheService = XCache.Current;
        //    string[,] array = cacheService.RetrieveObject(CacheKeys.FORUM_BAN_WORD_LIST) as string[,];
        //    if (array == null)
        //    {
        //        //DataTable banWordList = DatabaseProvider.GetInstance().GetBanWordList();
        //        var banWordList = Word.FindAllWithCache();
        //        array = new string[banWordList.Count, 2];
        //        string text = "";
        //        var i = 0;
        //        foreach (var item in banWordList)
        //        {
        //            text = item.Key.Trim();
        //            foreach (Match match in Caches.r.Matches(text))
        //            {
        //                text = text.Replace(match.Groups[0].ToString(), match.Groups[0].ToString().Replace("{", ".{0,"));
        //            }
        //            array[i, 0] = Word.ConvertRegexCode(text);
        //            array[i, 1] = item.Replacement.Trim();
        //            i++;
        //        }
        //        XCache.Add(CacheKeys.FORUM_BAN_WORD_LIST, array);
        //        //banWordList.Dispose();
        //    }
        //    return array;
        //}

        //public static DataTable GetAvatarList()
        //{
        //	var cacheService = XCache.Current;
        //	DataTable dataTable = cacheService.RetrieveObject(CacheKeys.FORUM_COMMON_AVATAR_LIST) as DataTable;
        //	if (dataTable == null)
        //	{
        //		dataTable = new DataTable();
        //		dataTable.Columns.Add("filename", typeof(String));
        //		DirectoryInfo directoryInfo = new DirectoryInfo(Utils.GetMapPath(BaseConfigs.GetForumPath + "avatars/common/"));
        //		FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos();
        //		for (int i = 0; i < fileSystemInfos.Length; i++)
        //		{
        //			FileSystemInfo fileSystemInfo = fileSystemInfos[i];
        //			if (fileSystemInfo != null)
        //			{
        //				string text = fileSystemInfo.Extension.ToLower();
        //				if (text.Equals(".jpg") || text.Equals(".gif") || text.Equals(".png"))
        //				{
        //					DataRow dataRow = dataTable.NewRow();
        //					dataRow["filename"] = "avatars/common/" + fileSystemInfo.Name;
        //					dataTable.Rows.Add(dataRow);
        //				}
        //			}
        //		}
        //		XCache.Add(CacheKeys.FORUM_COMMON_AVATAR_LIST, dataTable);
        //	}
        //	return dataTable;
        //}

        public static string GetJammer()
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_UI_JAMMER) as string;

            if (text == null)
            {
                Random        random        = new Random((int)DateTime.Now.Ticks);
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 10; i++)
                {
                    stringBuilder.Append(Convert.ToChar(random.Next(1, 256)));
                }
                stringBuilder.Append(HttpContext.Current.Request.Url.Authority);
                for (int j = 0; j < 10; j++)
                {
                    stringBuilder.Append(Convert.ToChar(random.Next(1, 256)));
                }
                text = stringBuilder.ToString();
                text = Utils.HtmlEncode(text);
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Remove(0, stringBuilder.Length);
                }
                text = stringBuilder.AppendFormat("<span class=\"jammer\">{0}</span>", text).ToString();
                XCache.Add(CacheKeys.FORUM_UI_JAMMER, text, 720);
            }
            return(text);
        }
Ejemplo n.º 2
0
        public Int32 SelectCount(SelectBuilder sb, params String[] tableNames)
        {
            CheckBeforeUseDatabase();

            var cacheKey = "";
            var rs       = 0;

            if (EnableCache)
            {
                cacheKey = sb + "_SelectCount" + "_" + ConnName;
                if (XCache.TryGetItem(cacheKey, out rs))
                {
                    return(rs);
                }
            }

            Interlocked.Increment(ref _QueryTimes);
            rs = (Int32)Session.QueryCount(sb);

            if (EnableCache)
            {
                XCache.Add(cacheKey, rs, tableNames);
            }

            return(rs);
        }
Ejemplo n.º 3
0
        public static DataTable GetTemplateVarList(string forumpath, string skinName)
        {
            var       cacheService = XCache.Current;
            DataTable dataTable    = cacheService.RetrieveObject("/Forum/" + skinName + "/TemplateVariable") as DataTable;

            if (dataTable == null)
            {
                DataSet dataSet = new DataSet("template");
                var     file    = Utils.GetMapPath(forumpath + "templates/" + skinName + "/templatevariable.xml");

                if (Utils.FileExists(file))
                {
                    dataSet.ReadXml(file);
                    if (dataSet.Tables.Count == 0)
                    {
                        dataSet.Tables.Add(TemplateVariableTable());
                    }
                }
                else
                {
                    dataSet.Tables.Add(TemplateVariableTable());
                }
                dataTable = dataSet.Tables[0];
                XCache.Add("/Forum/" + skinName + "/TemplateVariable", dataTable, file);
            }
            return(dataTable);
        }
Ejemplo n.º 4
0
        public static string GetCurrentTopicTypesOption(int fid, string topictypes)
        {
            if (topictypes.IsNullOrEmpty() || topictypes == "|")
            {
                return("");
            }

            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/TopicTypesOption" + fid) as string;

            if (text == null)
            {
                var      stringBuilder = new StringBuilder("<option value=\"0\">分类</option>");
                string[] array         = topictypes.Replace("\r\n", "").Split('|');
                for (int i = 0; i < array.Length; i++)
                {
                    string text2 = array[i];
                    if (!Utils.StrIsNullOrEmpty(text2.Trim()))
                    {
                        stringBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", text2.Split(',')[0], text2.Split(',')[1]);
                    }
                }
                text = stringBuilder.ToString();
                XCache.Add("/Forum/TopicTypesOption" + fid, text);
            }
            return(text);
        }
Ejemplo n.º 5
0
        //public static string GetForumListBoxOptionsCache()
        //{
        //	return Caches.GetForumListBoxOptionsCache(false);
        //}

        public static string GetForumListMenuDivCache(int usergroupid, int userid, string extname)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_FORUM_LIST_MENU_DIV) as string;

            if (text.IsNullOrEmpty())
            {
                var sb        = new StringBuilder();
                var forumList = XForum.Root.Childs;
                if (forumList.Count > 0)
                {
                    sb.Append("<div class=\"popupmenu_popup\" id=\"forumlist_menu\" style=\"overflow-y: auto; display:none\">");
                    foreach (var item in forumList)
                    {
                        if (item.Visible && item.AllowView(7) && item.Layer == 0)
                        {
                            sb.AppendFormat("<dl><dt><a href=\"{0}\">{1}</a></dt><dd><ul>", BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(item.ID, 0, item.Field.RewriteName), item.Name);
                            foreach (var elm in item.Childs)
                            {
                                if (elm.Layer == 1 && elm.Visible)
                                {
                                    sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", BaseConfigs.GetForumPath + Urls.ShowForumAspxRewrite(elm.ID, 0, elm.Field.RewriteName), elm.Name);
                                }
                            }
                            sb.Append("</ul></dd></dl>");
                        }
                    }
                }
                sb.Append("</div>");
                text = sb.ToString().Replace("<dd><ul></ul></dd>", "");
                XCache.Add(CacheKeys.FORUM_FORUM_LIST_MENU_DIV, text);
            }
            return(text);
        }
Ejemplo n.º 6
0
        public static string GetForumRssXml(int ttl, int fid)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/RSS/Forum" + fid) as string;

            if (text == null)
            {
                var forumInfo = Forums.GetForumInfo(fid);
                if (forumInfo == null)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Specified forum not found</Rss>\r\n");
                }
                if (!forumInfo.AllowView(7))
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }
                if (!UserGroup.Guest.AllowVisit)
                {
                    return("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Rss>Guest Denied</Rss>\r\n");
                }
                text = BuildRssOutput(ttl, new Int32[] { fid }, forumInfo.Name);
                XCache.Add("/Forum/RSS/Forum" + fid, text, ttl * 60);
            }
            return(text);
        }
Ejemplo n.º 7
0
        public static string GetDropdownOptions()
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/DropdownOptions") as string;

            if (text == null)
            {
                var sb = new StringBuilder();
                //DataTable shortForumList = BBX.Data.Forums.GetShortForumList();
                //var shortForumList = XForum.Root.AllChilds.ToDataTable(false);
                string blank = Utils.HtmlDecode("&nbsp;&nbsp;&nbsp;&nbsp;");
                //DataRow[] array = shortForumList.Select("parentid=0");
                //for (int i = 0; i < array.Length; i++)
                //{
                //    DataRow dataRow = array[i];
                //    sb.AppendFormat("<option value=\"{0}\" disabled='true'>{1}</option>", dataRow[0].ToString().Trim(), dataRow[1].ToString().Trim());
                //    sb.Append(Forums.BindNode(dataRow[0].ToString().Trim(), shortForumList, blank));
                //}
                foreach (var item in XForum.Root.Childs)
                {
                    sb.AppendFormat("<option value=\"{0}\" disabled='true'>{1}</option>", item.ID, item.Name);
                    sb.Append(BindNode(item, blank));
                }
                text = sb.ToString();
                XCache.Add("/Forum/DropdownOptions", text);
            }
            return(text);
        }
Ejemplo n.º 8
0
        public DataSet Select(DbCommand cmd, String[] tableNames)
        {
            CheckBeforeUseDatabase();

            var     cacheKey = "";
            DataSet ds       = null;

            if (EnableCache)
            {
                cacheKey = cmd.CommandText + "_" + ConnName;
                if (XCache.TryGetItem(cacheKey, out ds))
                {
                    return(ds);
                }
            }

            Interlocked.Increment(ref _QueryTimes);
            ds = Session.Query(cmd);

            if (EnableCache)
            {
                XCache.Add(cacheKey, ds, tableNames);
            }

            return(ds);
        }
Ejemplo n.º 9
0
        //public static EntityList<Topic> GetDigestTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views)
        //{
        //	return Focuses.GetTopicList(count, views, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetRecentTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg)
        //{
        //	return Focuses.GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, "");
        //}

        public static EntityList <Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, Int32 ordertype, bool isdigest, int cachetime, bool onlyimg, string fidlist)
        {
            if (cachetime == 0)
            {
                cachetime = 1;
            }
            if (count > 50)
            {
                count = 50;
            }
            if (count < 1)
            {
                count = 1;
            }
            var order = Topic._FocusOrder[ordertype];

            string xpath        = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, order, isdigest, onlyimg, typeIdList.Replace(',', 'd'));
            var    cacheService = XCache.Current;

            var dataTable = cacheService.RetrieveObject(xpath) as EntityList <Topic>;

            if (dataTable == null)
            {
                if (String.IsNullOrEmpty(fidlist))
                {
                    fidlist = Forums.GetVisibleForum();
                }

                dataTable = Topic.GetFocusTopicList(count, views, fid, typeIdList, Focuses.GetStartDate(timetype), order, fidlist, isdigest, onlyimg);
                XCache.Add(xpath, dataTable, cachetime * 60);
            }
            return(dataTable);
        }
Ejemplo n.º 10
0
 public static string GetTemplateListBoxOptionsCache(bool topMenu)
 {
     lock (lockHelper)
     {
         var    key1 = CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS_FOR_FORUMINDEX;
         var    key2 = CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS;
         string text = topMenu ? XCache.Retrieve <String>(key1) : XCache.Retrieve <String>(key2);
         if (text.IsNullOrEmpty())
         {
             var sb = new StringBuilder();
             //var validTemplateList = Templates.GetValidTemplateList();
             foreach (var tmp in Template.GetValids())
             {
                 if (topMenu)
                 {
                     sb.AppendFormat("<li><a onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}';return false;\" href=\"###\"><i style=\"background: url(&quot;templates/{2}/about.png&quot;) no-repeat scroll 0% 0% transparent;\">&nbsp;</i><span>{3}</span><em></em></a></li>", BaseConfigs.GetForumPath, tmp.ID, tmp.Directory, tmp.Name.Trim());
                 }
                 else
                 {
                     sb.AppendFormat("<li><a onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}';return false;\" href=\"###\">{2}</a></li>", BaseConfigs.GetForumPath, tmp.ID, tmp.Name.Trim());
                 }
             }
             text = sb.ToString();
             XCache.Add(topMenu ? key1 : key2, text);
             //validTemplateList.Dispose();
         }
         return(text);
     }
 }
Ejemplo n.º 11
0
        /// <summary>获取帖子列表,带缓存</summary>
        /// <param name="inf"></param>
        /// <returns></returns>
        public static EntityList <Topic> GetTopicList(ForumHotItemInfo inf)
        {
            if (inf.Cachetimeout < 60)
            {
                inf.Cachetimeout = 60;
            }
            if (inf.Dataitemcount > 50)
            {
                inf.Dataitemcount = 50;
            }
            else if (inf.Dataitemcount < 1)
            {
                inf.Dataitemcount = 1;
            }

            var list = XCache.Current.RetrieveObject("/Forum/ForumHostList-" + inf.Id) as EntityList <Topic>;

            if (list == null)
            {
                string visibleFidList = string.IsNullOrEmpty(inf.Forumlist) ? Forums.GetVisibleForum() : inf.Forumlist;
                //string fieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), inf.Sorttype));
                var type = Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), inf.Datatimetype));
                list = Topic.GetFocusTopicList(inf.Dataitemcount, -1, 0, "", type, inf.Sorttype, visibleFidList, inf.Sorttype == "digest", false);
                if (inf.Cachetimeout > 0)
                {
                    XCache.Add("/Forum/ForumHostList-" + inf.Id, list, inf.Cachetimeout);
                }
            }
            return(list);
        }
Ejemplo n.º 12
0
        public List <Post> GetUserPostCountList(int topNumber, DateType dateType, int dateNum)
        {
            var list = XCache.Retrieve <List <Post> >("/Aggregation/UserPostCountList");

            if (list == null)
            {
                list = Post.GetUserPostCountList(topNumber, dateType, (dateNum > 1) ? dateNum : 1);
                XCache.Add("/UserPostCountList", list, 120);
            }
            return(list);
        }
Ejemplo n.º 13
0
        //public static DataRow GetStatisticsRow()
        //{
        //    var cacheService = XCache.Current;
        //    DataTable dataTable = cacheService.RetrieveObject(CacheKeys.FORUM_STATISTICS) as DataTable;
        //    if (dataTable == null)
        //    {
        //        dataTable = Discuz.Data.Statistics.GetStatisticsRow();
        //        XCache.Add(CacheKeys.FORUM_STATISTICS, dataTable);
        //    }
        //    return dataTable.Rows[0];
        //}
        //public static void GetPostCountFromForum(int fid, out int topiccount, out int postcount, out int todaypostcount)
        //{
        //    if (fid == 0)
        //    {
        //        Discuz.Data.Statistics.GetAllForumStatistics(out topiccount, out postcount, out todaypostcount);
        //        return;
        //    }
        //    Discuz.Data.Statistics.GetForumStatistics(fid, out topiccount, out postcount, out todaypostcount);
        //}
        //public static string GetStatisticsRowItem(string param)
        //{
        //    return Statistics.GetStatisticsRow()[param].ToString();
        //}
        public static string GetStatisticsSearchtime()
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_STATISTICS_SEARCHTIME) as string;

            if (text == null)
            {
                text = DateTime.Now.ToString();
                XCache.Add(CacheKeys.FORUM_STATISTICS_SEARCHTIME, text);
            }
            return(text);
        }
Ejemplo n.º 14
0
        public static int GetStatisticsSearchcount()
        {
            var cacheService = XCache.Current;
            int num          = Utils.StrToInt(cacheService.RetrieveObject(CacheKeys.FORUM_STATISTICS_SEARCHCOUNT), 0);

            if (num == 0)
            {
                num = 1;
                XCache.Add(CacheKeys.FORUM_STATISTICS_SEARCHCOUNT, num);
            }
            return(num);
        }
Ejemplo n.º 15
0
        public static int GetTemplateWidth(string templatePath)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/TemplateWidth/" + templatePath) as string;

            if (text == null)
            {
                text = Templates.GetTemplateAboutInfo(Utils.GetMapPath(BaseConfigs.GetForumPath + "templates/" + templatePath + "/")).width;
                XCache.Add("/Forum/TemplateWidth/" + templatePath, text);
            }
            return(TypeConverter.StrToInt(text));
        }
Ejemplo n.º 16
0
        public static string[] GetValidScoreName()
        {
            var cacheService = XCache.Current;

            string[] array = cacheService.RetrieveObject(CacheKeys.FORUM_VALID_SCORE_NAME) as string[];
            if (array == null)
            {
                array = GetValidScore(0);
                XCache.Add(CacheKeys.FORUM_VALID_SCORE_NAME, array);
            }
            return(array);
        }
Ejemplo n.º 17
0
        public static TagInfo[] GetCachedHotForumTags(int count)
        {
            var cacheService = XCache.Current;

            TagInfo[] array = cacheService.RetrieveObject("/Forum/Tag/Hot-" + count) as TagInfo[];
            if (array == null)
            {
                array = BBX.Data.ForumTags.GetCachedHotForumTags(count);
                XCache.Add("/Forum/Tag/Hot-" + count, array, 21600);
            }
            return(array);
        }
Ejemplo n.º 18
0
        public static List <Post> GetFirstPostInfo(int tid, int cachetime)
        {
            var cacheService = XCache.Current;
            var list         = cacheService.RetrieveObject("/Forum/HotForumFirst_" + tid) as List <Post>;

            if (list == null || list.Count == 0)
            {
                //list = Posts.GetPostList(tid.ToString());
                list = Post.FindAllByTid(tid);
                XCache.Add("/Forum/HotForumFirst_" + tid, list, cachetime * 60);
            }
            return(list);
        }
Ejemplo n.º 19
0
        private static EntityList <Attachment> HotImages(int count, int cachetime, string orderby, int tabid, string fidlist, int continuous)
        {
            var cacheService = XCache.Current;
            var list         = cacheService.RetrieveObject("/Aggregation/HotImages_" + tabid + "List") as EntityList <Attachment>;

            if (list == null)
            {
                //dataTable = DatabaseProvider.GetInstance().GetWebSiteAggHotImages(count, orderby, fidlist, continuous);
                list = Attachment.GetWebSiteAggHotImages(count, orderby, fidlist, continuous);
                XCache.Add("/Aggregation/HotImages_" + tabid + "List", list, cachetime * 60);
            }
            return(list);
        }
Ejemplo n.º 20
0
        //public static bool AllowPostAttach(string postattachperm, int usergroupid)
        //{
        //    return Forums.HasPerm(postattachperm, usergroupid);
        //}

        public static List <IXForum> GetForumList()
        {
            var cacheService = XCache.Current;
            var list         = cacheService.RetrieveObject(CacheKeys.FORUM_FORUM_LIST) as List <IXForum>;

            if (list == null || list.Count == 0)
            {
                //list = BBX.Data.GetForumList();
                list = XForum.Root.AllChilds.Cast <IXForum>().ToList();
                XCache.Add(CacheKeys.FORUM_FORUM_LIST, list);
            }
            return(list);
        }
Ejemplo n.º 21
0
        //public DataTable GetUserList(int topNumber, string orderBy)
        //{
        //    var cacheService = XCache.Current;
        //    DataTable dataTable = XCache.Retrieve<DataTable>("/Aggregation/Users_" + orderBy + "List");
        //    if (dataTable == null)
        //    {
        //        dataTable = BBX.Forum.Users.GetUserList(topNumber, 1, orderBy, "desc");
        //        XCache.Add("/Aggregation/Users_" + orderBy + "List", dataTable, 300);
        //    }
        //    return dataTable;
        //}

        public EntityList <Post> GetLastPostList(int fid, int count)
        {
            var cacheService = XCache.Current;
            var list         = XCache.Retrieve <EntityList <Post> >("/Aggregation/lastpostList_" + fid);

            if (list == null)
            {
                //list = DatabaseProvider.GetInstance().GetLastPostList(fid, count, TableList.CurrentTableName, BBX.Forum.Forums.GetVisibleForum());
                list = Post.GetLastPostList(fid, count);
                XCache.Add("/Aggregation/lastpostList_" + fid, list, 300);
            }
            return(list);
        }
Ejemplo n.º 22
0
        public List <IXForum> GetHotForumList(int topNumber, string orderby, int fid)
        {
            orderby = ((String.IsNullOrEmpty(orderby)) ? "posts" : orderby);
            var cacheService = XCache.Current;
            var list         = XCache.Retrieve <List <IXForum> >("/Aggregation/HotForumList");

            if (list == null)
            {
                list = XForum.GetWebSiteAggHotForumList((topNumber <= 0) ? 10 : topNumber, orderby, fid);
                XCache.Add("/Aggregation/HotForumList", list, 300);
            }
            return(list);
        }
Ejemplo n.º 23
0
        public static DataTable GetForumAggregationTopic(int fid)
        {
            var cacheService = XCache.Current;
            var dataTable    = cacheService.RetrieveObject("/Aggregation/TopicByForumId_" + fid) as DataTable;

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

            string text = HttpContext.Current.Server.MapPath(BaseConfigs.GetForumPath + "config/agg_" + fid + ".config");

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

            var xmlDocument = new XmlDocument();

            try
            {
                xmlDocument.Load(text);
                var xmlNode = xmlDocument.SelectSingleNode("/Aggregationinfo/Forum");
                if (xmlNode != null)
                {
                    var dataSet = new DataSet();
                    using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(Regex.Replace(xmlNode.InnerXml, "[\0-\b|\v-\f|\u000e-\u001f]", ""))))
                    {
                        dataSet.ReadXml(memoryStream);
                    }
                    if (dataSet.Tables.Count != 0)
                    {
                        dataTable = dataSet.Tables[0];
                    }
                    else
                    {
                        dataTable = new DataTable();
                    }
                }
                else
                {
                    dataTable = new DataTable();
                }
            }
            catch
            {
                dataTable = new DataTable();
            }
            XCache.Add("/Aggregation/TopicByForumId_" + fid, dataTable, 300);
            return(dataTable);
        }
Ejemplo n.º 24
0
        public static Smilie[] GetSmiliesListWithInfo()
        {
            var cacheService = XCache.Current;
            var array        = cacheService.RetrieveObject(CacheKeys.FORUM_UI_SMILIES_LIST_WITH_INFO) as Smilie[];

            if (array == null)
            {
                //array = BBX.Data.GetSmiliesListWithoutType();
                array = Smilie.FindAllWithCache().ToList().Where(e => e.Type != 0).ToArray();
                XCache.Add(CacheKeys.FORUM_UI_SMILIES_LIST_WITH_INFO, array);
                ResetRegexSmilies(array);
            }
            return(array);
        }
Ejemplo n.º 25
0
        private static string GetScoresCache(string cacheKey)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/Scoreset/" + cacheKey) as string;

            if (text == null)
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(scoreFilePath);
                text = dataSet.Tables["formula"].Rows[0][cacheKey.ToLower()].ToString();
                XCache.Add("/Forum/Scoreset/" + cacheKey, text);
            }
            return(text);
        }
Ejemplo n.º 26
0
 public static bool CreateShowTopicCacheFile(int tid, int pageid, string pagetext)
 {
     if (IsGuestCachePage(pageid, "showtopic"))
     {
         var cacheService = XCache.Current;
         if (!string.IsNullOrEmpty(pagetext))
         {
             pagetext = pagetext + "\r\n<!-- " + Utils.ProductName + " CachedPage (Created: " + Utils.GetDateTime() + ") -->\r\n";
             XCache.Add("/Forum/ShowTopicGuestCachePage/Tid_" + tid + "/Page_" + pageid + "/", pagetext, GeneralConfigInfo.Current.Guestcachepagetimeout * 60);
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 27
0
        //private static Regex r = new Regex("\\{(\\d+)\\}", Utils.GetRegexCompiledOptions());

        public static string GetForumListBoxOptionsCache(bool cateUnselectable)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_UI_FORUM_LIST_BOX_OPTIONS) as string;

            if (text.IsNullOrEmpty())
            {
                StringBuilder stringBuilder = new StringBuilder();
                //Caches.AddOptionTree(BBX.Data.Forums.GetVisibleForumList(), "0", cateUnselectable, stringBuilder);
                Caches.AddOptionTree(XForum.GetVisibleForumList(), 0, cateUnselectable, stringBuilder);
                text = stringBuilder.ToString();
                XCache.Add(CacheKeys.FORUM_UI_FORUM_LIST_BOX_OPTIONS, text);
            }
            return(text);
        }
Ejemplo n.º 28
0
 public static bool CreateShowForumCacheFile(int fid, int pageid, string pagetext)
 {
     if (IsGuestCachePage(pageid, "showforum"))
     {
         var cacheService = XCache.Current;
         if (!string.IsNullOrEmpty(pagetext))
         {
             pagetext = pagetext + "\r\n<!-- " + Utils.ProductName + " CachedPage (Created: " + Utils.GetDateTime() + ") -->";
             //XCache.Add("/Forum/ShowForumGuestCachePage/Fid_" + fid + "/Page_" + pageid + "/", pagetext, mcci.ApplyMemCached ? (mcci.CacheShowForumCacheTime * 60) : (rci.CacheShowForumCacheTime * 60));
             XCache.Add("/Forum/ShowForumGuestCachePage/Fid_" + fid + "/Page_" + pageid + "/", pagetext, 0);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 29
0
        //public static string GetSmiliesCache()
        //{
        //    string text = XCache.Retrieve<String>(CacheKeys.FORUM_UI_SMILIES_LIST);
        //    if (text.IsNullOrEmpty())
        //    {
        //        var sb = new StringBuilder();
        //        //DataTable smiliesListDataTable = BBX.Data.Smilies.GetSmiliesListDataTable();
        //        var list = Smilie.FindAllWithCache();
        //        foreach (var sm in list)
        //        {
        //            if (sm.Type != 0) continue;

        //            sb.AppendFormat("'{0}': [\r\n", sm.Code.Trim().Replace("'", "\\'"));
        //            bool flag = false;
        //            foreach (var sm2 in list)
        //            {
        //                if (sm2.Type == sm.ID)
        //                {
        //                    sb.Append("{'code' : '");
        //                    sb.Append(sm2.Code.Trim().Replace("'", "\\'"));
        //                    sb.Append("', 'url' : '");
        //                    sb.Append(sm2.Url.Trim().Replace("'", "\\'"));
        //                    sb.Append("'},\r\n");
        //                    flag = true;
        //                }
        //            }
        //            if (sb.Length > 0 && flag)
        //            {
        //                sb.Remove(sb.Length - 3, 3);
        //            }
        //            sb.Append("\r\n],\r\n");
        //        }
        //        sb.Remove(sb.Length - 3, 3);
        //        text = sb.ToString();
        //        XCache.Add(CacheKeys.FORUM_UI_SMILIES_LIST, text);
        //    }
        //    return text;
        //}

        //public static string GetSmiliesFirstPageCache()
        //{
        //	string text = XCache.Retrieve<String>("/Forum/UI/SmiliesListFirstPage");
        //	if (text.IsNullOrEmpty())
        //	{
        //		var sb = new StringBuilder();
        //		//DataTable smiliesListDataTable = BBX.Data.Smilies.GetSmiliesListDataTable();
        //		var list = Smilie.FindAllWithCache();
        //		foreach (var sm in list)
        //		{
        //			if (sm.Type != 0) continue;

        //			sb.AppendFormat("'{0}': [\r\n", sm.Code.Trim().Replace("'", "\\'"));
        //			bool flag = false;
        //			int num = 0;
        //			foreach (var sm2 in list)
        //			{
        //				if (sm2.Type == sm.ID && num < 16)
        //				{
        //					sb.Append("{'code' : '");
        //					sb.Append(sm2.Code.Trim().Replace("'", "\\'"));
        //					sb.Append("', 'url' : '");
        //					sb.Append(sm2.Url.Trim().Replace("'", "\\'"));
        //					sb.Append("'},\r\n");
        //					flag = true;
        //					num++;
        //				}
        //			}
        //			if (sb.Length > 0 && flag)
        //			{
        //				sb.Remove(sb.Length - 3, 3);
        //			}
        //			sb.Append("\r\n],\r\n");
        //			break;
        //		}
        //		sb.Remove(sb.Length - 3, 3);
        //		text = sb.ToString();
        //		XCache.Add("/Forum/UI/SmiliesListFirstPage", text);
        //	}
        //	return text;
        //}

        //public static DataTable GetSmilieTypesCache()
        //{
        //    DataTable dataTable = XCache.Retrieve<DataTable>("/Forum/UI/SmiliesTypeList");
        //    if (dataTable == null || dataTable.Rows.Count == 0)
        //    {
        //        dataTable = BBX.Data.Smilies.GetSmiliesTypes();
        //        XCache.Add("/Forum/UI/SmiliesTypeList", dataTable);
        //    }
        //    return dataTable;
        //}

        public static string GetCustomEditButtonList()
        {
            string result;

            lock (lockHelper)
            {
                string text = XCache.Retrieve <String>(CacheKeys.FORUM_UI_CUSTOM_EDIT_BUTTON_LIST);
                if (text == null)
                {
                    var sb = new StringBuilder();
                    //var customEditButtonList = DatabaseProvider.GetInstance().GetCustomEditButtonList();
                    var customEditButtonList = BbCode.FindAllByAvailable(1);
                    //try
                    //{
                    foreach (var bb in customEditButtonList)
                    //while (customEditButtonList.Read())
                    {
                        sb.AppendFormat(",'{0}':['", Utils.ReplaceStrToScript(bb.Tag));
                        sb.Append(Utils.ReplaceStrToScript(bb.Tag));
                        sb.Append("','");
                        sb.Append(Utils.ReplaceStrToScript(bb.Icon));
                        sb.Append("','");
                        sb.Append(Utils.ReplaceStrToScript(bb.Explanation));
                        sb.Append("',['");
                        sb.Append(Utils.ReplaceStrToScript(bb.ParamsDescript).Replace(",", "','"));
                        sb.Append("'],['");
                        sb.Append(Utils.ReplaceStrToScript(bb.ParamsDefValue).Replace(",", "','"));
                        sb.Append("'],");
                        sb.Append(Utils.ReplaceStrToScript(bb.Params + ""));
                        sb.Append("]");
                    }
                    if (sb.Length > 0)
                    {
                        sb.Remove(0, 1);
                    }
                    text = Utils.ClearBR(sb.ToString());
                    XCache.Add(CacheKeys.FORUM_UI_CUSTOM_EDIT_BUTTON_LIST, text);
                    //}
                    //finally
                    //{
                    //	customEditButtonList.Close();
                    //}
                }
                result = text;
            }
            return(result);
        }
Ejemplo n.º 30
0
        public static DataTable GetValidTemplateList()
        {
            DataTable result;

            lock (Templates.SynObject)
            {
                var       cacheService = XCache.Current;
                DataTable dataTable    = cacheService.RetrieveObject("/Forum/TemplateList") as DataTable;
                if (dataTable == null)
                {
                    dataTable = Discuz.Data.Templates.GetValidTemplateList();
                    XCache.Add("/Forum/TemplateList", dataTable);
                }
                result = dataTable;
            }
            return(result);
        }