Esempio n. 1
0
        public ActionResult ArchiveConfigurationWizard(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                DocumentArchive archive = ArchiveService.GetArchive(id);
                if (archive == null)
                {
                    throw new Exception(string.Format("Nessun archivio trovato con id {0}", id));
                }

                ArchiveConfigurationWizardViewModel model = new ArchiveConfigurationWizardViewModel()
                {
                    IdArchive = id
                };
                return View(model);
            }, _loggerService));
        }
Esempio n. 2
0
        public ActionResult DistributionPackagesGrid(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                DistributionPackagesSearchGridViewModel viewModel = new DistributionPackagesSearchGridViewModel()
                {
                    IdArchive = id,
                    ArchiveAttributes = AttributeService.GetAttributesFromArchive(id).OrderBy(x => x.Name).Select(s => new AttributeModel()
                    {
                        Name = s.Name,
                        Description = string.IsNullOrEmpty(s.Description) ? s.Name : s.Description
                    }).ToList()
                };

                return PartialView("_DistributionPackagesGrid", viewModel);
            }, _loggerService));
        }
Esempio n. 3
0
 public ActionResult DynamicFormFields(Guid id)
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         ICollection <DocumentAttribute> archiveAttributes = AttributeService.GetAttributesFromArchive(id);
         DynamicFormFieldsViewModel viewModel = new DynamicFormFieldsViewModel()
         {
             DynamicControlViewModels = archiveAttributes.OrderBy(x => x.Name).Select(s => new DynamicControlViewModel()
             {
                 Caption = string.IsNullOrEmpty(s.Description) ? s.Name : s.Description,
                 ControlName = s.Name,
                 ControlType = s.AttributeType
             }).ToList()
         };
         return PartialView("_DynamicFormFields", viewModel);
     }, _loggerService));
 }
Esempio n. 4
0
        private void ChimaHandleAndWrapException(ExceptionContext context)
        {
            if (!ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType))
            {
                return;
            }

            context.HttpContext.Response.StatusCode = GetStatusCode(context);

            context.Result = new ObjectResult(
                _errorInfoBuilder.BuildForException(context.Exception)
                );

            EventBus.Trigger(this, new AbpHandledExceptionData(context.Exception));

            context.Exception = null; //Handled!
        }
Esempio n. 5
0
        public ActionResult ExportPDD(string data)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                ICollection <Guid> ids = JsonConvert.DeserializeObject <ICollection <Guid> >(HttpUtility.UrlDecode(data));
                Guid processId = Guid.NewGuid();
                string path = Path.Combine(ConfigurationHelper.GetAppDataPath(), processId.ToString());
                Directory.CreateDirectory(path);
                try
                {
                    foreach (Guid id in ids)
                    {
                        Document document = DocumentService.GetDocument(id);
                        using (DocumentsClient client = new DocumentsClient())
                        {
                            document.Content = client.GetDocumentContentById(id);
                        }

                        //Copied from preservation logic
                        document.AttributeValues = AttributeService.GetAttributeValues(document.IdDocument);
                        var fileName = string.Concat(_preservationService.PreservationDocumentFileName(document), (Path.GetExtension(document.Name)));
                        System.IO.File.WriteAllBytes(Path.Combine(path, fileName), document.Content.Blob);

                        if (document.IdPreservation.HasValue)
                        {
                            Preservation preservation = _preservationService.GetPreservation(document.IdPreservation.Value, false);
                            string[] files = Directory.GetFiles(preservation.Path).Where(x => x.Contains("INDICE_") || x.Contains("CHIUSURA_") || x.Contains("IPDA_") || x.Contains("LOTTI_")).ToArray();
                            foreach (string file in files.Where(f => !System.IO.File.Exists(Path.Combine(path, Path.GetFileName(f)))))
                            {
                                System.IO.File.Copy(file, Path.Combine(path, Path.GetFileName(file)), true);
                            }
                        }
                    }
                    string zipPath = CreatePDDZip(path);
                    return File(System.IO.File.ReadAllBytes(zipPath), System.Net.Mime.MediaTypeNames.Application.Zip);
                }
                finally
                {
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true);
                    }
                }
            }, _loggerService));
        }
