Example #1
0
        //--------------------------------------------------------------------------------------------------------------


        public virtual Result CreateTemp(ContentAttachmentTemp a, User user, IMember owner)
        {
            a.OwnerId    = owner.Id;
            a.OwnerType  = owner.GetType().FullName;
            a.OwnerUrl   = owner.Url;
            a.Creator    = user;
            a.CreatorUrl = user.Url;

            a.Guid = Guid.NewGuid().ToString();

            return(db.insert(a));
        }
        //--------------------------------------------------------------------------------------------------------------


        public virtual Result CreateTemp( ContentAttachmentTemp a, User user, IMember owner ) {

            a.OwnerId = owner.Id;
            a.OwnerType = owner.GetType().FullName;
            a.OwnerUrl = owner.Url;
            a.Creator = user;
            a.CreatorUrl = user.Url;

            a.Guid = Guid.NewGuid().ToString();

            return db.insert( a );
        }
Example #3
0
        public virtual void DeleteTempAttachment(long id)
        {
            ContentAttachmentTemp at = ContentAttachmentTemp.findById(id);

            if (at == null)
            {
                return;
            }

            at.delete();

            Img.DeleteImgAndThumb(at.FileUrl);
        }
Example #4
0
        public virtual void CreateByTemp(String ids, ContentPost post)
        {
            int[] arrIds = cvt.ToIntArray(ids);
            if (arrIds.Length == 0)
            {
                return;
            }

            int attachmentCount = 0;

            foreach (int id in arrIds)
            {
                ContentAttachmentTemp at = ContentAttachmentTemp.findById(id);
                if (at == null)
                {
                    continue;
                }

                ContentAttachment a = new ContentAttachment();

                a.AppId = at.AppId;
                a.Guid  = at.Guid;

                a.FileSize    = at.FileSize;
                a.Type        = at.Type;
                a.Name        = at.Name;
                a.Description = at.Description;
                a.PostId      = post.Id;

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

                a.insert();

                at.delete();

                attachmentCount++;
            }

            post.Attachments = attachmentCount;
            post.update("Attachments");
        }