Esempio n. 1
0
        /// <summary>执行CMD,返回受影响的行数</summary>
        /// <param name="cmd"></param>
        /// <param name="tableNames"></param>
        /// <returns></returns>
        public Int32 Execute(DbCommand cmd, String[] tableNames)
        {
            CheckBeforeUseDatabase();

            // 移除所有和受影响表有关的缓存
            if (EnableCache)
            {
                XCache.Remove(tableNames);
            }

            Interlocked.Increment(ref _ExecuteTimes);
            Int32 ret = Session.Execute(cmd);

            Session.AutoClose();
            return(ret);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private void DelAds_Click(object sender, EventArgs e)
        {
            if (base.CheckCookie())
            {
                String ads = Request["advid"];
                if (ads != "")
                {
                    //Advertisements.DeleteAdvertisementList(Request["advid"]);
                    Advertisement.DeleteAll(ads);

                    XCache.Remove(CacheKeys.FORUM_ADVERTISEMENTS);
                    base.RegisterStartupScript("PAGE", "window.location.href='advsgrid.aspx';");
                    return;
                }
                base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='advsgrid.aspx';</script>");
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 private void addrota_Click(object sender, EventArgs e)
 {
     if (this.rotaimg.Text.Trim() != "" && this.url.Text.Trim() != "" && this.titlecontent.Text.Trim() != "")
     {
         if (!Utils.IsURL(this.rotaimg.Text.Trim()) || !Utils.IsURL(this.url.Text.Trim()))
         {
             base.RegisterStartupScript("", "<script>alert('图片路径或点击链接可能是非法URL');</script>");
             this.BindData();
             this.ResetForm();
             return;
         }
         XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender();
         xmlDocumentExtender.Load(this.configPath);
         int num = 0;
         if (xmlDocumentExtender.SelectSingleNode(this.targetNode) != null && xmlDocumentExtender.SelectSingleNode(this.targetNode).InnerText != "")
         {
             num = int.Parse(xmlDocumentExtender.SelectSingleNode(this.targetNode).LastChild["rotatepicid"].InnerText);
         }
         num++;
         XmlElement newChild = xmlDocumentExtender.CreateElement(this.nodeName);
         xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "rotatepicid", num.ToString());
         xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "pagetype", "1");
         xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "img", this.rotaimg.Text.Trim());
         xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "url", this.url.Text.Trim());
         xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "titlecontent", this.titlecontent.Text.Trim());
         xmlDocumentExtender.CreateNode(this.targetNode).AppendChild(newChild);
         xmlDocumentExtender.Save(this.configPath);
         AggregationFacade.BaseAggregation.ClearAllDataBind();
         AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加聚合页图版轮换广告", "添加聚合页图版轮换广告,名称为: " + this.titlecontent.Text.Trim());
         try
         {
             this.BindData();
             XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST);
             this.ResetForm();
             base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';");
             return;
         }
         catch
         {
             base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';</script>");
             return;
         }
     }
     base.RegisterStartupScript("", "<script>alert('图片或链接地址以及标题不能为空.');window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';</script>");
 }
Esempio n. 6
0
        public static void InsertMedalList(ArrayList medalFiles)
        {
            medalFiles.Remove("thumbs.db");
            DataTable existMedalList = BBX.Data.Medals.GetExistMedalList();

            foreach (DataRow dataRow in existMedalList.Rows)
            {
                medalFiles.Remove(dataRow["image"].ToString().ToLower());
            }
            int num = TypeConverter.ObjectToInt(existMedalList.Rows[existMedalList.Rows.Count - 1]["medalid"]) + 1;

            for (int i = 0; i < medalFiles.Count; i++)
            {
                int num2 = num + i;
                Medals.InsertMedal(num2, "Medal No." + num2, medalFiles[i].ToString());
            }
            XCache.Remove(CacheKeys.FORUM_UI_MEDALS_LIST);
        }