Esempio n. 6
0
        private void HandleAndWrapException(ExceptionContext context)
        {
            if (!ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType))
            {
                return;
            }

            context.HttpContext.Response.StatusCode = GetStatusCode(context);

            context.Result = new ObjectResult(
                new AjaxResponse(
                    _errorInfoBuilder.BuildForException(context.Exception),
                    context.Exception is SecurityException
                    )
                );

            context.Exception = null; // Handled!
        }
        public async Task GetExistingDrinkFromShoppingListReturnsOk()
        {
            var drink = new Drink {
                Name = "drink", Quantity = 1
            };

            this.repository.Setup(r => r.GetByName(drink.Name)).ReturnsAsync(() => drink);

            var subject = this.CreateSubject();

            var result = await subject.Get(drink.Name);

            result.ShouldBeOfType <OkObjectResult>();
            var value = ActionResultHelper.GetOkObject <Drink>(result);

            value.Name.ShouldBe(drink.Name);
            value.Quantity.ShouldBe(drink.Quantity);
        }
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            //TODO: Configuration to disable validation for controllers..?

            if (!context.ActionDescriptor.IsControllerAction() ||
                !ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType))
            {
                await next();

                return;
            }

            using (AbpCrossCuttingConcerns.Applying(context.Controller, AbpCrossCuttingConcerns.Validation))
            {
                _validator.Validate(context.ModelState);
                await next();
            }
        }
        public async Task DeleteExistingDrinkToShoppingListReturnsOk()
        {
            var drink = new Drink {
                Name = "drink", Quantity = 1
            };

            this.repository.Setup(r => r.GetByName(drink.Name)).ReturnsAsync(() => drink);
            this.repository.Setup(r => r.Delete(drink.Name)).Returns(() => Task.CompletedTask);

            var subject = this.CreateSubject();

            var result = await subject.Delete(drink.Name);

            result.ShouldBeOfType <OkObjectResult>();
            var value = ActionResultHelper.GetOkObject <OkResponse>(result);

            value.Message.ShouldBe("Ok");
        }
Esempio n. 10
0
        public async Task <IActionResult> VersionsPutAsync(
            [HttpTrigger(AuthorizationLevel.Function, FunctionConstants.FunctionPut, Route = "packages/{packageIdentifier}/versions/{packageVersion}")]
            HttpRequest req,
            string packageIdentifier,
            string packageVersion,
            ILogger log)
        {
            Dictionary <string, string> headers = null;
            Version version = null;

            try
            {
                // Parse Headers
                headers = HeaderProcessor.ToDictionary(req.Headers);

                // Parse body as Version
                version = await Parser.StreamParser <Version>(req.Body, log);

                ApiDataValidator.Validate(version);

                // Validate Versions Match
                if (version.PackageVersion != packageVersion)
                {
                    throw new InvalidArgumentException(
                              new InternalRestError(
                                  ErrorConstants.VersionDoesNotMatchErrorCode,
                                  ErrorConstants.VersionDoesNotMatchErrorMessage));
                }

                await this.dataStore.UpdateVersion(packageIdentifier, packageVersion, version);
            }
            catch (DefaultException e)
            {
                log.LogError(e.ToString());
                return(ActionResultHelper.ProcessError(e.InternalRestError));
            }
            catch (Exception e)
            {
                log.LogError(e.ToString());
                return(ActionResultHelper.UnhandledError(e));
            }

            return(new ApiObjectResult(new ApiResponse <Version>(version)));
        }
Esempio n. 11
0
        public ActionResult Edit(CategoryView model)
        {
            CategoryView remodel      = new CategoryView();
            var          actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string errorString = "";
            string message     = "";
            bool   IsValid     = true;

            if (ModelState.IsValid)
            {
                //var currentCulture = Session[Common.CommonConstants.CurrentCulture];
                model.ModifiedBy = CurrentUser.UserID;
                remodel          = _categoryDao.Edit(model, out message);
                if (remodel != null && String.IsNullOrEmpty(message))
                {
                    actionStatus.ActionStatus = ResultSubmit.success;
                    actionStatus.ErrorReason  = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_CATEGORY_HAS_UPDATED_SUCCESSFULLY);
                    Session["ACTION_STATUS"]  = actionStatus;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    //ModelState.AddModelError("", Resources.InsertCategoryFailed);
                    errorString = Resources.MSG_THE_CATEGORY_HAS_UPDATED_UNSUCCESSFULLY;
                    goto actionError;
                }
            }
            else
            {
                IsValid = false;
                goto actionError;
            }

actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason = String.Format(SiteResource.HTML_ALERT_ERROR, Resources.MSG_ERROR_ENTER_DATA_FOR_FORM + errorString);
                Session["ACTION_STATUS"] = actionStatus;
            }
            ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.Name);
            return(View("Edit", model));
        }
Esempio n. 12
0
        public ActionResult Create(CatalogueView model, string saveclose = "", string savenew = "")
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string        message = "";
            CatalogueView result  = new CatalogueView();

            if (ModelState.IsValid)
            {
                model.CreatedById  = CurrentUser.UserID;
                model.ModifiedById = CurrentUser.UserID;
                result             = _catalogueRepo.CreateCatalogue(model, out message);

                if (result != null && result.Id > 0)
                {
                    actionStatus.ErrorReason  = String.Format(SiteResource.HTML_ALERT_SUCCESS, Resources.MSG_THE_CATEGORY_HAS_CREATED_SUCCESSFULLY);
                    actionStatus.ActionStatus = ResultSubmit.success;
                    Session["ACTION_STATUS"]  = actionStatus;

                    if (!String.IsNullOrWhiteSpace(saveclose))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else if (!String.IsNullOrWhiteSpace(savenew))
                    {
                        return(RedirectToAction("Create"));
                    }
                    else
                    {
                        return(RedirectToAction("Edit", new { id = result.Id }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.MSG_THE_CATEGORY_HAS_CREATED_UNSUCCESSFULLY);
                }
            }

            //load site configtion
            ViewBag.Title  = "Tạo catalog mới";
            ViewBag.Action = "Create";
            return(View("Edit", model));
        }
        public async Task AddNonExistingDrinkToShoppingListReturnsOK()
        {
            var drink = new Drink {
                Name = "drink", Quantity = 1
            };

            this.repository.Setup(r => r.GetByName(drink.Name)).ReturnsAsync(() => null);
            this.repository.Setup(r => r.Save(drink)).Returns(() => Task.CompletedTask);

            var subject = this.CreateSubject();

            var result = await subject.Post(drink);

            result.ShouldBeOfType <OkObjectResult>();
            var value = ActionResultHelper.GetOkObject <Drink>(result);

            value.Name.ShouldBe(drink.Name);
            value.Quantity.ShouldBe(drink.Quantity);
        }
        private bool ShouldHandleException(ExceptionContext context)
        {
            if (context.ActionDescriptor.IsControllerAction() &&
                ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType))
            {
                //TODO: Create DontWrap attribute to control wrapping..?

                return(true);
            }

            var accept = context.HttpContext.Request.Headers["Accept"];

            if (accept.ToString().Contains("application/json")) //TODO: Optimize
            {
                return(true);
            }

            return(false);
        }
Esempio n. 15
0
        public ActionResult PreservationUploadCloseFiles(IEnumerable <HttpPostedFileBase> files, string metaData, string messageId)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                if (string.IsNullOrEmpty(metaData))
                {
                    _uploadHelper.UploadSave(files);
                    return Content(string.Empty);
                }

                Models.FileResult fileBlob = _uploadHelper.ChunkUploadSave(files, metaData, messageId);
                if (fileBlob.Uploaded)
                {
                    fileBlob.ExtraDescription = UnZipPreservationFile(fileBlob.FileName);
                    _uploadHelper.RemoveUploadedFile(fileBlob.FileName, messageId);
                }
                return Content(JsonConvert.SerializeObject(fileBlob), System.Net.Mime.MediaTypeNames.Text.Plain);
            }, _loggerService));
        }
 public ActionResult ClosePreviousArchiveTasks(Guid idPreservationTask)
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         PreservationService service = new PreservationService();
         PreservationTask preservationTask = service.GetPreservationTask(idPreservationTask);
         int taskYear = preservationTask.StartDocumentDate.Value.Year;
         IList <int> years = new List <int>()
         {
             (taskYear - 1)
         };
         if (preservationTask.StartDocumentDate.Value != new DateTime(taskYear, 1, 1))
         {
             years.Add(taskYear);
         }
         ViewData["Years"] = years;
         TempData["IdPreservationTask"] = idPreservationTask;
         return PartialView("_ClosePreviousArchiveTasks");
     }, _loggerService));
 }
