Example #1
0
        public void UploadFile(User user, DAL.Models.File file, byte[] data)
        {
            var directory = _fileContainer.GetDirectoryReference(user.Folder.Name);
            var blob      = directory.GetBlockBlobReference(file.Hash);

            blob.UploadFromByteArray(data, 0, data.Length);
        }
Example #2
0
        public void UploadFile(User user, DAL.Models.File file, Stream data)
        {
            var directory = _fileContainer.GetDirectoryReference(user.Folder.Name);
            var blob      = directory.GetBlockBlobReference(file.Hash);

            blob.UploadFromStream(data);
        }
Example #3
0
        public void DeleteFile(User user, DAL.Models.File file)
        {
            var directory = _fileContainer.GetDirectoryReference(user.Folder.Name);
            var blob      = directory.GetBlockBlobReference(file.Hash);

            blob.DeleteIfExists();
        }
Example #4
0
        public ActionResult Execute(UI.Action action)
        {
            if (!action.Props.ContainsKey("FileId"))
            {
                throw new CustomValidationException("There is not Prop FileId");
            }

            int fileId = Convert.ToInt32(action.Props["FileId"]);

            DAL.Services.DbFileService fileService = new DAL.Services.DbFileService();

            DAL.Models.File file = fileService.GetFile(fileId);

            file.Deleted    = true;
            file.DeleteDate = DateTime.Now;
            file.DeletedBy  = CurrentUser.Login;

            fileService.UpdateFile(file);

            return(new ActionResult()
            {
                Success = true,
                ActionType = action.ActionType
            });
        }
Example #5
0
        public byte[] DownloadFile(User user, DAL.Models.File file)
        {
            var directory = _fileContainer.GetDirectoryReference(user.Folder.Name);
            var blob      = directory.GetBlockBlobReference(file.Hash); blob.FetchAttributes();
            var len       = blob.Properties.Length;

            byte[] output = new byte[len];
            blob.DownloadToByteArray(output, 0);
            return(output);
        }
Example #6
0
        public byte[] DownloadFile(User user, DAL.Models.File file)
        {
            string infile = Path.Combine(_root, user.Folder.Name, file.Hash);

            if (!System.IO.File.Exists(infile))
            {
                throw new FileNotFoundException();
            }
            return(System.IO.File.ReadAllBytes(infile));
        }
Example #7
0
        public void Insert(File file)
        {
            var token = from i in ApplicationContext.Files
                        where i.RequestFormToken == file.RequestFormToken
                        select i;

            if (token.Count() > 5)
            {
                return;
            }
            ApplicationContext.Files.Add(file);
            ApplicationContext.SaveChanges();
        }
Example #8
0
        public List <int> AddFile(Incoming.FileInput fileInput)
        {
            DbFileService fileService = new DbFileService();

            DAL.Models.File file = new DAL.Models.File()
            {
                Name        = fileInput.Name,
                ContentType = fileInput.ContentType,
                CreateDate  = DateTime.Now,
                ContentData = fileInput.ContentData
            };
            return(fileService.AddFiles(fileInput.FieldId, fileInput.DocId, new[] { file }).Select(f => f.Id).ToList());
        }
Example #9
0
        public void UploadFile(User user, DAL.Models.File file, byte[] data)
        {
            string outfile = Path.Combine(_root, user.Folder.Name, file.Hash);

#if !DEBUG
            if (System.IO.File.Exists(outfile))
            {
                throw new IOException();
            }
#endif

            System.IO.File.WriteAllBytes(outfile, data);
            //using (StreamWriter s = new StreamWriter(Path.Combine(_root, user.Folder.Name)))
            //using (BinaryWriter bw = new BinaryWriter(s.BaseStream))
            //{
            //    //bw.Write()
            //}
        }
Example #10
0
 public void DeleteFile(User user, DAL.Models.File file)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public Stream DownloadFileAsStream(User user, DAL.Models.File file)
 {
     throw new NotImplementedException();
 }
Example #12
0
 public void UploadFile(User user, DAL.Models.File file, Stream data)
 {
     throw new NotImplementedException();
 }