Exemple #1
0
        public virtual void UpdateAtachments(long[] arrAttachmentIds, ContentPost post)
        {
            if (post == null || arrAttachmentIds.Length == 0)
            {
                return;
            }

            foreach (int id in arrAttachmentIds)
            {
                ContentAttachment a = ContentAttachment.findById(id);
                if (a == null)
                {
                    continue;
                }

                a.OwnerId    = post.OwnerId;
                a.OwnerType  = post.OwnerType;
                a.OwnerUrl   = post.OwnerUrl;
                a.Creator    = post.Creator;
                a.CreatorUrl = post.CreatorUrl;

                a.PostId = post.Id;
                a.AppId  = post.AppId;

                a.update();
            }

            int count = ContentAttachment.count("PostId=" + post.Id);

            post.Attachments = count;
            post.update();
        }
Exemple #2
0
        //--------------------------------------------------------------------------------------------------------------

        public virtual void Delete(long id)
        {
            ContentAttachment at = ContentAttachment.findById(id);

            if (at == null)
            {
                return;
            }

            at.delete();
            Img.DeleteImgAndThumb(strUtil.Join(sys.Path.DiskPhoto, at.Name));

            // 重新统计所属主题的附件数
            refreshAttachmentCount(at);
        }
Exemple #3
0
 public virtual ContentAttachment GetById(long id)
 {
     return(ContentAttachment.findById(id));
 }