Display results from Piscal processing

Error handling for Piscal processing
This commit is contained in:
2016-03-07 11:47:55 -05:00
parent c80d048c39
commit 05b2bfefb1
11 changed files with 191 additions and 58 deletions
@@ -1,5 +1,6 @@
using System.Linq;
using AutoMapper;
using LeafWeb.Core.Entities;
namespace LeafWeb.Web.ViewModels.LeafOutput
{
@@ -10,7 +11,9 @@ namespace LeafWeb.Web.ViewModels.LeafOutput
public int LeafInputFileId { get; set; }
public string LeafInputFilename { get; set; }
public string CurrentStatus { get; set; }
public string[] ErrorMessages { get; set; }
public string[] LeafOutputFilenames { get; set; }
public string LeafInputName { get; set; }
public string LeafInputIdentifier { get; set; }
public string LeafInputSiteId { get; set; }
public string LeafInputPhotosynthesisType { get; set; }
@@ -20,19 +23,33 @@ namespace LeafWeb.Web.ViewModels.LeafOutput
var config =
new MapperConfiguration(cfg =>
{
cfg.CreateMap<Core.Entities.LeafInputFile, LeafOutputViewModel>()
cfg.CreateMap<LeafInputFile, LeafOutputViewModel>()
.ForMember(dest => dest.LeafInputFileId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.LeafInputFilename, opt => opt.MapFrom(src => src.Filename))
.ForMember(dest => dest.LeafOutputFilenames,
opt => opt.ResolveUsing(file => file.LeafOutputFiles?.Select(o => o.Filename).ToArray() ?? new string[] {}))
opt => opt.ResolveUsing(
file =>
file.LeafOutputFiles?
.Select(o => o.Filename)
.ToArray()
?? new string[] {}))
.ForMember(dest => dest.LeafInputName, opt => opt.MapFrom(src => src.LeafInput.Name))
.ForMember(dest => dest.LeafInputIdentifier, opt => opt.MapFrom(src => src.LeafInput.Identifier))
.ForMember(dest => dest.LeafInputSiteId, opt => opt.MapFrom(src => src.LeafInput.SiteId))
.ForMember(dest => dest.LeafInputPhotosynthesisType, opt => opt.MapFrom(src => src.LeafInput.PhotosynthesisType.Name));
.ForMember(dest => dest.LeafInputPhotosynthesisType, opt => opt.MapFrom(src => src.LeafInput.PhotosynthesisType.Name))
.ForMember(dest => dest.ErrorMessages,
opt => opt.ResolveUsing(
src =>
src.StatusHistory?
.Where(sh => sh.Status == LeafInputStatusType.Error)
.Select(sh => sh.Description)
.ToArray()
?? new string[] {}));
});
Mapper = config.CreateMapper();
}
public LeafOutputViewModel(Core.Entities.LeafInputFile leafInput)
public LeafOutputViewModel(LeafInputFile leafInput)
{
Mapper.Map(leafInput, this);
}