Пример #1
0
        /// <summary>
        /// 设置精华,同时也处理了个人的精华统计,积分
        /// </summary>
        public void SetDigest(string tids, int digest)
        {
            new BLL.Forum_Topic().UpdateField("id in (" + tids + ")", "[Digest]=" + digest);

            System.Data.DataTable dt = GetList("id in (" + tids + ")").Tables[0];

            string strSql = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (digest == 1)
                {
                    strSql = "UPDATE [" + siteConfig.sysdatabaseprefix + "Forum_UserExtended]SET [PostDigestCount] = [PostDigestCount]+1 WHERE [UserId] = " + dt.Rows[i]["PostUserId"] + ";";

                    //获得实际积分
                    int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(Convert.ToInt32(dt.Rows[i]["BoardId"]), 3);

                    new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " Credit=Credit+" + _point);
                }
                else
                {
                    strSql = "UPDATE [" + siteConfig.sysdatabaseprefix + "Forum_UserExtended]SET [PostDigestCount] = [PostDigestCount]-1 WHERE  [PostDigestCount]>0 and [UserId] = " + dt.Rows[i]["PostUserId"] + ";";

                    //获得实际积分
                    int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(Convert.ToInt32(dt.Rows[i]["BoardId"]), 4);

                    new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " Credit=Credit+" + _point);
                }
            }

            if (!string.IsNullOrEmpty(strSql))
            {
                DbHelperSQL.ExecuteSql(strSql);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据,内部已经处理分表回贴,版块统计,属归作者表,积分
        /// </summary>
        public int Add(Model.Forum_Topic model, out int _subTable_id, out int _post_id)
        {
            Forum_PostSubTable bllSubTable = new Forum_PostSubTable();
            Forum_Board        bllBoard    = new Forum_Board();

            Model.Forum_PostSubTable modelSubTable = bllSubTable.GetModel("Avail=1");

            //分表ID
            _subTable_id = modelSubTable.Id;

            model.PostSubTable = _subTable_id;

            //主题表ID
            int _topic_id = dal.Add(model);

            //回复表ID
            _post_id = new Forum_PostId().Add(new Model.Forum_PostId {
                TopicId = _topic_id
            });

            new Forum_Post(_subTable_id).Add(model, new Model.Forum_Post
            {
                BoardId      = model.BoardId,
                Message      = model.Message,
                Title        = model.Title,
                PostDateTime = model.PostDatetime,
                PostNickname = model.PostNickname,
                PostUsername = model.PostUsername,
                PostUserId   = model.PostUserId,
                Id           = _post_id,
                TopicId      = _topic_id,
                First        = 1
            });

            //版块包括父级版块的统计、标记最后发贴

            string strValue = "[TodayTopicCount]=[TodayTopicCount]+1,[TopicCount]=[TopicCount]+1,[LastPostUserId]=" + model.PostUserId + ",[LastPostUsername]='" + model.PostUsername.Replace("'", "") + "',[LastPostNickname]='" + model.PostNickname.Replace("'", "") + "',[LastTopicId]=" + _topic_id + ",[LastTopicTitle]='" + model.Title.Replace("'", "") + "'";

            Model.Forum_Board modelBoard = bllBoard.GetModel(model.BoardId);

            bllBoard.UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue);

            //文章归属
            new Forum_MyTopic().Add(new Model.Forum_MyTopic {
                TopicId = _topic_id, UserId = model.PostUserId
            });

            //获得实际积分
            int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 1);

            new Forum_UserExtended().UpdateField(model.PostUserId, " TopicCount=TopicCount+1 ,Credit=Credit+" + _point);

            modelSubTable.TopicCount += 1;

            bllSubTable.Update(modelSubTable);

            return(_topic_id);
        }
Пример #3
0
        /// <summary>
        /// 删除回贴,标题统计,版块统计,积分一并处理,有附件的一并处理
        /// </summary>
        public void DeleterReply(string rids, int topic_id)
        {
            Model.Forum_Topic modelTopic = GetModel(topic_id);

            System.Data.DataTable dt = new BLL.Forum_Post(modelTopic.PostSubTable).GetList(" id in (" + rids + ") ").Tables[0];

            //获得实际积分
            int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(modelTopic.BoardId, 6);

            BLL.Forum_Attachment bllAtt = new Forum_Attachment();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " PostCount=PostCount-1 , Credit=Credit+" + _point);

                //附件处理

                if (Convert.ToInt32(dt.Rows[i]["Attachment"]) != 0)
                {
                    List <Model.Forum_Attachment> dtAtt = bllAtt.GetModelList(" PostId=" + dt.Rows[i]["id"].ToString());

                    foreach (Model.Forum_Attachment item in dtAtt)
                    {
                        bllAtt.Delete(item, item.Id);
                    }
                }
            }

            string strSql = "DELETE [" + siteConfig.sysdatabaseprefix + "Forum_Post_" + modelTopic.PostSubTable + "]  WHERE ID in (" + rids + ")";

            //影响记录数相当于删了多少条数据
            int _count = 0;

            if (!string.IsNullOrEmpty(strSql))
            {
                _count = DbHelperSQL.ExecuteSql(strSql);
            }

            modelTopic.ReplayCount = modelTopic.ReplayCount - _count;

            Update(modelTopic);

            //版块包括父级版块的统计

            string strValue = "[PostCount]=[PostCount]-" + _count + "";

            Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(modelTopic.BoardId);

            new Forum_Board().UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue);

            new Forum_PostId().DeleteList(rids);

            new Forum_PostSubTable().UpdateField(modelTopic.PostSubTable, " PostCount=PostCount-" + _count);
        }
