Esempio n. 1
0
        public ActionResult Index(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                Preservation preservation = _preservationService.GetPreservation(id, false);
                if (preservation == null)
                {
                    _loggerService.Warn(string.Format("Nessuna conservazione trovata con id {0}", id));
                    return HttpNotFound();
                }

                IpdaIndexViewModel model = new IpdaIndexViewModel()
                {
                    Preservation = preservation
                };
                string preservationPath = preservation.Path;
                string closeFile = IpdaUtil.GetCloseFile(preservationPath);
                string ipdaXmlFile = IpdaUtil.GetIpdaXmlFile(preservationPath);
                string ipdaTsdFile = IpdaUtil.GetIpdaTsdFile(preservationPath);
                model.ToCreate = (!string.IsNullOrEmpty(closeFile) && string.IsNullOrEmpty(ipdaXmlFile) && string.IsNullOrEmpty(ipdaTsdFile));
                model.ToSign = !model.ToCreate && (!string.IsNullOrEmpty(ipdaXmlFile) && string.IsNullOrEmpty(ipdaTsdFile));
                model.ToClose = !model.ToCreate && !model.ToSign && (!string.IsNullOrEmpty(ipdaXmlFile) && !string.IsNullOrEmpty(ipdaTsdFile) && !preservation.CloseDate.HasValue);
                return View(model);
            }, _loggerService));
        }
Esempio n. 2
0
 public ActionResult DownloadXml(Guid id)
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         Preservation preservation = _preservationService.GetPreservation(id, false);
         string xmlFile = IpdaUtil.GetIpdaXmlFile(preservation.Path);
         return File(xmlFile, System.Net.Mime.MediaTypeNames.Application.Zip, string.Concat(id, "_", Path.GetFileName(xmlFile)));
     }, _loggerService));
 }
Esempio n. 3
0
        public ActionResult GridPreservations(Guid id, [DataSourceRequest] DataSourceRequest request)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                var result = new DataSourceResult();
                ICollection <Preservation> preservations = _preservationService.GetPreservations(id, request.PageSize, (request.Page - 1) * request.PageSize, true, false, out int counter);

                List <PreservationItem> gridItems = new List <PreservationItem>();
                foreach (var p in preservations)
                {
                    PreservationItem pi = new PreservationItem
                    {
                        IdPreservation = p.IdPreservation,
                        Label = p.Label,
                        StartDate = p.StartDate,
                        EndDate = p.EndDate,
                        CloseDate = p.CloseDate,
                        Username = p.User.Name,
                        DisplayCreate = "none",
                        DisplaySign = "none",
                        DisplayClose = "none",
                        DisplayPurge = "none"
                    };

                    if (IpdaUtil.GetCloseFile(p.Path) != "" && IpdaUtil.GetIpdaXmlFile(p.Path) == "" && IpdaUtil.GetIpdaTsdFile(p.Path) == "")
                    {
                        pi.DisplayCreate = "inline";
                    }

                    if (IpdaUtil.GetIpdaXmlFile(p.Path) != "" && IpdaUtil.GetIpdaTsdFile(p.Path) == "" && !p.CloseDate.HasValue)
                    {
                        pi.DisplaySign = "inline";
                    }

                    if (IpdaUtil.GetIpdaXmlFile(p.Path) != "" && IpdaUtil.GetIpdaTsdFile(p.Path) != "" && !p.CloseDate.HasValue)
                    {
                        pi.DisplayClose = "inline";
                    }

                    if (p.CloseDate.HasValue && _preservationService.CountPreservationDocumentsToPurge(p.IdPreservation) > 0)
                    {
                        pi.DisplayPurge = "inline";
                    }

                    gridItems.Add(pi);
                }

                result.Total = counter;
                result.Data = gridItems;
                return Json(result, JsonRequestBehavior.AllowGet);
            }, _loggerService));
        }
Esempio n. 4
0
        private string CreatePreservationZipToDownload(List <Preservation> preservations)
        {
            string destination = Path.Combine(ConfigurationHelper.GetAppDataPath(), string.Format("Preservation_{0:yyyyMMddHHmmss}.zip", DateTime.Now));

            using (IWritableArchive archive = ArchiveFactory.Create(ArchiveType.Zip))
            {
                foreach (Preservation preservation in preservations)
                {
                    string file = IpdaUtil.GetIpdaXmlFile(preservation.Path);
                    archive.AddEntry(string.Concat(preservation.IdPreservation, "_", Path.GetFileName(file)), file);
                }
                archive.SaveTo(destination, CompressionType.Deflate);
            }
            return(destination);
        }