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); }
public static int SetDigest(string topiclist, int val) { //string us = TopicAdmins.GetUserListWithDigestTopiclist(topiclist, (val > 0) ? 1 : 0); //int num = TopicAdmins.SetTopicStatus(topiclist, "digest", val); //if (num > 0) var list = Topic.FindAllByIDs(topiclist); if (list.Count > 0) { list.ToList().ForEach(e => e.Digest = val); list.Save(); // 过滤列表 if (val > 0) { list = list.FindAll(e => e.Digest <= 0); } else { list = list.FindAll(e => e.Digest > 0); } foreach (var item in list) { var user = item.PostUser; if (user == null) { continue; } user.DigestPosts = Topic.GetDigestCount(user.ID); user.Save(); if (val > 0) { CreditsFacade.SetDigest(user.ID); } else { CreditsFacade.UnDigest(user.ID); } } //if (Utils.IsNumericList(us)) //{ // // 更新用户有多少个主题被评分 // //BBX.Data.Users.UpdateUserDigest(us); // var users = User.FindAllByIdList(us); // foreach (var item in users) // { // item.DigestPosts = Topic.GetDigestCount(item.ID); // item.Save(); // } //} //if (!string.IsNullOrEmpty(us) && Utils.IsNumericList(us)) //{ // string[] array = Utils.SplitString(us, ","); // for (int i = 0; i < array.Length; i++) // { // string str = array[i]; // if (intValue > 0) // { // CreditsFacade.SetDigest(str.ToInt()); // } // else // { // CreditsFacade.UnDigest(str.ToInt()); // } // } //} } return(list.Count); }