コード例 #1
0
ファイル: AttachmentService.cs プロジェクト: zuhuizou/wojilu
        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");
        }
コード例 #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;
        }
コード例 #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" );
        }
コード例 #4
0
ファイル: AttachmentService.cs プロジェクト: zuhuizou/wojilu
        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);
        }