示例#1
0
 private FileResult createBackupFromModel(ExportModel exportModel)
 {
     string HomeDirectory = ((BaseCatalogDir)System.Web.Configuration.WebConfigurationManager.GetSection("katalogBazowyDanych")).BaseDir;
     Backup backup = new Backup(HomeDirectory);
     string fileName = prepareAttachmentName(exportModel);
     return File(backup.ZipFilesInRange(exportModel), "application/force-download", fileName);
 }
示例#2
0
        public Stream ZipFilesInRange(ExportModel movie)
        {
            Stream zipStream = new MemoryStream();

            using (ZipFile zip = new ZipFile())
            {
                List<DirectoryElementList> directoryList = GetDirectoryElementList(movie.FromDate, movie.ToDate);
                foreach (DirectoryElementList element in directoryList)
                {
                    zip.AddDirectory(element.Directory, element.DirectoryInArchive);
                }
                zip.Save(zipStream);
                zipStream.Position = 0;
            }
            return zipStream;
        }
示例#3
0
 private static string prepareAttachmentName(ExportModel exportModel)
 {
     return exportModel.FromDate.ToString("yyyy-MM-dd") + "_" + exportModel.ToDate.ToString("yyyy-MM-dd") + ".zip";
 }
示例#4
0
 public FileResult CreateLastDays(int days)
 {
     ExportModel exportModel = new ExportModel();
     exportModel.FromDate = exportModel.ToDate.AddDays(-1d*days);
     return createBackupFromModel(exportModel);
 }
示例#5
0
 public FileResult Create(ExportModel exportModel)
 {
     return createBackupFromModel(exportModel);
 }