示例#1
0
文件: Posts.cs 项目: xiongeee/BBX
 public static int DeletePost(Post pi, bool reserveAttach, bool chanagePostStatistic)
 {
     if (!reserveAttach)
     {
         //Attachments.DeleteAttachmentByPid(pid);
         Attachment.FindAllByPid(pi.ID).Delete();
     }
     //RateLogs.DeleteRateLog(pid);
     //PostInfo postInfo = GetPostInfo(postTableId, pid);
     //var pi = Post.FindByID(pid);
     CreditsFacade.DeletePost(pi, reserveAttach);
     //return BBX.Data.Posts.DeletePost(postTableId, pid, chanagePostStatistic);
     //return DatabaseProvider.GetInstance().DeletePost(postTableId, pid, chanagePostStatistic);
     return pi.Delete();
 }
示例#2
0
        public static int DeleteTopics(string topicList, int subTractCredits, bool reserveAttach)
        {
            if (!Utils.IsNumericList(topicList))
            {
                return(-1);
            }

            //DataTable topicList2 = Topics.GetTopicList(topicList);
            //var topicList2 = Topic.FindAllByTidsAndDisplayOrder(topicList, -10).ToDataTable(false);
            //if (topicList2 == null)
            //{
            //	return -1;
            //}
            //foreach (DataRow dataRow in topicList2.Rows)
            //{
            //	if (TypeConverter.ObjectToInt(dataRow["digest"]) > 0)
            //	{
            //		CreditsFacade.UnDigest(TypeConverter.ObjectToInt(dataRow["posterid"]));
            //	}
            //}
            var list = Topic.FindAllByIDs(topicList);

            if (list.Count == 0)
            {
                return(-1);
            }

            foreach (var item in list)
            {
                if (item.Digest > 0)
                {
                    CreditsFacade.UnDigest(item.PosterID);
                }
            }

            //var postList = Posts.GetPostList(topicList);
            var postList = Post.FindAllByTid(topicList.SplitAsInt(","));

            if (postList != null && postList.Count != 0)
            {
                //int fid = 0;
                //IXForum forumInfo = null;
                foreach (var pt in postList)
                {
                    //if (fid != pt.Fid)
                    //{
                    //	fid = pt.Fid;
                    //	forumInfo = Forums.GetForumInfo(fid);
                    //}
                    CreditsFacade.DeletePost(pt, reserveAttach);
                }
            }
            //int num2 = 0;
            //string[] postTableIdArray = Posts.GetPostTableIdArray(topicList);
            //for (int i = 0; i < postTableIdArray.Length; i++)
            //{
            //	string postTableId = postTableIdArray[i];
            //	//num2 = BBX.Data.TopicAdmins.DeleteTopicByTidList(topicList, postTableId);
            //	num2 = DatabaseProvider.GetInstance().DeleteTopicByTidList(topicList, postTableId, true);
            //}
            if (list.Delete() > 0 && !reserveAttach)
            {
                //Attachments.DeleteAttachmentByTid(topicList);
                Attachment.FindAllByTids(topicList).Delete();
            }
            return(list.Count);
        }