Пример #1
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;
        }
Пример #2
0
        public Result SaveFile( HttpFile postedFile )
        {
            Dictionary<String, String> dic = new Dictionary<String, String>();

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

            MessageAttachment att = new MessageAttachment();
            att.Name = System.IO.Path.GetFileName( postedFile.FileName );
            att.Url = result.Info.ToString();
            att.Type = System.IO.Path.GetExtension( postedFile.FileName );
            att.FileSize = postedFile.ContentLength;

            this.Insert( att );

            result.Info = att;

            return result;
        }
        public virtual Result Upload( HttpFile postedFile, IMember user, IMember owner )
        {
            Result result = Uploader.SaveImg( postedFile );

            if (result.HasErrors) {
                return result;
            }

            String picUrl = strUtil.Join( sys.Path.Photo, result.Info.ToString() );
            String picThumbUrl = Img.GetThumbPath( picUrl );

            String filePath = result.Info.ToString();

            TempUploadFile uploadFile = new TempUploadFile();
            uploadFile.FileSize = postedFile.ContentLength;
            uploadFile.Type = postedFile.ContentType;
            uploadFile.Name = filePath;

            return Upload( uploadFile, (User)user, owner );
        }
Пример #4
0
 public Result SaveLogo( HttpFile afile, String url )
 {
     return Uploader.SaveImg( this.LogoDiskPath, afile, url, this.LogoWidth, this.LogoHeight, SaveThumbnailMode.Cut );
 }
Пример #5
0
 /// <summary>
 /// 保存群组 logo
 /// </summary>
 /// <param name="postedFile"></param>
 /// <param name="groupUrlName"></param>
 /// <returns></returns>
 public static Result SaveGroupLogo( HttpFile postedFile, String groupUrlName )
 {
     return Uploader.SaveImg( sys.Path.DiskGroupLogo, postedFile, groupUrlName, GroupSetting.Instance.LogoWidth, GroupSetting.Instance.LogoHeight );
 }
 public virtual Result Upload( HttpFile postedFile )
 {
     return Upload( postedFile, null, null );
 }
Пример #7
0
        public virtual Result SaveFile( HttpFile postedFile, String ip, User creator, IMember owner )
        {
            Result result = Uploader.SaveFileOrImage( postedFile );
            if (result.HasErrors) return result;

            UserFile att = new UserFile();
            att.Name = System.IO.Path.GetFileName( postedFile.FileName );
            att.PathRelative = result.Info.ToString();
            att.ContentType = postedFile.ContentType;
            att.Ext = System.IO.Path.GetExtension( att.Name );
            att.FileSize = postedFile.ContentLength;
            att.IsPic = Uploader.IsImage( postedFile ) ? 1 : 0;

            att.Ip = ip;

            if (creator != null) {
                att.Creator = creator;
                att.CreatorUrl = creator.Url;
            }

            if (owner != null) {
                att.OwnerId = owner.Id;
                att.OwnerType = owner.GetType().FullName;
                att.OwnerUrl = owner.Url;
            }

            try {
                this.Insert( att );
            }
            catch (Exception ex) {
                result.Add( ex.Message );
                return result;
            }

            result.Info = att;

            return result;
        }