2025-07-06 01:36:48 +03:00
|
|
|
using System.Text.Json;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using OneSwiss.Server.Components.Pages.ErrorLoggingService;
|
|
|
|
|
using OneSwiss.Server.Dto.ErrorLoggingService;
|
|
|
|
|
using OneSwiss.Server.Helpers;
|
|
|
|
|
using OneSwiss.Server.Models;
|
|
|
|
|
|
|
|
|
|
namespace OneSwiss.Server.AutoMapper;
|
|
|
|
|
|
|
|
|
|
public class ModelViewModelProfile : Profile
|
|
|
|
|
{
|
|
|
|
|
public ModelViewModelProfile()
|
|
|
|
|
{
|
|
|
|
|
CreateMap<ErrorReport, ErrorReportViewModel>()
|
|
|
|
|
.ConvertUsing((m, vm) =>
|
|
|
|
|
{
|
|
|
|
|
vm ??= new ErrorReportViewModel();
|
2025-09-08 20:24:15 +03:00
|
|
|
|
|
|
|
|
var reportRoot =
|
|
|
|
|
JsonSerializer.Deserialize<ReportRoot>(m.Report, ErrorReportsHelper.ReportSerializerOptions);
|
2025-07-06 01:36:48 +03:00
|
|
|
|
|
|
|
|
vm.Id = m.Id;
|
|
|
|
|
vm.Configuration = reportRoot!.ConfigInfo.Name;
|
|
|
|
|
vm.ConfigurationVersion = reportRoot.ConfigInfo.Version;
|
|
|
|
|
vm.Date = reportRoot.Time;
|
|
|
|
|
vm.PlatformVersion = reportRoot.ServerInfo.AppVersion;
|
|
|
|
|
vm.UserName = reportRoot.SessionInfo.UserName;
|
2025-08-05 15:16:07 +03:00
|
|
|
vm.AdditionalInfo = reportRoot.AdditionalInfo ?? string.Empty;
|
2025-09-08 20:24:15 +03:00
|
|
|
|
2025-07-06 01:36:48 +03:00
|
|
|
return vm;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
CreateMap<ErrorReportViewModel, ErrorReport>();
|
|
|
|
|
}
|
|
|
|
|
}
|