示例#1
0
        /// <summary>
        /// 更新主题中的附件标志
        /// </summary>
        /// <param name="tid">主题id</param>
        public static void UpdateTopicAttachment(int tid)
        {
            int attachmentCount = 0;

            if (appDBCache)
            {
                attachmentCount = IAttachmentService.GetAttachmentCountByTid(tid);
            }
            else
            {
                attachmentCount = DatabaseProvider.GetInstance().GetAttachmentCountByTid(tid);
            }

            if (Topics.appDBCache)
            {
                TopicInfo topicInfo = Topics.GetTopicInfo(tid, 0, 0);
                topicInfo.Attachment = attachmentCount;
                Topics.ITopicService.UpdateTopic(topicInfo);
            }
            DatabaseProvider.GetInstance().UpdateTopicAttachment(tid, attachmentCount > 0 ? 1 : 0);
        }
示例#2
0
        /// <summary>
        /// 删除指定附件id的附件同时更新主题和帖子中的附件个数
        /// </summary>
        /// <param name="aid">附件id</param>
        /// <param name="pid">附件所属帖子id</param>
        /// <param name="tid">附件所属主题id</param>
        private static void DeleteAttachment(string aidlist, int pid, int tid)
        {
            if (appDBCache)
            {
                IAttachmentService.DeleteAttachment(aidlist);
            }

            DatabaseProvider.GetInstance().DelMyAttachmentByAid(aidlist);
            if (tid > 0)
            {
                if (DatabaseProvider.GetInstance().GetAttachmentCountByPid(pid) <= 0)
                {
                    string postTableId = PostTables.GetPostTableId(tid);
                    DatabaseProvider.GetInstance().UpdatePostAttachment(pid, postTableId, 0);

                    if (Posts.appDBCache)
                    {
                        PostInfo postInfo = Posts.GetPostInfo(postTableId, pid);
                        postInfo.Attachment = 0;
                        Posts.IPostService.UpdatePost(postInfo, postTableId);
                    }
                }

                if (DatabaseProvider.GetInstance().GetAttachmentCountByTid(tid) <= 0)
                {
                    DatabaseProvider.GetInstance().UpdateTopicAttachment(tid, 0);

                    if (Topics.appDBCache)
                    {
                        TopicInfo topicInfo = Topics.GetTopicInfo(tid, 0, 0);
                        topicInfo.Attachment = 0;
                        Topics.ITopicService.UpdateTopic(topicInfo);
                    }
                }
            }
        }