Esempio n. 17
0
        public ActionResult Detail(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                AwardBatch awardBatch = _preservationService.GetAwardBatch(id);
                if (awardBatch == null)
                {
                    throw new Exception(string.Format("Nessun pacchetto di versamento trovato con id {0}", id));
                }

                AwardBatchDetailsViewModel model = new AwardBatchDetailsViewModel()
                {
                    IdArchive = awardBatch.IdArchive,
                    IdAwardBatch = awardBatch.IdAwardBatch,
                    Name = awardBatch.Name,
                    IsOpen = awardBatch.IsOpen
                };
                return View(model);
            }, _loggerService));
        }
Esempio n. 18
0
 public ActionResult DownloadRDVToSign(string data)
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         string zipFile = string.Empty;
         try
         {
             ICollection <Guid> ids = JsonConvert.DeserializeObject <ICollection <Guid> >(HttpUtility.UrlDecode(data));
             zipFile = CreateRDVToSignZipToDownload(ids);
             return File(System.IO.File.ReadAllBytes(zipFile), System.Net.Mime.MediaTypeNames.Application.Zip);
         }
         finally
         {
             if (System.IO.File.Exists(zipFile))
             {
                 System.IO.File.Delete(zipFile);
             }
         }
     }, _loggerService));
 }
Esempio n. 19
0
 public ActionResult ArchivePreservationConfigurationSummary(Guid id, bool isCompleteWithErrors)
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         DocumentArchive archive = ArchiveService.GetArchive(id);
         ICollection <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(id);
         ArchiveWizardStepBaseViewModel model = new ArchiveWizardStepBaseViewModel()
         {
             IdArchive = id,
             ArchiveName = archive.Name,
             PathPreservation = archive.PathPreservation,
             MainDateAttribute = attributes.SingleOrDefault(s => s.IsMainDate == true).DisplayName,
             SelectedPreservationAttributes = attributes.Where(x => x.ConservationPosition > 0).OrderBy(o => o.ConservationPosition).Select(s => s.DisplayName).ToList(),
             SelectedPrimaryKeyAttributes = attributes.Where(x => x.KeyOrder > 0).OrderBy(o => o.KeyOrder).Select(s => s.DisplayName).ToList(),
             IsCompleted = true,
             IsCompleteWithErrors = isCompleteWithErrors
         };
         return PartialView("_ArchivePreservationConfigurationSummary", model);
     }, _loggerService));
 }
