2023-05-17 16:00:50 +10:00
|
|
|
|
using AutoMapper;
|
2023-12-06 11:53:36 +10:00
|
|
|
|
using PARR.API.Authentication.Models;
|
2023-06-16 15:00:11 +10:00
|
|
|
|
using PARR.API.Contracts.V1.Responses;
|
2023-09-19 16:42:06 +10:00
|
|
|
|
using PARR.API.MappingProfiles.Resolvers;
|
2023-10-11 11:10:35 +10:00
|
|
|
|
using PARR.BLL.Helpers;
|
2024-03-20 15:26:14 +10:00
|
|
|
|
using PARR.Constants.Shortcode;
|
2023-10-12 12:06:47 +10:00
|
|
|
|
using PARR.DAL.DomainModels;
|
2024-03-20 15:26:14 +10:00
|
|
|
|
using PARR.DAL.Extensions;
|
2023-09-15 16:32:46 +10:00
|
|
|
|
using PARR.DAL.Models;
|
2023-05-17 16:00:50 +10:00
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
namespace PARR.API.MappingProfiles
|
2023-05-17 16:00:50 +10:00
|
|
|
|
{
|
|
|
|
|
|
public class DomainToResponseProfile : Profile
|
|
|
|
|
|
{
|
|
|
|
|
|
public DomainToResponseProfile()
|
|
|
|
|
|
{
|
2023-12-27 08:50:45 +10:00
|
|
|
|
#region Template
|
|
|
|
|
|
|
2023-09-20 09:13:46 +10:00
|
|
|
|
// --- Template ---
|
2023-09-19 15:47:50 +10:00
|
|
|
|
CreateMap<Template, TemplateResponse>()
|
2023-09-20 09:13:46 +10:00
|
|
|
|
.ForMember(d => d.Work, o => o.MapFrom(s => s.ApplicationsInWork!.Work))
|
|
|
|
|
|
.ForMember(d => d.Host, o => o.MapFrom(s => s.Host))
|
|
|
|
|
|
.ForMember(d => d.Process, o => o.MapFrom(s => s.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Process))
|
|
|
|
|
|
.ForMember(d => d.Subprocess, o => o.MapFrom(s => s.ApplicationsInWork!.Work!.Tnk!.Subprocess))
|
|
|
|
|
|
.ForMember(d => d.Tnk, o => o.MapFrom(s => s.ApplicationsInWork!.Work!.Tnk))
|
2023-09-20 12:09:07 +10:00
|
|
|
|
.ForMember(d => d.ShortDescription, o => o.MapFrom(s => s.ApplicationsInWork!.ShortDescription))
|
|
|
|
|
|
.ForMember(d => d.FullDescription, o => o.MapFrom(s => s.ApplicationsInWork!.FullDescription))
|
|
|
|
|
|
.ForMember(d => d.Solution, o => o.MapFrom(s => s.ApplicationsInWork!.Solution))
|
|
|
|
|
|
.ForMember(d => d.TemplateDuration, o => o.MapFrom(s => s.ApplicationsInWork!.TemplateDuration))
|
2023-09-20 09:13:46 +10:00
|
|
|
|
.ForMember(d => d.Initiator, o => o.MapFrom<TemplateInitiatorResolver>())
|
|
|
|
|
|
.ForMember(d => d.ClosingCode, o => o.MapFrom<TemplateClosingCodeResolver>())
|
2023-10-06 15:13:40 +10:00
|
|
|
|
.ForMember(d => d.Category, o => o.MapFrom<TemplateCategoryResolver>())
|
2024-02-26 09:20:13 +10:00
|
|
|
|
.ForMember(d => d.SyncStatus, o => o.MapFrom(s => s.RobotConfigurations.OrderBy(t => t.RobotCode)))
|
2023-10-17 16:59:53 +10:00
|
|
|
|
.ForMember(d => d.Schedule, o => o.MapFrom<TemplateScheduleResolver>())
|
|
|
|
|
|
.ForMember(d => d.Agent, o => o.MapFrom(s => s.ApplicationsInWork))
|
|
|
|
|
|
.ForMember(d => d.NextRun, o => o.MapFrom(s => s.ApplicationsInWork!.NextRun))
|
|
|
|
|
|
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun));
|
2023-09-20 09:13:46 +10:00
|
|
|
|
// === Template ===
|
2023-09-18 12:08:40 +10:00
|
|
|
|
|
2023-12-27 08:50:45 +10:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-10-11 15:28:37 +10:00
|
|
|
|
CreateMap<Template, TemplateScheduleEsppIdResponse>();
|
|
|
|
|
|
|
2023-10-17 16:59:53 +10:00
|
|
|
|
CreateMap<ApplicationsInWork, TemplateAgentResponse>()
|
|
|
|
|
|
.ForMember(d => d.IsAgent, o => o.MapFrom(s => s.IsAgent))
|
|
|
|
|
|
.ForMember(d => d.Name, o => o.MapFrom(s => s.AgentName))
|
|
|
|
|
|
.ForMember(d => d.Script, o => o.MapFrom(s => s.AgentScript))
|
|
|
|
|
|
.ForMember(d => d.TimeOutSec, o => o.MapFrom(s => s.AgentTimeOutSec));
|
|
|
|
|
|
|
2023-10-06 14:24:58 +10:00
|
|
|
|
CreateMap<DAL.Models.TaskStatus, TaskStatusResponse>();
|
2023-10-04 12:00:43 +10:00
|
|
|
|
|
2023-09-19 16:55:56 +10:00
|
|
|
|
|
|
|
|
|
|
CreateMap<Process, ProcessResponse>();
|
|
|
|
|
|
CreateMap<Subprocess, SubprocessResponse>();
|
|
|
|
|
|
CreateMap<Tnk, TnkResponse>();
|
|
|
|
|
|
CreateMap<Work, WorkResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-30 10:17:02 +10:00
|
|
|
|
CreateMap<Application, ApplicationResponse>()
|
|
|
|
|
|
.ForMember(t => t.Type, o => o.MapFrom(s => s.ApplicationType));
|
2023-09-19 16:55:56 +10:00
|
|
|
|
|
2023-11-30 10:17:02 +10:00
|
|
|
|
CreateMap<ApplicationType, ApplicationTypeResponse>();
|
|
|
|
|
|
|
2023-12-27 08:50:45 +10:00
|
|
|
|
#region Host
|
|
|
|
|
|
|
2023-11-30 10:17:02 +10:00
|
|
|
|
// --- Host ---
|
|
|
|
|
|
CreateMap<DAL.Models.Host, HostBaseResponse>()
|
|
|
|
|
|
.Include<DAL.Models.Host, HostTemplateResponse>()
|
|
|
|
|
|
.Include<DAL.Models.Host, HostWithApplicationsResponse>()
|
2023-09-28 14:28:10 +10:00
|
|
|
|
.ForMember(d => d.Status, o => o.MapFrom(s => s.EkStatus!.Name))
|
|
|
|
|
|
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.ResponseArea!.Name));
|
2023-09-19 16:55:56 +10:00
|
|
|
|
|
2023-11-30 10:17:02 +10:00
|
|
|
|
CreateMap<DAL.Models.Host, HostTemplateResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<DAL.Models.Host, HostWithApplicationsResponse>()
|
2023-12-05 16:32:34 +10:00
|
|
|
|
.ForMember(d => d.Applications, o => o.MapFrom(s => s.ApplicationsInHosts.Select(t => t.Application).OrderBy(t => t.Name)));
|
2023-11-30 10:17:02 +10:00
|
|
|
|
// === Host ===
|
|
|
|
|
|
|
2024-01-26 12:27:59 +10:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Robot
|
2023-12-27 08:50:45 +10:00
|
|
|
|
|
2023-10-03 16:54:01 +10:00
|
|
|
|
CreateMap<RobotStatus, RobotStatusResponse>();
|
|
|
|
|
|
|
2023-10-04 15:22:06 +10:00
|
|
|
|
CreateMap<RobotHistoryLevel, RobotHistoryLevelResponse>();
|
|
|
|
|
|
|
2023-10-06 13:58:10 +10:00
|
|
|
|
CreateMap<RobotHistory, RobotHistoryResponse>()
|
2023-10-04 15:22:06 +10:00
|
|
|
|
.ForMember(d => d.Level, o => o.MapFrom(s => s.RobotHistoryLevel))
|
|
|
|
|
|
.ForMember(d => d.Date, o => o.MapFrom(s => s.DateCreated))
|
2023-10-13 15:28:17 +10:00
|
|
|
|
.ForMember(d => d.TaskId, o => o.MapFrom(s => s.RobotConfigurationId))
|
|
|
|
|
|
.ForMember(d => d.TaskStatus, o => o.MapFrom(s => s.StatusTask))
|
|
|
|
|
|
.ForMember(d => d.TemplateId, o => o.MapFrom(s => s.RobotConfiguration!.TemplateId))
|
2024-01-26 12:27:59 +10:00
|
|
|
|
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.RobotConfiguration!.Template!.Name))
|
|
|
|
|
|
.ForMember(d => d.Robot, o => o.MapFrom(s => s.RobotConfiguration!.Robot));
|
2023-10-04 15:22:06 +10:00
|
|
|
|
|
2024-01-26 12:27:59 +10:00
|
|
|
|
#endregion
|
2023-10-06 09:49:36 +10:00
|
|
|
|
|
2023-12-27 08:50:45 +10:00
|
|
|
|
#region RobotConfiguration
|
2023-10-06 09:49:36 +10:00
|
|
|
|
// --- RobotConfiguration ---
|
2023-10-10 16:58:05 +10:00
|
|
|
|
CreateMap<RobotConfiguration, RobotTaskBaseResponse>()
|
|
|
|
|
|
.Include<RobotConfiguration, RobotTaskTemplateResponse>()
|
|
|
|
|
|
.Include<RobotConfiguration, RobotTaskScheduleResponse>()
|
|
|
|
|
|
.ForMember(d => d.TaskId, o => o.MapFrom(s => s.Id));
|
|
|
|
|
|
|
2023-10-06 09:49:36 +10:00
|
|
|
|
CreateMap<RobotConfiguration, RobotTaskTemplateResponse>()
|
|
|
|
|
|
.ForMember(d => d.IsActive, o => o.MapFrom(s => s.Template!.IsActiveTemplate))
|
|
|
|
|
|
.ForMember(d => d.ClosingCode, o => o.MapFrom<RobotTaskTemplateClosingCodeResolver>())
|
2023-10-24 15:40:52 +10:00
|
|
|
|
//todo
|
2023-10-06 09:49:36 +10:00
|
|
|
|
.ForMember(d => d.FullDescription, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.FullDescription))
|
|
|
|
|
|
.ForMember(d => d.ShortDescription, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.ShortDescription))
|
|
|
|
|
|
.ForMember(d => d.Solution, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Solution))
|
|
|
|
|
|
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.Template!.Host!.ResponseArea!.Name))
|
|
|
|
|
|
.ForMember(d => d.TemplateDuration, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.TemplateDuration))
|
|
|
|
|
|
.ForMember(d => d.Initiator, o => o.MapFrom<RobotTaskTemplateInitiatorResolver>())
|
|
|
|
|
|
.ForMember(d => d.Category, o => o.MapFrom<RobotTaskTemplateCategoryResolver>())
|
|
|
|
|
|
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Host!.WorkGroup))
|
|
|
|
|
|
.ForMember(d => d.Ek, o => o.MapFrom(s => s.Template!.Host!.Ek))
|
|
|
|
|
|
.ForMember(d => d.Name, o => o.MapFrom(s => s.Template!.Name))
|
|
|
|
|
|
.ForMember(d => d.ProcessName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Process!.Name))
|
|
|
|
|
|
.ForMember(d => d.ProcessEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Process!.EsppId))
|
|
|
|
|
|
.ForMember(d => d.SubprocessName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.Name))
|
|
|
|
|
|
.ForMember(d => d.SubprocessEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Subprocess!.EsppId))
|
2024-03-20 15:26:14 +10:00
|
|
|
|
.ForMember(d => d.TnkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.Name.ApplyShortcode(Shortcodes.EK, s.Template!.Host!.Ek)))
|
2023-10-06 09:49:36 +10:00
|
|
|
|
.ForMember(d => d.TnkEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Tnk!.EsppId))
|
2024-03-20 15:26:14 +10:00
|
|
|
|
//.ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Name))
|
|
|
|
|
|
// .ForMember(d => d.WorkName, o => o.MapFrom(s => ShortcodeHelpers.ApplyShortcode(Shortcodes.EK, s.Template.Host.Ek, ref s.Template!.ApplicationsInWork!.Work!.Name.ToString())))
|
|
|
|
|
|
.ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.Name.ApplyShortcode(Shortcodes.EK, s.Template!.Host!.Ek)))
|
2023-10-10 16:58:05 +10:00
|
|
|
|
.ForMember(d => d.WorkEsppId, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.Work!.EsppId));
|
2023-10-06 09:49:36 +10:00
|
|
|
|
|
2023-10-06 11:38:33 +10:00
|
|
|
|
CreateMap<RobotConfiguration, RobotTaskScheduleResponse>()
|
2023-10-10 16:58:05 +10:00
|
|
|
|
.ForMember(d => d.EsppId, o => o.MapFrom(s => s.Template!.ScheduleEsppId))
|
|
|
|
|
|
.ForMember(d => d.ScheduleName, o => o.MapFrom(s => s.Template!.Name))
|
|
|
|
|
|
.ForMember(d => d.IsActive, o => o.MapFrom(s => s.Template!.IsActiveSchedule))
|
|
|
|
|
|
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.Template!.Host!.ResponseArea!.Name))
|
|
|
|
|
|
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.Template!.Name))
|
|
|
|
|
|
.ForMember(d => d.TemplateId, o => o.MapFrom(s => s.Template!.Id))
|
|
|
|
|
|
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Host!.WorkGroup))
|
2023-10-11 11:10:35 +10:00
|
|
|
|
.ForMember(d => d.Exclude, o => o.MapFrom<RobotTaskScheduleExcludeResolver>())
|
|
|
|
|
|
.ForMember(d => d.Timezone, o => o.MapFrom<RobotTaskScheduleTimezoneResolver>())
|
|
|
|
|
|
.ForMember(d => d.RepeatRange, o => o.MapFrom<RobotTaskScheduleRepeatRangeResolver>())
|
2023-10-17 10:53:02 +10:00
|
|
|
|
//.ForMember(d => d.GenerationTime, o => o.MapFrom(s => s.Template!.ApplicationsInWork!.ScheduleGenerationTime))
|
|
|
|
|
|
.ForMember(d => d.GenerationTime, o => o.MapFrom(s => EsppScheduleHelpers.GetGenerationTime(s.Template!.ApplicationsInWork!.NextRun)))
|
|
|
|
|
|
.ForMember(d => d.NextStart, o => o.MapFrom(s => EsppScheduleHelpers.GetNextRun(s.Template!.ApplicationsInWork!.NextRun)))
|
|
|
|
|
|
//.ForMember(d => d.NextStart, o => o.MapFrom(s => EsppScheduleHelpers.GetFirstStart(s.Template!.ApplicationsInWork!.ScheduleStartDate, s.Template!.ApplicationsInWork!.ScheduleGenerationTime)))
|
2023-10-13 14:21:49 +10:00
|
|
|
|
//.ForMember(d => d.NextStart, o => o.MapFrom(s => EsppScheduleHelpers.GetNextScheduleStart(s.Template!.NextScheduleStart)))
|
2023-10-11 11:10:35 +10:00
|
|
|
|
.ForMember(d => d.ScheduleType, o => o.MapFrom(s =>
|
|
|
|
|
|
s.Template!.ApplicationsInWork!.EsppSchValues!.First()!.EsppSchTypeConfig!.EsppSchTypeSchedule!.Description))
|
2023-10-12 09:10:10 +10:00
|
|
|
|
.ForMember(d => d.ScheduleTypeCode, o => o.MapFrom(s =>
|
|
|
|
|
|
s.Template!.ApplicationsInWork!.EsppSchValues!.First()!.EsppSchTypeConfig!.EsppSchTypeSchedule!.Id))
|
2023-10-11 11:10:35 +10:00
|
|
|
|
.ForMember(d => d.Schedule, o => o.MapFrom<RobotTaskScheduleSchResolver>());
|
2023-10-06 09:49:36 +10:00
|
|
|
|
// === RobotConfiguration ===
|
2023-12-27 08:50:45 +10:00
|
|
|
|
#endregion
|
2023-10-06 09:49:36 +10:00
|
|
|
|
|
2023-10-06 11:38:33 +10:00
|
|
|
|
CreateMap<Robot, RobotResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<DAL.Models.TaskStatus, TaskStatusResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<RobotConfiguration, RobotConfigurationResponse>()
|
|
|
|
|
|
.ForMember(d => d.Robot, o => o.MapFrom(s => s.Robot))
|
2023-10-06 15:13:40 +10:00
|
|
|
|
.ForMember(d => d.TaskStatus, o => o.MapFrom(s => s.TaskStatus))
|
2023-10-06 11:38:33 +10:00
|
|
|
|
.ForMember(d => d.RobotStatus, o => o.MapFrom(s => s.RobotStatus));
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-12 12:06:47 +10:00
|
|
|
|
// --- EsppSch ---
|
|
|
|
|
|
CreateMap<EsppSchTypeSchedule, EsppScheduleTypeScheduleResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<EsppSchType, EsppScheduleTypeResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<EsppSchTypeValue, EsppScheduleTypeValueResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<EsppScheduleValDto, EsppScheduleValResponse>()
|
|
|
|
|
|
.ForMember(d => d.Order, o => o.MapFrom(s => s.Order))
|
|
|
|
|
|
.ForMember(d => d.Value, o => o.MapFrom(s => s.Value))
|
|
|
|
|
|
.ForMember(d => d.Type, o => o.MapFrom(s => s.Type));
|
|
|
|
|
|
// === EsppSch ===
|
|
|
|
|
|
|
2023-10-19 11:22:35 +10:00
|
|
|
|
CreateMap<AgentHistoryLevel, AgentHistoryLevelResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<AgentHistory, AgentHistoryResponse>()
|
2024-03-12 15:09:12 +10:00
|
|
|
|
.ForMember(d => d.Date, o => o.MapFrom(s => s.DateCreated))
|
|
|
|
|
|
.ForMember(d => d.Level, o => o.MapFrom(s => s.AgentHistoryLevel))
|
|
|
|
|
|
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.Template!.Name));
|
2023-12-05 16:32:34 +10:00
|
|
|
|
|
2023-12-21 16:00:08 +10:00
|
|
|
|
|
2023-12-05 16:32:34 +10:00
|
|
|
|
#region User
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<User, UserResponse>()
|
|
|
|
|
|
.ForMember(t => t.Roles, o => o.MapFrom(s => s.Roles.Select(t => t.Role).OrderBy(t => t!.Description)));
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<Role, RoleResponse>();
|
|
|
|
|
|
|
2023-12-06 11:53:36 +10:00
|
|
|
|
CreateMap<UserCache, UserProfileResponse>();
|
|
|
|
|
|
|
2023-12-05 16:32:34 +10:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-12-21 16:00:08 +10:00
|
|
|
|
#region Order
|
2023-12-27 08:50:45 +10:00
|
|
|
|
|
2023-12-21 16:00:08 +10:00
|
|
|
|
CreateMap<OrderStatus, OrderStatusResponse>();
|
2023-12-27 08:50:45 +10:00
|
|
|
|
|
2024-01-22 11:46:49 +10:00
|
|
|
|
CreateMap<Order, OrderResponseBase>()
|
|
|
|
|
|
.Include<Order, OrderForAgentHistoryResponse>()
|
|
|
|
|
|
.Include<Order, OrderResponse>();
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<Order, OrderForAgentHistoryResponse>()
|
|
|
|
|
|
.ForMember(s => s.Status, o => o.MapFrom(s => s.OrderStatus))
|
|
|
|
|
|
.ForMember(s => s.NextStatus, o => o.MapFrom(s => s.NextStatus));
|
|
|
|
|
|
|
2024-02-26 09:20:13 +10:00
|
|
|
|
CreateMap<Order, OrderResponse>()
|
|
|
|
|
|
.ForMember(s => s.Status, o => o.MapFrom(s => s.OrderStatus))
|
|
|
|
|
|
.ForMember(s => s.NextStatus, o => o.MapFrom(s => s.NextStatus));
|
2024-01-22 11:46:49 +10:00
|
|
|
|
|
2023-12-21 16:00:08 +10:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-03-12 15:09:12 +10:00
|
|
|
|
|
|
|
|
|
|
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
|
|
|
|
|
|
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
|
2024-03-14 10:14:25 +10:00
|
|
|
|
.ForMember(d => d.Application, o => o.MapFrom(s => s.Application));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CreateMap<EkStatus, EkStatusResponse>();
|
2023-05-17 16:00:50 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|