Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
0
        public virtual Result SaveFile( HttpFile postedFile ) {

            Result result = Uploader.SaveFileOrImage( postedFile );
            if (result.HasErrors)return result;

            ContentAttachment uploadFile = new ContentAttachment();
            uploadFile.FileSize = postedFile.ContentLength;
            uploadFile.Type = postedFile.ContentType;
            uploadFile.Name = result.Info.ToString();
            uploadFile.Description = System.IO.Path.GetFileName( postedFile.FileName );
            uploadFile.Guid = Guid.NewGuid().ToString();

            uploadFile.insert();

            result.Info = uploadFile;

            return result;
        }
Ejemplo n.º 3
0
        public 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" );
        }
Ejemplo n.º 4
0
        public virtual Result SaveFile(HttpFile postedFile)
        {
            Result result = Uploader.SaveFileOrImage(postedFile);

            if (result.HasErrors)
            {
                return(result);
            }

            ContentAttachment uploadFile = new ContentAttachment();

            uploadFile.FileSize    = postedFile.ContentLength;
            uploadFile.Type        = postedFile.ContentType;
            uploadFile.Name        = result.Info.ToString();
            uploadFile.Description = System.IO.Path.GetFileName(postedFile.FileName);
            uploadFile.Guid        = Guid.NewGuid().ToString();

            uploadFile.insert();

            result.Info = uploadFile;

            return(result);
        }