Esempio n. 7
0
        public void LoadTemplateData()
        {
            string msg  = "由于目录 : ";
            var    ids  = new List <Int32>();
            var    list = Template.GetValids();

            foreach (var tmp in list)
            {
                var dir = tmp.Directory;
                if (!dir.IsNullOrEmpty() && !dir.EqualIgnoreCase("default") && !Directory.Exists(path.CombinePath(dir)))
                {
                    msg = msg + dir + " ,";
                    ids.Add(tmp.ID);
                }
            }
            if (ids.Count > 0)
            {
                base.RegisterStartupScript("", "<script>alert('" + msg.Substring(0, msg.Length - 1) + "已被删除, 因此系统将自动更新模板列表!')</script>");
                //AdminTemplates.DeleteTemplateItem(ids);
                Template.Delete(ids);
                AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "从数据库中删除模板文件", "ID为:" + ids.Join());
                XCache.Remove(CacheKeys.FORUM_TEMPLATE_ID_LIST);
                //Templates.GetValidTemplateIDList();
            }
            else
            {
                try
                {
                    var tmps = Template.Import(path);
                    foreach (var item in tmps)
                    {
                        AdminVisitLog.InsertLog(userid, username, usergroupid, grouptitle, ip, "模板文件入库", item.Name);
                        this.CreateTemplateByDirectory(item.Directory);
                    }
                }
                catch (Exception ex)
                {
                    base.RegisterStartupScript("", "<script>alert('" + ex.Message + "');window.location.href='global_templatesgrid.aspx';</script>");
                }
            }
            this.DataGrid1.AllowCustomPaging = false;
            this.DataGrid1.DataSource        = Template.FindAllWithCache();
            this.DataGrid1.DataBind();
        }
Esempio n. 8
0
        private void IntoDB_Click(object sender, EventArgs e)
        {
            if (!base.CheckCookie())
            {
                return;
            }

            var tids = Request["templateid"].SplitAsInt();

            if (tids.Length == 0)
            {
                base.RegisterStartupScript("", "<script>alert('您未选中任何选项'); window.location.href='global_templatesgrid.aspx';</script>");
            }
            //if (tids.Contains(1))
            //{
            //    base.RegisterStartupScript("", "<script>alert('选中的模板中含有系统初始化模板,此次提交无法执行');window.location.href='global_templatesgrid.aspx'</script>");
            //    return;
            //}
            var list = Template.GetValids();

            // 这里可以遍历templates目录来入库模版,AboutInfo可加载基本信息
            //throw new NotImplementedException("未实现模版入库!");
            for (int i = 0; i < tids.Length; i++)
            {
                try
                {
                    var tmp = Template.FindByID(tids[i]);
                    tmp.Import(null, tmp.Directory);
                    tmp.Enable = true;
                    tmp.Save();
                }
                catch (Exception ex)
                {
                    base.RegisterStartupScript("", "<script>alert('" + ex.Message + "');window.location.href='global_templatesgrid.aspx';</script>");
                }
            }

            XCache.Remove("/Forum/TemplateList");
            XCache.Remove(CacheKeys.FORUM_TEMPLATE_ID_LIST);
            XCache.Remove(CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS_FOR_FORUMINDEX);
            XCache.Remove(CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS);
            base.RegisterStartupScript("PAGE", "window.location.href='global_templatesgrid.aspx';");
        }
Esempio n. 9
0
        public static int CreateForums(IXForum forumInfo, out string moderatorsInfo, int adminUid, string adminUserName, int adminUserGruopId, string adminUserGroupTitle, string adminIp)
        {
            //int result = BBX.Data.Forums.CreateForumInfo(forumInfo);
            var result = forumInfo.Insert();

            //SetForumsPathList();
            moderatorsInfo = SetForumsModerators(result.ToString(), forumInfo.Moderators, forumInfo.Inheritedmod).Replace("'", "’");
            var cache = XCache.Current;

            XCache.Remove(CacheKeys.FORUM_UI_FORUM_LIST_BOX_OPTIONS);
            XCache.Remove(CacheKeys.FORUM_FORUM_LIST);
            XCache.Remove("/Aggregation/HotForumList");
            XCache.Remove("/Aggregation/ForumHotTopicList");
            XCache.Remove("/Aggregation/ForumNewTopicList");
            XCache.Remove("/Forum/DropdownOptions");
            XCache.Remove(CacheKeys.FORUM_FORUM_LIST_MENU_DIV);
            AdminVisitLog.InsertLog(adminUid, adminUserName, adminUserGruopId, adminUserGroupTitle, adminIp, "添加论坛版块", "添加论坛版块,名称为:" + forumInfo.Name);
            return(result);
        }
