public ActionResult CheckArchivePreservationConfiguration(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { CheckPreservationArchiveConfigurationViewModel model = new CheckPreservationArchiveConfigurationViewModel() { IdArchive = id }; DocumentArchive archive = ArchiveService.GetArchive(id); ICollection <DocumentAttribute> archiveAttributes = AttributeService.GetAttributesFromArchive(id); model.ArchiveName = archive.Name; model.ArchiveAttributes = archiveAttributes.Where(x => !x.KeyOrder.HasValue || x.KeyOrder == 0) .OrderBy(o => o.DisplayName) .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName); //model.DateAttributes.Add(Guid.Empty.ToString(), "--Crea attributo (Date)"); archiveAttributes.Where(x => x.AttributeType.Equals("System.DateTime", StringComparison.InvariantCultureIgnoreCase)) .OrderBy(o => o.DisplayName).ToList().ForEach(f => model.DateAttributes.Add(f.IdAttribute.ToString(), f.DisplayName)); model.PathPreservation = archive.PathPreservation; model.MainDateAttribute = archiveAttributes.Where(x => x.IsMainDate == true).Select(s => s.IdAttribute.ToString()).SingleOrDefault(); model.PrimaryKeyAttributes = archiveAttributes.Where(x => x.KeyOrder > 0).OrderBy(o => o.KeyOrder) .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName); ValidateArchiveForPreservationInteractor interactor = new ValidateArchiveForPreservationInteractor(_loggerService); ValidateArchiveForPreservationResponseModel response = interactor.Process(new ValidateArchiveForPreservationRequestModel() { IdArchive = id }); model.HasPreservations = response.HasPreservations; model.ValidationErrors = response.ValidationErrors; model.IsValidated = response.IsValidated; return PartialView("_CheckArchivePreservationConfiguration", model); }, _loggerService)); }
public ActionResult ViewAwardRDV(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { AwardBatch awardBatch = _preservationService.GetAwardBatch(id); if (awardBatch.IdRDVDocument.HasValue) { using (DocumentsClient client = new DocumentsClient()) { DocumentContent content = client.GetDocumentContentById(awardBatch.IdRDVDocument.Value); if (content != null) { return View(new WindowFileContentViewModel() { Content = System.Text.Encoding.UTF8.GetString(content.Blob) }); } } _loggerService.Warn(string.Format("ViewAwardRDV -> nessun documento trovato con Id {0}.", awardBatch.IdRDVDocument)); } WindowFileContentViewModel model = new WindowFileContentViewModel() { Content = string.Empty }; return View(model); }, _loggerService)); }
public ActionResult ChangePassword(ChangePasswordModel model) { return(ActionResultHelper.TryCatchWithLogger(() => { if (!ModelState.IsValid) { return View(model); } bool changePasswordSucceeded; try { CustomerService.ChangeCustomerPassword(User.Identity.Name, model.OldPassword, model.NewPassword); changePasswordSucceeded = true; } catch (Exception ex) { _loggerService.Error(ex.Message, ex); changePasswordSucceeded = false; } if (changePasswordSucceeded) { return RedirectToAction("ChangePasswordSuccess"); } else { ModelState.AddModelError("", "Errore nella procedura di cambio password."); } return View(model); }, _loggerService)); }
public ActionResult SignPreservationFilesToClose() { return(ActionResultHelper.TryCatchWithLogger(() => { try { CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; List <Preservation> preservations = PreservationService.PreservationToClose(customerCompany.CompanyId); Models.ArubaSignModel arubaSignModel = ArubaSignConfigurationHelper.GetArubaSignConfiguration(customerCompany.CompanyId, User.Identity.Name); _logger.InfoFormat("Initializing signing with Aruba Automatic"); ISignService _signService = new SignService((info) => _logger.Info(info), (err) => _logger.Error(err)); if (arubaSignModel == null) { return Json(ArubaSignConfigurationHelper.NO_CREDENTIALS, JsonRequestBehavior.AllowGet); } foreach (Preservation preservation in preservations) { SignDocuments(preservation, _signService, arubaSignModel); } return Json(ArubaSignConfigurationHelper.SIGN_COMPLETE, JsonRequestBehavior.AllowGet); } catch (Exception ex) { _loggerService.Error($"Exception caught in process of signing: { ex.Message}", ex); return Json(ArubaSignConfigurationHelper.SIGN_ERROR, JsonRequestBehavior.AllowGet); } }, _loggerService)); }
public ActionResult PreservationArchivesConfigurable() { return(ActionResultHelper.TryCatchWithLogger(() => { return View(); }, _loggerService)); }
public ActionResult ViewAwardPDV(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { AwardBatch awardBatch = _preservationService.GetAwardBatch(id); if (awardBatch.IdPDVDocument.HasValue) { using (DocumentsClient client = new DocumentsClient()) { DocumentContent content = client.GetDocumentContentById(awardBatch.IdPDVDocument.Value); if (content != null) { return View(new WindowFileContentViewModel() { Content = System.Text.Encoding.UTF8.GetString(content.Blob) }); } _loggerService.Warn(string.Format("ViewAwardPDV -> nessun documento trovato con Id {0}. Si procede con una nuova generazione del pacchetto di versamento.", awardBatch.IdPDVDocument)); } } string pdv = _preservationService.CreateAwardBatchPDVXml(awardBatch); SavePDVXml(pdv, awardBatch); WindowFileContentViewModel model = new WindowFileContentViewModel() { Content = pdv }; return View(model); }, _loggerService)); }
public ActionResult PreservationToClose() { return(ActionResultHelper.TryCatchWithLogger(() => { IpdaPreservationToCloseViewModel model = new IpdaPreservationToCloseViewModel(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; IList <Preservation> preservationsToClose = PreservationService.PreservationToClose(customerCompany.CompanyId); model.PreservationsCount = preservationsToClose.Count; IList <string> files = new List <string>(); foreach (Preservation preservation in preservationsToClose) { if (Directory.GetFiles(preservation.Path, "IPDA*.tsd").Any()) { continue; } string fileName = Directory.GetFiles(preservation.Path, "IPDA*.xml").FirstOrDefault(); if (!String.IsNullOrEmpty(fileName)) { files.Add(fileName); } } model.CloseFiles = files.ToArray(); ViewBag.messageId = Guid.NewGuid().ToString(); return View(model); }, _loggerService)); }
public ActionResult ExportFullPDD(Guid?idArchive, DateTime?fromDate, DateTime?toDate, string dynamicFilters) { return(ActionResultHelper.TryCatchWithLogger(() => { if (!idArchive.HasValue) { _logger.InfoFormat("ExportFullPDD -> nessun id archivio passato per la ricerca"); return Content(string.Empty); } IDictionary <string, string> filters = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(dynamicFilters)) { filters = JsonConvert.DeserializeObject <IDictionary <string, string> >(dynamicFilters); } SearchDocumentsRequestModel requestModel = new SearchDocumentsRequestModel() { IdArchive = idArchive.Value, FromDate = fromDate, ToDate = toDate, DynamicFilters = filters }; SearchDocumentsResponseModel responseModel = _searchDocumentsInteractor.Process(requestModel); return ExportPDD(JsonConvert.SerializeObject(responseModel.Documents.Select(s => s.IdDocument))); }, _loggerService)); }
public ActionResult CreateIpda(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { try { Preservation preservation = _preservationService.GetPreservation(id, false); if (preservation == null) { _loggerService.Error(string.Format("Nessuna conservazione trovata con id {0}", id)); return Content("Errore: Conservazione non valida"); } string closeFile = IpdaUtil.GetCloseFile(preservation.Path); if (string.IsNullOrEmpty(closeFile)) { return Content("Errore: Conservazione non valida"); } IpdaConverter converter = new IpdaConverter(); Ipda ipda = converter.ConvertCloseFile(closeFile, "NomeFileInArchivio"); ipda.SaveAs(IpdaUtil.Close2IpdaFilename(closeFile)); return Content("Il file IPDA è stato generato con successo"); } catch (Exception ex) { _loggerService.Error(ex.Message, ex); return Content(string.Concat("Errore durante la conversione del file di chiusura.<br/>", ex.Message)); } }, _loggerService)); }
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)); }
public ActionResult Login(LoginModel model, string returnUrl) { return(ActionResultHelper.TryCatchWithLogger(() => { if (!ModelState.IsValid) { return View(model); } if (CustomerService.CustomerLoginExists(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "Lo username o la password forniti non sono corretti."); } return View(model); }, _loggerService)); }
public ActionResult Index(Guid id, Guid?idPreservation) { return(ActionResultHelper.TryCatchWithLogger(() => { DocumentArchive archive = ArchiveService.GetArchive(id); if (archive == null) { throw new Exception(string.Format("Nessun archivio trovato con id {0}", id)); } AwardBatchViewModel model = new AwardBatchViewModel() { ArchiveName = archive.Name, IdArchive = archive.IdArchive, IdPreservation = idPreservation }; if (idPreservation.HasValue && idPreservation.Value != Guid.Empty) { model.FromDate = null; model.ToDate = null; } return View(model); }, _loggerService)); }
public ActionResult GetPreservationAuditType() { return(ActionResultHelper.TryCatchWithLogger(() => { ICollection <PreservationJournalingActivity> preservationJournalingActivities = _preservationService.GetPreservationJournalingActivities(null, false); return Json(preservationJournalingActivities, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult PreservationAudit() { return(ActionResultHelper.TryCatchWithLogger(() => { PreservationAuditViewModel viewModel = new PreservationAuditViewModel(); return View(viewModel); }, _loggerService)); }
public ActionResult Login(string returnUrl) { return(ActionResultHelper.TryCatchWithLogger(() => { ViewBag.ReturnUrl = returnUrl; return View(); }, _loggerService)); }
public ActionResult DownloadJsonTempFile(string referenceKey) { return(ActionResultHelper.TryCatchWithLogger(() => { string tmpFileName = Path.Combine(ConfigurationHelper.GetAppDataPath(), $"{referenceKey}.json"); return File(System.IO.File.ReadAllBytes(tmpFileName), System.Net.Mime.MediaTypeNames.Application.Octet, $"{referenceKey}.json"); }, _loggerService)); }
public ActionResult Check(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { Preservation preservation = _preservationService.GetPreservation(id, false); _preservationService.VerifyExistingPreservation(id); return RedirectToAction("PreservationCheck", "Preservation", new { id }); }, _loggerService)); }
public ActionResult LogOff() { return(ActionResultHelper.TryCatchWithLogger(() => { FormsAuthentication.SignOut(); Session["idCompany"] = null; return RedirectToAction("Index", "Home"); }, _loggerService)); }
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)); }
public ActionResult ArchiveConfigurationWizard(ArchiveWizardStepBaseViewModel model) { return(ActionResultHelper.TryCatchWithLogger(() => { Func <ArchiveWizardStepBaseViewModel, ActionResult> func = null; switch (model.ActiveStep) { case 1: { ModelState.Remove(nameof(ArchiveWizardStepBaseViewModel.SelectedPreservationAttributes)); func = (m) => ConfirmAndNextArchivePreservationConfiguration(m); } break; case 2: { ModelState.Remove(nameof(ArchiveWizardStepBaseViewModel.MainDateAttribute)); ModelState.Remove(nameof(ArchiveWizardStepBaseViewModel.PathPreservation)); ModelState.Remove(nameof(ArchiveWizardStepBaseViewModel.SelectedPrimaryKeyAttributes)); func = (m) => ConfirmAndNextArchivePreservationAttributesConfiguration(m); } break; case 3: { ModelState.Clear(); ArchiveConfigurationWizardViewModel returnModel = new ArchiveConfigurationWizardViewModel() { IdArchive = model.IdArchive, FlowActiveIndex = 4, IsCompleteWithErrors = model.IsCompleteWithErrors.Value }; return View(returnModel); } case 4: { return RedirectToAction("PreservationArchivesConfigurable", "Archive"); } default: throw new Exception($"Step {model.ActiveStep} not valid"); } if (!ModelState.IsValid) { ArchiveConfigurationWizardViewModel resultModel = new ArchiveConfigurationWizardViewModel() { IdArchive = model.IdArchive, FlowActiveIndex = model.ActiveStep }; return View(resultModel); } return func(model); }, _loggerService)); }
public ActionResult ClosePreviousArchiveTasks(Guid idPreservationTask, int selectedTaskYear) { return(ActionResultHelper.TryCatchWithLogger(() => { PreservationService service = new PreservationService(); PreservationTask preservationTask = service.GetPreservationTask(idPreservationTask); service.CreateClosePreviousPreservationTask(preservationTask, selectedTaskYear); return RedirectToAction("ArchivePreservationTask", new { id = preservationTask.Archive.IdArchive }); }, _loggerService)); }
public ActionResult GetUserCompanies() { return(ActionResultHelper.TryCatchWithLogger(() => { if (Session["idCompany"] != null) { return Json(UserCompaniesConfiguration.GetCachedAvailableCompanies(), JsonRequestBehavior.AllowGet); } return Json(null, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult GetRDVToSign([DataSourceRequest] DataSourceRequest request, Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { DataSourceResult result = new DataSourceResult(); ICollection <AwardBatch> toSignBatches = _preservationService.GetToSignAwardBatchRDV(id); result.Total = toSignBatches.Count; result.Data = toSignBatches; return Json(result, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult GetPreservationsToClose([DataSourceRequest] DataSourceRequest request) { return(ActionResultHelper.TryCatchWithLogger(() => { DataSourceResult result = new DataSourceResult(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; IList <Preservation> preservations = PreservationService.PreservationToClose(customerCompany.CompanyId); result.Total = preservations.Count; result.Data = preservations; return Json(result, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult CacheCompanyId(CustomerCompanyViewModel customerCompany) { return(ActionResultHelper.TryCatchWithLogger(() => { CustomerCompanyViewModel customerCompanyViewModel = new CustomerCompanyViewModel { SelectedIndex = customerCompany.SelectedIndex, CompanyId = customerCompany.CompanyId }; Session["idCompany"] = customerCompanyViewModel; return Json(customerCompanyViewModel, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult AwardBatchRDVSign(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { DocumentArchive archive = ArchiveService.GetArchive(id); ViewBag.messageId = Guid.NewGuid().ToString(); AwardBatchRDVSignViewModel viewModel = new AwardBatchRDVSignViewModel() { ArchiveName = archive.Name, IdArchive = archive.IdArchive }; return View(viewModel); }, _loggerService)); }
public ActionResult GetArchives(string text) { return(ActionResultHelper.TryCatchWithLogger(() => { CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; ICollection <PreservationArchiveInfoResponse> archives = ArchiveService.GetLegalArchives(string.Empty, customerCompany.CompanyId); if (!string.IsNullOrEmpty(text)) { archives = archives.Where(x => x.Archive.Name.ToLower().Contains(text.ToLower())).ToList(); } return Json(archives.Select(s => s.Archive), JsonRequestBehavior.AllowGet); }, _loggerService)); }
public ActionResult ExecuteArchivePreservationMigrator(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { DocumentArchive archive = ArchiveService.GetArchive(id); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; ExecuteArchivePreservationMigratorViewModel model = new ExecuteArchivePreservationMigratorViewModel() { IdArchive = id, ArchiveName = archive.Name, IdCompany = customerCompany.CompanyId }; return PartialView("_ExecuteArchivePreservationMigrator", model); }, _loggerService)); }
public ActionResult PreservationRemoveCloseFiles(string[] fileNames, string messageId) { return(ActionResultHelper.TryCatchWithLogger(() => { if (fileNames != null) { foreach (string file in fileNames) { string fileName = Path.GetFileName(file); _uploadHelper.RemoveUploadedFile(fileName, messageId); } } return Content(string.Empty); }, _loggerService)); }
public ActionResult DownloadPreservationPDA(Guid id, bool includeDocuments) { return(ActionResultHelper.TryCatchWithLogger(() => { var t = includeDocuments; Preservation preservation = _preservationService.GetPreservation(id, false); if (!Directory.Exists(preservation.Path)) { throw new DirectoryNotFoundException(string.Concat("DownloadPreservationPDA -> directory ", preservation.Path, " non trovata")); } string zipToDownload = _preservationService.GetZipPreservationPDA(preservation, includeDocuments); byte[] zipContent = System.IO.File.ReadAllBytes(zipToDownload); return File(zipContent, System.Net.Mime.MediaTypeNames.Application.Zip, Path.GetFileName(zipToDownload)); }, _loggerService)); }