Пример #4
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("plugin_forum_boardactionpoint", DTEnums.ActionEnum.Add.ToString()); //检查权限

            BLL.Forum_BoardActionPoint bll = new BLL.Forum_BoardActionPoint();
            Repeater rptList = new Repeater();

            rptList = this.rptList;
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);

                int intPoint;
                if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtPoint")).Text.Trim(), out intPoint))
                {
                    intPoint = 0;
                }

                int      intEnable = 0;
                CheckBox cb        = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    intEnable = 1;
                }

                bool bol = bll.UpdateField("ActionId=" + id + " and BoardId=" + board_id, "Enable=" + intEnable + " , Point=" + intPoint.ToString());

                if (bol == false)
                {
                    Model.Forum_BoardActionPoint model = new Model.Forum_BoardActionPoint();

                    model.ActionId = id;
                    model.BoardId  = board_id;
                    model.Enable   = intEnable;
                    model.Point    = intPoint;

                    bll.Add(model);
                }

                //同步所有版块
                if (Convert.ToInt32(ddlSYN.SelectedValue) == 1)
                {
                    bll.UpdateField("ActionId=" + id, " Point=" + intPoint.ToString());
                }
            }

            JscriptMsg("操作成功!", "board_action_point_list.aspx?board_id=" + this.board_id);
        }
Пример #5
0
        /// <summary>
        /// 内部标题表的统计、版块的回贴统计及最后回贴人,积分,回贴归属
        /// </summary>
        public void Add(Model.Forum_Topic modelTopic, Model.Forum_Post modelPost)
        {
            modelTopic.LastPostUserId   = modelPost.PostUserId;
            modelTopic.LastPostNickname = modelPost.PostNickname;
            modelTopic.LastPostUsername = modelPost.PostUsername;
            modelTopic.LastPostDatetime = System.DateTime.Now;
            modelTopic.ReplayCount      = modelTopic.ReplayCount + 1;

            //主题与回贴不是同一人才记录入回复记录表
            if (modelTopic.PostUserId != modelPost.PostUserId)
            {
                //回贴归属
                new Forum_MyPost().Add(new Model.Forum_MyPost {
                    TopicId = modelTopic.Id, UserId = modelPost.PostUserId, PostId = modelPost.Id
                });
            }

            //更新主题
            new Forum_Topic().Update(modelTopic);

            //版块统计
            Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(modelTopic.BoardId);

            string strIds = "0" + modelBoard.ClassList + "0";

            string strSql = "UPDATE [" + siteConfig.sysdatabaseprefix + "Forum_Board] SET  [PostCount]=[PostCount]+1  WHERE Id in (" + strIds + ")";

            DbHelperSQL.ExecuteSql(strSql);

            dal.Add(modelPost);

            //除了标题贴
            if (modelPost.First == 0)
            {
                //获得实际积分
                int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(modelTopic.BoardId, 2);
                new Forum_UserExtended().UpdateField(modelPost.PostUserId, " PostCount=PostCount+1 ,Credit=Credit+" + _point);
                new BLL.Forum_PostSubTable().UpdateField(modelTopic.PostSubTable, " PostCount=PostCount+1 ");
            }
        }
Пример #6
0
        /// <summary>
        /// 内部 删除一条数据及主题的回贴并重新统计版块的主题总数,积分,我的主题,我的回复一起清除
        /// </summary>
        public bool Delete(int Id)
        {
            Model.Forum_Topic model = GetModel(Id);

            //--删除回复----------------------------------

            System.Data.DataTable dt = new BLL.Forum_Post(model.PostSubTable).GetList(9999999, " TopicId=" + Id + " ", " id asc ").Tables[0];

            //获得实际积分,调整,删除主题不牵联其它已经回复者的积分
            //int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 6);

            BLL.Forum_Attachment bllAtt = new Forum_Attachment();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToInt32(dt.Rows[i]["First"].ToString()) == 0)
                {
                    new Forum_UserExtended().UpdateField(Convert.ToInt32(dt.Rows[i]["PostUserId"]), " PostCount=PostCount-1 ");
                }

                //附件处理

                if (Convert.ToInt32(dt.Rows[i]["Attachment"]) != 0)
                {
                    List <Model.Forum_Attachment> dtAtt = bllAtt.GetModelList(" PostId=" + dt.Rows[i]["id"].ToString());

                    foreach (Model.Forum_Attachment item in dtAtt)
                    {
                        bllAtt.Delete(item, item.Id);
                    }
                }
            }

            //------------------------------------

            new BLL.Forum_Post(model.PostSubTable).DeleteTopicId(Id);

            //版块包括父级版块的统计

            string strValue = "[TopicCount]=[TopicCount]-1,[PostCount]=[PostCount]-" + model.ReplayCount;

            Model.Forum_Board modelBoard = new BLL.Forum_Board().GetModel(model.BoardId);

            string strIds = "0" + modelBoard.ClassList + "0";

            new Forum_Board().UpdateField(" Id in (" + strIds + ") ", strValue);

            new Forum_PostSubTable().UpdateField(model.PostSubTable, " TopicCount=TopicCount-1,PostCount=PostCount-" + model.ReplayCount);

            //获得实际积分
            int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 5);

            new Forum_UserExtended().UpdateField(model.PostUserId, " TopicCount=TopicCount-1, Credit=Credit+" + _point);

            //--主题清空随之 我的主题,我的回复一起清除----------------------------------
            new BLL.Forum_MyTopic().Delete("TopicId=" + Id);

            new BLL.Forum_MyPost().Delete("TopicId=" + Id);

            return(dal.Delete(Id));
        }