Example #1
0
        public Guid?UploadFile(string name, DateTimeOffset?createDate, byte[] data)
        {
            int maxUploadFileSize = Convert.ToInt32(WebConfigurationManager.AppSettings.Get("MaxUploadFileSize"));

            if (data.Length <= maxUploadFileSize)
            {
                using (var db = new FileCollectorEntities())
                {
                    return(db.spFileInsert(name, createDate, data).FirstOrDefault());
                }
            }
            else
            {
                throw new FaultException("Размер загружаемого файла превышает указанный в конфигурационном файле лимит");
            }
        }
Example #2
0
 public List <FileStorage> DownloadFile(Guid Id)
 {
     using (var db = new FileCollectorEntities())
     {
         var result = db.spFileDownload(Id).Select(r => new FileStorage()
         {
             Id         = r.Id,
             Name       = r.Name,
             Path       = r.Path,
             Type       = r.Type,
             Size       = r.Size,
             CreateDate = r.CreateDate,
             LoadDate   = r.LoadDate,
             Data       = r.Data
         }).ToList();
         return(result);
     }
 }
Example #3
0
 public List <FileStorage> GetFiles()
 {
     using (var db = new FileCollectorEntities())
     {
         var result = db.spFileSelect(null, null).Select(r => new FileStorage()
         {
             Id         = r.Id,
             Name       = r.Name,
             Path       = r.Path,
             Type       = r.Type,
             Size       = r.Size,
             CreateDate = r.CreateDate,
             LoadDate   = r.LoadDate,
             Data       = null
         }).ToList();
         return(result);
     }
 }