Esempio n. 10
0
        public static DataTable GetScoreSet()
        {
            DataTable result;

            lock (lockHelper)
            {
                var       cacheService = XCache.Current;
                DataTable dataTable    = cacheService.RetrieveObject("/Forum/ScoreSet") as DataTable;
                if (dataTable == null)
                {
                    DataSet dataSet = new DataSet();
                    dataSet.ReadXml(scoreFilePath);
                    dataTable = dataSet.Tables[0];
                    XCache.Add("/Forum/ScoreSet", dataTable, scoreFilePath);
                }
                result = dataTable;
            }
            return(result);
        }
Esempio n. 11
0
        public static IList <User> GetReportUsers()
        {
            var cacheService = XCache.Current;
            var ht           = cacheService.RetrieveObject("/Forum/ReportUsers") as IList <User>;

            if (ht == null)
            {
                ht = new List <User>();
                string reportusergroup = GeneralConfigInfo.Current.Reportusergroup;
                if (!Utils.IsNumericList(reportusergroup))
                {
                    return(ht);
                }
                var list = User.FindAllByGroupID(reportusergroup.ToInt());
                ht = list;
                XCache.Add("/Forum/ReportUsers", ht);
            }
            return(ht);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public static void RemoveTemplateInDB(string templateIdList, int uid, string userName, int groupId, string groupTitle, string ip)
        {
            GeneralConfigInfo config = GeneralConfigInfo.Current;

            if (("," + templateIdList + ",").IndexOf("," + config.Templateid + ",") >= 0)
            {
                config.Templateid = 1;
            }
            //GeneralConfigs.Serialiaze(config, Utils.GetMapPath("../../config/general.config"));
            config.Save();
            Discuz.Data.Forums.UpdateForumAndUserTemplateId(templateIdList);
            Discuz.Data.Templates.DeleteTemplateItem(templateIdList);
            var cache = XCache.Current;

            XCache.Remove("/Forum/TemplateList");
            XCache.Remove(CacheKeys.FORUM_TEMPLATE_ID_LIST);
            XCache.Remove(CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS_FOR_FORUMINDEX);
            XCache.Remove(CacheKeys.FORUM_UI_TEMPLATE_LIST_BOX_OPTIONS);
            AdminVisitLog.InsertLog(uid, userName, groupId, groupTitle, ip, "从数据库中删除模板文件", "ID为:" + templateIdList);
        }
Esempio n. 14
0
        public static string UpdateForumInfo(IXForum forumInfo)
        {
            //BBX.Data.Forums.UpdateForumInfo(forumInfo);
            forumInfo.Save();

            var cache = XCache.Current;

            XCache.Remove(CacheKeys.FORUM_FORUM_LIST);
            //SetForumsPathList();
            string result = SetForumsModerators(forumInfo.ID.ToString(), forumInfo.Moderators, forumInfo.Inheritedmod);

            XCache.Remove(CacheKeys.FORUM_UI_FORUM_LIST_BOX_OPTIONS);
            XCache.Remove(CacheKeys.FORUM_FORUM_LIST);
            XCache.Remove("/Forum/TopicTypesOption" + forumInfo.ID);
            XCache.Remove("/Forum/TopicTypesLink" + forumInfo.ID);
            XCache.Remove("/Aggregation/HotForumList");
            XCache.Remove("/Aggregation/ForumHotTopicList");
            XCache.Remove("/Aggregation/ForumNewTopicList");
            return(result);
        }
Esempio n. 15
0
        public static IUser[] GetUserList(int topNumber, string orderBy, int cachetime, int tabid)
        {
            var cacheService = XCache.Current;

            IUser[] array = cacheService.RetrieveObject("/Aggregation/Users_" + tabid + "List") as IUser[];
            if (array == null)
            {
                if (Utils.InArray(orderBy, "lastactivity,joindate"))
                {
                    //List<IUser> list = new List<IUser>();
                    //DataTable userList = Users.GetUserList(topNumber, 1, orderBy, "desc");
                    //foreach (DataRow dataRow in userList.Rows)
                    //{
                    //    list.Add(new IUser
                    //    {
                    //        Uid = TypeConverter.ObjectToInt(dataRow["uid"]),
                    //        Username = dataRow["username"].ToString(),
                    //        Lastactivity = dataRow["lastactivity"].ToString(),
                    //        JoinDate = dataRow["joindate"].ToString()
                    //    });
                    //}
                    //array = list.ToArray();
                    array = User.FindAll(null, orderBy, null, 0, topNumber).ToArray();
                }
                else
                {
                    array = Stats.GetUserArray(orderBy);
                    if (array.Length > topNumber)
                    {
                        var list2 = new List <IUser>();
                        for (int i = 0; i < topNumber; i++)
                        {
                            list2.Add(array[i]);
                        }
                        array = list2.ToArray();
                    }
                }
                XCache.Add("/Aggregation/Users_" + tabid + "List", array, cachetime * 60);
            }
            return(array);
        }
Esempio n. 16
0
        public static List <IXForum> GetHotForumList(int topNumber, string orderby, int cachetime, int tabid)
        {
            var cacheService = XCache.Current;
            var list         = cacheService.RetrieveObject("/Aggregation/HotForumList_" + tabid) as List <IXForum>;

            if (list == null)
            {
                list = Stats.GetForumArray(orderby).Cast <IXForum>().ToList();
                if (list.Count > topNumber)
                {
                    var list2 = new List <IXForum>();
                    for (int i = 0; i < topNumber; i++)
                    {
                        list2.Add(list[i]);
                    }
                    list = list2;
                }
                XCache.Add("/Aggregation/HotForumList" + tabid, list, cachetime * 60);
            }
            return(list);
        }
Esempio n. 17
0
        public static string GetValidTemplateIDList()
        {
            string result;

            lock (Templates.SynObject)
            {
                var    cacheService = XCache.Current;
                string text         = cacheService.RetrieveObject(CacheKeys.FORUM_TEMPLATE_ID_LIST) as string;
                if (text == null)
                {
                    text = Discuz.Data.Templates.GetValidTemplateIDList();
                    if (!Utils.StrIsNullOrEmpty(text))
                    {
                        text = text.Substring(1);
                    }
                    XCache.Add(CacheKeys.FORUM_TEMPLATE_ID_LIST, text);
                }
                result = text;
            }
            return(result);
        }
Esempio n. 18
0
        public static bool IsSetDownLoadAttachScore()
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/IsSetDownLoadAttachScore") as string;

            if (text.IsNullOrEmpty())
            {
                float[] userExtCredits = GetUserExtCredits(CreditsOperationType.DownloadAttachment);
                float[] array          = userExtCredits;
                for (int i = 0; i < array.Length; i++)
                {
                    float num = array[i];
                    if ((double)num < 0.0)
                    {
                        XCache.Add("/Forum/IsSetDownLoadAttachScore", "true");
                        return(true);
                    }
                }
            }
            return(text.ToBoolean());
        }
