Beispiel #1
0
        private void SaveTopicType_Click(object sender, EventArgs e)
        {
            int  num  = 0;
            bool flag = false;

            foreach (object current in this.DataGrid1.GetKeyIDArray())
            {
                string s             = current.ToString();
                Int32  typeid        = Int32.Parse(s);
                string controlValue  = this.DataGrid1.GetControlValue(num, "name");
                string controlValue2 = this.DataGrid1.GetControlValue(num, "displayorder");
                string controlValue3 = this.DataGrid1.GetControlValue(num, "description");
                if (!this.CheckValue(controlValue, controlValue2, controlValue3) || TopicType.IsExist(controlValue, typeid))
                {
                    flag = true;
                }
                else
                {
                    var sortedList = TopicType.GetTopicTypeArray();
                    //DataTable existTopicTypeOfForum = Forums.GetExistTopicTypeOfForum();
                    DataTable topicTypes = TopicType.FindAllWithCache().ToDataTable();
                    foreach (var item in XForum.Root.AllChilds)
                    {
                        var text = item.Field.TopicTypes + "";
                        if (String.IsNullOrEmpty(text.Trim()))
                        {
                            continue;
                        }

                        string topicTypeString = this.GetTopicTypeString(text, sortedList[typeid].ToString().Trim());
                        if (!(String.IsNullOrEmpty(topicTypeString)))
                        {
                            string value = topicTypeString.Replace("," + sortedList[typeid].ToString().Trim() + ",", "," + controlValue + ",");
                            text = text.Replace(topicTypeString + "|", "");
                            ArrayList arrayList = new ArrayList();
                            string[]  array     = text.Split('|');
                            for (int i = 0; i < array.Length; i++)
                            {
                                string text2 = array[i];
                                if (text2 != "")
                                {
                                    arrayList.Add(text2);
                                }
                            }
                            bool flag2 = false;
                            for (int j = 0; j < arrayList.Count; j++)
                            {
                                int displayOrder = this.GetDisplayOrder(arrayList[j].ToString().Split(',')[1], topicTypes);
                                if (displayOrder > int.Parse(controlValue2))
                                {
                                    arrayList.Insert(j, value);
                                    flag2 = true;
                                    break;
                                }
                            }
                            if (!flag2)
                            {
                                arrayList.Add(value);
                            }
                            text = "";
                            foreach (object current2 in arrayList)
                            {
                                text = text + current2.ToString() + "|";
                            }

                            //TopicTypes.UpdateForumTopicType(text, int.Parse(dataRow["fid"].ToString()));
                            //var ff = ForumField.FindByID(int.Parse(dataRow["fid"].ToString()));
                            var ff = item.Field;
                            if (ff != null)
                            {
                                ff.TopicTypes = text;
                                ff.Save();
                            }
                            XCache.Remove("/Forum/TopicTypesOption" + item.ID);
                            XCache.Remove("/Forum/TopicTypesLink" + item.ID);
                        }
                    }

                    //TopicTypes.UpdateTopicTypes(controlValue, int.Parse(controlValue2), controlValue3, typeid);
                    var entity = TopicType.FindByID(typeid);
                    if (entity != null)
                    {
                        entity.Name         = controlValue;
                        entity.DisplayOrder = Int32.Parse(controlValue);
                        entity.Description  = controlValue3;
                        entity.Save();
                    }
                    num++;
                }
            }

            //XCache.Remove("/Forum/TopicTypes");
            XCache.Remove(CacheKeys.FORUM_FORUM_LIST);
            if (flag)
            {
                base.RegisterStartupScript("", "<script>alert('数据库中已存在相同的主题分类名称或为空,该记录不能被更新!');window.location.href='forum_topictypesgrid.aspx';</script>");
                return;
            }
            base.RegisterStartupScript("PAGE", "window.location.href='forum_topictypesgrid.aspx';");
        }
Beispiel #2
0
        protected override void ShowPage()
        {
            this.topic = base.GetTopicInfo();
            if (this.topic == null)
            {
                return;
            }
            this.topicid = this.topic.ID;
            this.forumid = this.topic.Fid;
            this.forum   = Forums.GetForumInfo(this.forumid);
            if (this.forum == null)
            {
                base.AddErrLine("不存在的版块ID");
                return;
            }
            if (!base.ValidateInfo() || base.IsErr())
            {
                return;
            }
            base.IsModer();
            int topicPrice = this.GetTopicPrice(this.topic);

            if (this.topic.Special == 0 && topicPrice > 0)
            {
                HttpContext.Current.Response.Redirect(this.forumpath + "buytopic.aspx?topicid=" + this.topic.ID);
                return;
            }
            if (this.postid > 0 && Post.FindByID(this.postid) == null)
            {
                base.AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", base.ShowTopicAspxRewrite(this.topicid, 1)));
                return;
            }
            ForumUtils.SetVisitedForumsCookie(this.forumid.ToString());
            if (this.userid > 0)
            {
                this.userInfo = BBX.Entity.User.FindByID(this.userid);
            }
            if (this.topic.Identify > 0)
            {
                this.topicidentify = TopicIdentify.FindByID(this.topic.Identify);
            }
            this.pagetitle = string.Format("{0} - {1}", this.topic.Title, Utils.RemoveHtml(this.forum.Name));
            base.GetForumAds(this.forum.Fid);
            TopicType.GetTopicTypeArray().TryGetValue(this.topic.TypeID, out this.topictypes);
            this.topictypes         = (this.topictypes.IsNullOrEmpty() ? "" : ("[" + this.topictypes + "]"));
            this.userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            this.score       = Scoresets.GetValidScoreName();
            this.scoreunit   = Scoresets.GetValidScoreUnit();
            this.navhomemenu = Caches.GetForumListMenuDivCache(this.usergroupid, this.userid, this.config.Extname);
            base.EditorState();
            string[] array = this.config.Customauthorinfo.Split('|');
            this.postleftshow = array[0].Split(',');
            this.userfaceshow = array[1].Split(',');
            this.onlyauthor   = ((this.onlyauthor == "1" || this.onlyauthor == "2") ? this.onlyauthor : "0");
            this.BindPageCountAndId();
            base.GetPostAds(this.GetPostPramsInfo(topicPrice), this.postlist.Count);
            //this.bonuslogs = Bonus.GetLogs(this.topic);
            if (this.topic.Special == 3)
            {
                this.bonuslogs = BonusLog.GetLogs(this.topic.ID);
            }
            if (this.topic.Special == 1)
            {
                this.GetPollInfo();
            }
            if (this.topic.Special == 4)
            {
                this.GetDebateInfo();
            }
            this.enabletag = config.Enabletag && forum.AllowTag;
            if (this.postlist != null && this.postlist.Count > 0)
            {
                base.UpdateMetaInfo(Utils.RemoveHtml(this.postlist[0].Message));
            }
            this.IsGuestCachePage();
            //Topic.UpdateViewCount(this.topicid, 1);
            topic.Views++;
            topic.SaveAsync(10000);
            Topics.MarkOldTopic(this.topic);
            this.topicviews = this.topic.Views;
            Online.UpdateAction(this.olid, UserAction.ShowTopic, this.forumid, this.forum.Name, this.topicid, this.topic.Title);
            if (DNTRequest.GetInt("fromfav", 0) > 0)
            {
                //Favorites.UpdateUserFavoriteViewTime(this.userid, this.topicid);
                var fav = Favorite.FindByUidAndTid(userid, topicid);
                if (fav != null)
                {
                    fav.ViewTime = DateTime.Now;
                    fav.Update();
                }
            }
        }