2022-04-03 13:34:55 +08:00
|
|
|
using AutoMapper;
|
|
|
|
using BililiveRecorder.Core;
|
2022-04-03 20:43:38 +08:00
|
|
|
using BililiveRecorder.Core.Config.V3;
|
2022-04-09 16:43:05 +08:00
|
|
|
using BililiveRecorder.Core.Event;
|
2022-06-09 15:40:08 +08:00
|
|
|
using BililiveRecorder.Core.Templating;
|
|
|
|
using Newtonsoft.Json.Linq;
|
2022-04-03 13:34:55 +08:00
|
|
|
|
2022-04-03 15:34:22 +08:00
|
|
|
namespace BililiveRecorder.Web.Models.Rest
|
2022-04-03 13:34:55 +08:00
|
|
|
{
|
|
|
|
public class DataMappingProfile : Profile
|
|
|
|
{
|
|
|
|
public DataMappingProfile()
|
|
|
|
{
|
|
|
|
this.CreateMap<IRoom, RoomDto>()
|
|
|
|
.ForMember(x => x.RoomId, x => x.MapFrom(s => s.RoomConfig.RoomId))
|
2022-04-03 15:34:22 +08:00
|
|
|
.ForMember(x => x.AutoRecord, x => x.MapFrom(s => s.RoomConfig.AutoRecord))
|
2022-04-09 16:43:05 +08:00
|
|
|
.ForMember(x => x.IoStats, x => x.MapFrom(s => s.Stats))
|
|
|
|
.ForMember(x => x.RecordingStats, x => x.MapFrom(s => s.Stats))
|
2022-04-03 15:34:22 +08:00
|
|
|
;
|
2022-04-03 13:34:55 +08:00
|
|
|
|
2022-04-09 16:43:05 +08:00
|
|
|
this.CreateMap<RoomStats, RoomRecordingStatsDto>()
|
2022-04-03 15:34:22 +08:00
|
|
|
.ForMember(x => x.SessionDuration, x => x.MapFrom(s => s.SessionDuration.TotalMilliseconds))
|
|
|
|
.ForMember(x => x.SessionMaxTimestamp, x => x.MapFrom(s => s.SessionMaxTimestamp.TotalMilliseconds))
|
|
|
|
.ForMember(x => x.FileMaxTimestamp, x => x.MapFrom(s => s.FileMaxTimestamp.TotalMilliseconds))
|
|
|
|
;
|
2022-04-03 13:34:55 +08:00
|
|
|
|
2022-04-09 16:43:05 +08:00
|
|
|
this.CreateMap<RoomStats, RoomIOStatsDto>()
|
|
|
|
.ForMember(x => x.Duration, x => x.MapFrom(s => s.Duration.TotalMilliseconds))
|
|
|
|
.ForMember(x => x.DiskWriteDuration, x => x.MapFrom(s => s.DiskWriteDuration.TotalMilliseconds))
|
|
|
|
;
|
|
|
|
|
|
|
|
this.CreateMap<RecordingStatsEventArgs, RoomRecordingStatsDto>();
|
|
|
|
|
2022-04-03 13:34:55 +08:00
|
|
|
this.CreateMap<RoomConfig, RoomConfigDto>();
|
|
|
|
|
|
|
|
this.CreateMap<GlobalConfig, GlobalConfigDto>();
|
2022-06-09 15:40:08 +08:00
|
|
|
|
|
|
|
this.CreateMap<FileNameTemplateContextDto, FileNameTemplateContext>();
|
|
|
|
|
|
|
|
this.CreateMap<string, JObject>().ConvertUsing(s => JObject.Parse(s));
|
2022-04-03 13:34:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|