Esempio n. 19
0
        public static bool DeleteTopicCacheFile(int tid)
        {
            int num = 1;

            //if (mcci != null && mcci.ApplyMemCached)
            //{
            //    num = mcci.CacheShowTopicPageNumber;
            //}
            //else
            //{
            //    if (rci != null && rci.ApplyRedis)
            //    {
            //        num = rci.CacheShowTopicPageNumber;
            //    }
            //}
            for (int i = 1; i < num; i++)
            {
                XCache.Remove("/Forum/ShowTopicGuestCachePage/Tid_" + tid + "/Page_" + i + "/");
            }
            return(true);
        }
Esempio n. 20
0
        public static DataTable GetScorePaySet(int type)
        {
            var       cacheService = XCache.Current;
            DataTable dataTable    = (type == 0) ? (cacheService.RetrieveObject(CacheKeys.FORUM_SCORE_PAY_SET) as DataTable) : (cacheService.RetrieveObject("/Forum/ScorePaySet1") as DataTable);

            if (dataTable == null)
            {
                DataTable scoreSet   = GetScoreSet();
                DataTable dataTable2 = new DataTable();
                dataTable2.Columns.Add("id", typeof(Int32));
                dataTable2.Columns.Add("name", typeof(String));
                dataTable2.Columns.Add("rate", typeof(Single));
                for (int i = 1; i <= 8; i++)
                {
                    bool flag = !Utils.StrIsNullOrEmpty(scoreSet.Rows[0]["extcredits" + i].ToString());
                    if (type == 0)
                    {
                        flag = (flag && scoreSet.Rows[2]["extcredits" + i].ToString() != "0");
                    }
                    if (flag)
                    {
                        DataRow dataRow = dataTable2.NewRow();
                        dataRow["id"]   = i;
                        dataRow["name"] = scoreSet.Rows[0]["extcredits" + i.ToString()].ToString().Trim();
                        dataRow["rate"] = (Single)scoreSet.Rows[2]["extcredits" + i].ToDouble();
                        dataTable2.Rows.Add(dataRow);
                    }
                }
                if (type == 0)
                {
                    XCache.Add(CacheKeys.FORUM_SCORE_PAY_SET, dataTable2);
                }
                else
                {
                    XCache.Add("/Forum/ScorePaySet1", dataTable2);
                }
                dataTable = dataTable2;
            }
            return(dataTable);
        }