Esempio n. 20
0
        public ActionResult ArchivePreservationAttributesConfiguration(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                DocumentArchive archive = ArchiveService.GetArchive(id);
                ICollection <DocumentAttribute> archiveAttributes = AttributeService.GetAttributesFromArchive(id);
                ArchivePreservationAttributesConfigurationViewModel model = new ArchivePreservationAttributesConfigurationViewModel()
                {
                    IdArchive = id,
                    ArchiveName = archive.Name,
                    ArchiveAttributes = archiveAttributes.Where(x => !x.ConservationPosition.HasValue || x.ConservationPosition == 0)
                                        .OrderBy(o => o.DisplayName)
                                        .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName),
                    PreservationAttributes = archiveAttributes.Where(x => x.ConservationPosition > 0).OrderBy(o => o.ConservationPosition)
                                             .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName)
                };

                return PartialView("_ArchivePreservationAttributesConfiguration", model);
            }, _loggerService));
        }
        protected virtual void HandleAndWrapException(ExceptionContext context)
        {
            if (!ActionResultHelper.IsObjectResult(context.ActionDescriptor.GetMethodInfo().ReturnType))
            {
                return;
            }

            context.HttpContext.Response.StatusCode = GetStatusCode(context);

            context.Result = new ObjectResult(
                new AjaxResponse(
                    _errorInfoBuilder.BuildForException(context.Exception),
                    context.Exception is AbpAuthorizationException
                    )
                );

            EventBus.Trigger(this, new AbpHandledExceptionData(context.Exception));

            context.Exception = null; //Handled!
        }
        public ActionResult ExecuteVerify(PreservationVerifyIndexModel postedModel)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                PreservationVerifyExecuteModel model = new PreservationVerifyExecuteModel
                {
                    fromDate = postedModel.fromDate,
                    toDate = postedModel.toDate
                };

                //crea l'elenco dei job di verifica 1 per conservazione chiusa
                List <PreservationVerifyJob> jobs = new List <PreservationVerifyJob>();
                foreach (Guid idArchive in postedModel.selectedArchives.Select(s => Guid.Parse(s)))
                {
                    //conservazioni chiuse per archivio
                    DocumentArchive archive = ArchiveService.GetArchive(idArchive);
                    IList <Preservation> preservations = _preservationService.ArchivePreservationClosedInDate(idArchive, postedModel.fromDate, postedModel.toDate.AddDays(1).AddSeconds(-1));
                    if (preservations.Count > 0)
                    {
                        jobs.AddRange(preservations.Select(p => new PreservationVerifyJob
                        {
                            idArchive = idArchive.ToString(),
                            idPreservation = p.IdPreservation.ToString(),
                            archiveName = archive.Name
                        }));
                    }
                    else
                    {
                        jobs.Add(new PreservationVerifyJob
                        {
                            idArchive = idArchive.ToString(),
                            idPreservation = Guid.Empty.ToString(),
                            archiveName = archive.Name
                        });
                    }
                }

                model.jobs = jobs.ToArray();
                return View(model);
            }, _loggerService));
        }
        public virtual ActionResult Edit(TViewModel viewModel)
        {
            TEntity entity = AssignViewModelToEntity(viewModel);
            var     actionExceptionHelper = new ActionResultHelper <TEntity>();

            actionExceptionHelper.Method += Update;

            var result = Validate(entity, _CleanUpControllerName(), "Edit");

            if (!result.Passed)
            {
                _EditReturnPartialViewOnError(viewModel);
            }

            //var actionResultMessage = actionExceptionHelper.Process(entity, ModelState, CrudTransactionResultConstant.Update);
            var actionResultMessage = actionExceptionHelper.Process(entity, ModelState, _setting.GetMessage(SystemMessageConstant.RecordUpdated));

            return(actionResultMessage.ActionStatus == ActionStatusResult.Failed
               ? _EditReturnPartialViewOnError(viewModel)
               : Json(actionResultMessage, JsonRequestBehavior.AllowGet));
        }
Esempio n. 24
0
 public ActionResult DownloadPreservationFilesToClose()
 {
     return(ActionResultHelper.TryCatchWithLogger(() =>
     {
         string zipFile = string.Empty;
         try
         {
             CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel;
             List <Preservation> preservations = PreservationService.PreservationToClose(customerCompany.CompanyId);
             zipFile = CreatePreservationZipToDownload(preservations);
             return File(System.IO.File.ReadAllBytes(zipFile), System.Net.Mime.MediaTypeNames.Application.Zip);
         }
         finally
         {
             if (System.IO.File.Exists(zipFile))
             {
                 System.IO.File.Delete(zipFile);
             }
         }
     }, _loggerService));
 }
Esempio n. 25
0
        public ActionResult Edit(int Id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            string message = "";

            var model = _catalogueRepo.GetCatalogue(Id, out message);

            if (model != null && String.IsNullOrWhiteSpace(message))
            {
                ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.SiteName);
                return(View(model));
            }
            else
            {
                actionStatus.ErrorReason = String.Format(message);
                Session["ACTION_STATUS"] = actionStatus;
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 26
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var order = await _unitOfWork.OrderRepository.GetObjectAsync(id);

                if (order == null)
                {
                    return(ActionResultHelper.CreateFailedResult($"Order {id} not found"));
                }

                _unitOfWork.OrderRepository.RemoveObject(order);
                await _unitOfWork.Context.SaveChangesAsync();

                return(ActionResultHelper.CreateSucceededResult());
            }
            catch (Exception e)
            {
                _logger.LogError(e, "api/Orders/{id} DELETE technical error");
                return(ActionResultHelper.CreateFailedResult("Sorry there was a technical error. Try to retry the request or contact technical support."));
            }
        }
Esempio n. 27
0
        protected virtual bool ShouldHandleException(PageHandlerExecutingContext context)
        {
            //TODO: Create DontWrap attribute to control wrapping..?

            if (context.ActionDescriptor.IsPageAction() &&
                ActionResultHelper.IsObjectResult(context.HandlerMethod.MethodInfo.ReturnType, typeof(void)))
            {
                return(true);
            }

            if (context.HttpContext.Request.CanAccept(MimeTypes.Application.Json))
            {
                return(true);
            }

            if (context.HttpContext.Request.IsAjax())
            {
                return(true);
            }

            return(false);
        }
