using AutoMapper; using DSWeb.Common.DB; using DSWeb.Areas.CompanyManage.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; using DSWeb.Areas.CmaCtrn.Models; using DSWeb.Areas.SysMng.Models.OpRecord; using DSWeb.Filter; using DSWeb.Common.Helper; using DSWeb.Areas.SysMng.Models.AccountConfig; using DSWeb.Common.Model; using DSWeb.MvcShipping.Models.MsOpSeaeCustFee; using DSWeb.Areas.SysMng.Models.OpTask; using DSWeb.Areas.MvcShipping.Models.MsOpRule; using DSWeb.MvcShipping.Models.MsOpSeaeEdi; using DSWeb.Areas.SysMng.Models.MpConfig; namespace DSWeb { public static class AutoMapperConfig { public static void Init() { Mapper.Initialize(cfg => { cfg.CreateMap(); cfg.CreateMap() ; cfg.CreateMap() .ForMember(x => x.ModuleName, map => map.MapFrom(t => EnumHelper.GetDescription(typeof(OpRecordModule), t.ModuleId))) .ForMember(x => x.CateName, map => map.MapFrom(t => EnumHelper.GetDescription(typeof(OpRecordCate), t.CateId))) ; cfg.CreateMap() .ForMember(x => x.TypeName, map => map.MapFrom(t => EnumHelper.GetDescription(typeof(AccountConfigType), t.Type))) .ForMember(x => x.CategoryName, map => map.MapFrom(t => EnumHelper.GetDescription(typeof(AccountConfigCate), t.Category))) .ForMember(x => x.CreateTime, map => map.MapFrom(t => t.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"))) ; cfg.CreateMap() ; cfg.CreateMap() ; #region op_rule cfg.CreateMap() .ForMember(x => x.EnableDisableTime, m => { m.MapFrom(d => d.EnableDisableTime.HasValue ? d.EnableDisableTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : ""); }); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); #endregion //个人邮箱配置 cfg.CreateMap() .ForMember(x => x.ReceiveSSL, map => map.MapFrom(t => t.ReceiveSSL.ToLower() == "on" ? true : false)) .ForMember(x => x.SmtpSSL, map => map.MapFrom(t => t.SmtpSSL.ToLower() == "on" ? true : false)) ; //舱单EDI cfg.CreateMap().ReverseMap(); //公众号配置 cfg.CreateMap() .ForMember(x => x.CreateTime, map => map.MapFrom(t => t.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"))) .ForMember(x => x.ModifyTime, map => map.MapFrom(t => t.ModifyTime.HasValue ? t.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")); cfg.CreateMap(); cfg.CreateMap() .ForMember(x => x.CreateTime, map => map.MapFrom(t => t.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"))) .ForMember(x => x.ModifyTime, map => map.MapFrom(t => t.ModifyTime.HasValue ? t.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "")); cfg.CreateMap(); }); } } }