Esempio n. 21
0
        public static string GetBaiduSitemap(int ttl)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject("/Forum/Sitemap/Baidu") as string;

            if (text == null)
            {
                var guest = UserGroup.Guest;
                var sb    = new StringBuilder();
                foreach (var item in Forums.GetForumList())
                {
                    if (!item.AllowRss)
                    {
                        sb.AppendFormat(",{0}", item.Fid);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(item.ViewPerm))
                        {
                            if (!guest.AllowVisit)
                            {
                                sb.AppendFormat(",{0}", item.Fid);
                            }
                        }
                        else
                        {
                            if (!Utils.InArray("7", item.ViewPerm, ","))
                            {
                                sb.AppendFormat(",{0}", item.Fid);
                            }
                        }
                    }
                }
                sb = ((sb.Length > 0) ? sb.Remove(0, 1) : sb);
                var user = User.FindByID(BaseConfigs.GetFounderUid);
                text = GetBaiduSitemap(sb.ToString(), user);
                XCache.Add("/Forum/Sitemap/Baidu", text, ttl * 60);
            }
            return(text);
        }
Esempio n. 22
0
        protected override void OnUnload(EventArgs e)
        {
            var pname  = this.pagename;
            var req    = HttpContext.Current.Request;
            var pcount = req.Form.Count + req.QueryString.Count;

            if (this.isguestcachepage == 1 && pname != null)
            {
                int page = DNTRequest.GetQueryInt("page", 1);
                switch (pname)
                {
                case "index.aspx":
                    var cacheService = XCache.Current;
                    if (!(cacheService.RetrieveObject("/Forum/GuestCachePage/" + this.pagename) is string) && this.templateBuilder.Length > 1 && this.templateid == this.config.Templateid)
                    {
                        this.templateBuilder.Append("\r\n\r\n<!-- " + Utils.ProductName + " CachedPage (Created: " + Utils.GetDateTime() + ") -->");
                        XCache.Add("/Forum/GuestCachePage/" + this.pagename, this.templateBuilder.ToString());
                    }
                    break;

                case "showtopic.aspx":
                    int topicid = DNTRequest.GetQueryInt("topicid", 0);
                    if ((pcount == 2 || pcount == 3) && topicid > 0 && this.templateid == this.config.Templateid)
                    {
                        ForumUtils.CreateShowTopicCacheFile(topicid, page, this.templateBuilder.ToString());
                    }
                    break;

                case "showforum.aspx":
                    int forumid = DNTRequest.GetQueryInt("forumid", 0);
                    if ((pcount == 2 || pcount == 3) && forumid > 0 && this.templateid == this.config.Templateid)
                    {
                        ForumUtils.CreateShowForumCacheFile(forumid, page, this.templateBuilder.ToString());
                    }
                    break;
                }
            }
            base.OnUnload(e);
        }