Esempio n. 28
0
        public async Task <ActionResult> OrderDetails([FromBody] OrderDetailsQuery request)
        {
            try
            {
                var dto = await Mediator.Send(request);

                return(Ok(dto));
            }
            catch (CustomerDetailsHttpResponseException)
            {
                return(ActionResultHelper.ToBadRequestActionResult(message: "Error While Fetching Customer Details", title: "Error", statusCode: StatusCodes.Status500InternalServerError));
            }
            catch (InvalidUser ex)
            {
                return(ActionResultHelper.ToBadRequestActionResult(message: ex.Message, title: "User Not Found", statusCode: StatusCodes.Status404NotFound));
            }

            catch (Exception ex)
            {
                return(ActionResultHelper.ToBadRequestActionResult(message: ex.Message, title: "Error", statusCode: StatusCodes.Status500InternalServerError));
            }
        }
        public ActionResult PreservationCheck(Guid id)
        {
            return(ActionResultHelper.TryCatchWithLogger(() =>
            {
                Preservation preservation = _preservationService.GetPreservation(id, false);
                if (preservation == null)
                {
                    throw new Exception(string.Format("PreservationCheck -> conservazione con id {0} non trovata", id));
                }

                PreservationCheckViewModel model = new PreservationCheckViewModel()
                {
                    IdArchive = preservation.IdArchive,
                    IdPreservation = preservation.IdPreservation,
                    ArchiveName = preservation.Archive.Name,
                    ConservationDescription = string.Concat("dal <b>", preservation.StartDate.GetValueOrDefault().ToString("dd/MM/yyyy"), "</b> al <b>", preservation.EndDate.GetValueOrDefault().ToString("dd/MM/yyyy"), "</b>"),
                    Path = preservation.Path,
                    Manager = preservation.User != null ? string.Concat(preservation.User.Name, " ", preservation.User.Surname) : string.Empty,
                    CloseDateLabel = preservation.CloseDate.HasValue ? preservation.CloseDate.Value.ToString("dd/MM/yyyy") : "#",
                    LastVerifiedDateLabel = preservation.LastVerifiedDate.HasValue ? preservation.LastVerifiedDate.Value.ToString("dd/MM/yyyy") : "#",
                    PathExist = !string.IsNullOrEmpty(preservation.Path) && Directory.Exists(preservation.Path),
                    IsClosed = preservation.CloseDate.HasValue
                };

                if (model.PathExist)
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(model.Path);
                    FileInfo[] files = directoryInfo.GetFiles("*verifica conservazione*", SearchOption.TopDirectoryOnly).OrderByDescending(t => t.LastWriteTime).ToArray();
                    model.VerifyFiles = files.Select(s => new PreservationCheckVerifyFileViewModel()
                    {
                        FileName = s.Name,
                        Success = !s.Name.Contains("negativo"),
                        DateCreatedLabel = string.Concat(s.LastWriteTime.ToShortDateString(), " ", s.LastWriteTime.ToShortTimeString())
                    }).ToList();
                }

                return View(model);
            }, _loggerService));
        }
Esempio n. 30
0
        public ActionResult Edit(long id = 0)
        {
            var actionStatus = new ActionResultHelper();

            actionStatus.ActionStatus = ResultSubmit.failed;
            bool IsValid = true;
            var  dao     = new ProductCategoryDao();
            ProductCategoryView model = new ProductCategoryView();

            if (id > 0)
            {
                model = dao.Find(id);
                if (model == null)
                {
                    IsValid = false;
                    actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                    goto actionError;
                }
                else
                {
                    ViewBag.Title = String.Format(Resources.LABEL_UPDATE, model.Name);
                    return(View(model));
                }
            }
            else
            {
                IsValid = false;
                actionStatus.ErrorStrings.Add(Resources.MSG_THE_PRODUCT_CATEGORY_HAS_NOT_FOUND);
                goto actionError;
            }
actionError:
            if (!IsValid)
            {
                actionStatus.ErrorReason             = String.Format(SiteResource.HTML_ALERT_ERROR, actionStatus.ShowErrorStrings());
                Session[SessionName.ActionStatusLog] = actionStatus;
            }

            return(RedirectToAction("Index"));
        }