Esempio n. 23
0
        private void SaveTopic_Click(object sender, EventArgs e)
        {
            string @string = Request["forumtopicstatus"];

            if (String.IsNullOrEmpty(@string))
            {
                if (File.Exists(this.configPath))
                {
                    XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender();
                    xmlDocumentExtender.Load(this.configPath);
                    xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Data/Hottopiclist");
                    xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Forum/Hottopiclist");
                    xmlDocumentExtender.Save(this.configPath);
                    XCache.Remove("/Aggregation/Hottopiclist");
                }
                base.Response.Redirect("aggregation_forumhottopic.aspx");
                return;
            }
            Posts.WriteAggregationHotTopicsData(@string, this.configPath, "/Aggregationinfo/Data/Hottopiclist", "/Aggregationinfo/Forum/Hottopiclist");
            XCache.Remove("/Aggregation/Hottopiclist");
            base.Response.Redirect("aggregation_edithottopic.aspx");
        }
Esempio n. 24
0
        public static string GetRssXml(int ttl)
        {
            var    cacheService = XCache.Current;
            string text         = cacheService.RetrieveObject(CacheKeys.FORUM_RSS_INDEX) as string;

            if (text == null)
            {
                var guest = UserGroup.Guest;
                //var sb = new StringBuilder();
                // 查找支持RSS或者匿名访客浏览的论坛版面
                var fids = new List <Int32>();
                foreach (var item in Forums.GetForumList())
                {
                    if (item.AllowRss)
                    {
                        if (!item.Viewperm.IsNullOrEmpty())
                        {
                            if (Utils.InArray("7", item.Viewperm, ","))
                            {
                                //sb.AppendFormat(",{0}", current.Fid);
                                fids.Add(item.Fid);
                            }
                        }
                        else
                        {
                            if (guest.AllowVisit)
                            {
                                //sb.AppendFormat(",{0}", current.Fid);
                                fids.Add(item.Fid);
                            }
                        }
                    }
                }
                //text = BBX.Data.Feeds.BuildRssOutput(ttl, sb.ToString().Trim(','), "");
                text = BuildRssOutput(ttl, fids.ToArray(), "");
                XCache.Add(CacheKeys.FORUM_RSS_INDEX, text, ttl * 60);
            }
            return(text);
        }
Esempio n. 25
0
        public DataSet Select(String sql, params String[] tableNames)
        {
            CheckBeforeUseDatabase();

            var     cacheKey = sql + "_" + ConnName;
            DataSet ds       = null;

            if (EnableCache && XCache.TryGetItem(cacheKey, out ds))
            {
                return(ds);
            }

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

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

            return(ds);
        }
Esempio n. 26
0
        public Int32 SelectCount(String sql, params String[] tableNames)
        {
            CheckBeforeUseDatabase();

            String cacheKey = sql + "_SelectCount" + "_" + ConnName;
            Int32  rs       = 0;

            if (EnableCache && XCache.TryGetItem(cacheKey, out rs))
            {
                return(rs);
            }

            Interlocked.Increment(ref _QueryTimes);
            // 为了向前兼容,这里转为Int32,如果需要获取Int64,可直接调用Session
            rs = (Int32)Session.QueryCount(sql);

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

            return(rs);
        }
Esempio n. 27
0
        /// <summary>执行SQL查询,返回总记录数</summary>
        /// <param name="sb">查询生成器</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public Int32 SelectCount(SelectBuilder sb, params String[] tableNames)
        {
            CheckBeforeUseDatabase();

            String sql      = sb.ToString();
            String cacheKey = sql + "_SelectCount" + "_" + ConnName;
            Int32  rs       = 0;

            if (EnableCache && 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);
        }
Esempio n. 28
0
        /// <summary>执行CMD,返回记录集</summary>
        /// <param name="cmd">CMD</param>
        /// <param name="tableNames">所依赖的表的表名</param>
        /// <returns></returns>
        public DataSet Select(DbCommand cmd, String[] tableNames)
        {
            CheckBeforeUseDatabase();

            var     cacheKey = cmd.CommandText + "_" + ConnName;
            DataSet ds       = null;

            if (EnableCache && XCache.TryGetItem(cacheKey, out ds))
            {
                return(ds);
            }

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

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

            Session.AutoClose();
            return(ds);
        }
Esempio n. 29
0
        /************************************************************************************************************************/

        internal void Init(IDbConnection conn)
        {
            //
            if (XConfig.DB == DbEnum.None)
            {
                if (XConfig.MySQL.Equals(conn.GetType().FullName, StringComparison.OrdinalIgnoreCase))
                {
                    XConfig.DB = DbEnum.MySQL;
                }
                else
                {
                    throw new Exception("MyDAL 目前只支持 【MySQL】,后续将会支持【Oracle/SQLServer/PostgreSQL/DB2/Access/SQLite/Teradata/MariaDB】.");
                }
            }

            //
            Conn       = conn;
            Parameters = new List <DicParam>();
            AH         = new AttributeHelper(this);
            VH         = new CsValueHelper(this);
            GH         = new GenericHelper(this);
            EH         = new XExpression(this);
            CFH        = new CsFuncHelper();
            TSH        = new ToStringHelper();
            XC         = new XCache(this);
            PH         = new ParameterHelper(this);
            DPH        = new DicParamHelper(this);
            BDH        = new BatchDataHelper();
            DS         = new DataSource(this);
            AR         = new AutoRetry();

            //
            if (XConfig.DB == DbEnum.MySQL)
            {
                SqlProvider = new MySqlProvider(this);
            }
        }
Esempio n. 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.BindData();
            }
            if (DNTRequest.GetString("displayorder") != "" && DNTRequest.GetString("name") != "")// Request["displayorder"].IsNullOrEmpty() && Request["name"].IsNullOrEmpty())
            {
                Regex regex = new Regex("(http|https)://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?");
                if (!regex.IsMatch(Request["url"].Replace("'", "''")))
                {
                    base.RegisterStartupScript("", "<script>alert('链接地址不是有效的网页地址.');</script>");
                    return;
                }
                try
                {
                    //ForumLinks.CreateForumLink(DNTRequest.GetInt("displayorder", 0), Request["name"], Request["url"], Request["note"], Request["logo"]);

                    var lnk = new ForumLink();
                    lnk.DisplayOrder = WebHelper.RequestInt("displayorder");
                    lnk.Name         = Request["name"];
                    lnk.Url          = Request["url"];
                    lnk.Note         = Request["note"];
                    lnk.Logo         = Request["logo"];
                    lnk.Save();

                    AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加友情链接", "添加友情链接,名称为: " + Request["name"]);
                    XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST);
                    this.BindData();
                }
                catch
                {
                    base.RegisterStartupScript("", "<script>alert('无法更新数据库');window.location.href='global_forumlinksgrid.aspx';</script>");
                }
            }
        }