191 lines
8.9 KiB
C#
191 lines
8.9 KiB
C#
|
//using AutoMapper;
|
|||
|
//using NPlatform.AutoMap;
|
|||
|
//using BZPT.Domains.Entity;
|
|||
|
//using BZPT.Domains.Entity.Sys;
|
|||
|
//using BZPT.Dto.VO;
|
|||
|
//using NPlatform.Result;
|
|||
|
//using System.Collections;
|
|||
|
//using System.Collections.Generic;
|
|||
|
//using System.Text;
|
|||
|
//using BZPT.Dto.Sys;
|
|||
|
//using System.Configuration;
|
|||
|
//using System.Reflection;
|
|||
|
//using BZPT.DTO.VO;
|
|||
|
//using BZPT.Dto.Std;
|
|||
|
//using System.Security.Cryptography;
|
|||
|
//using BZPT.DTO.Const;
|
|||
|
//using NPlatform.Infrastructure.Redis;
|
|||
|
//using NPlatform.Infrastructure;
|
|||
|
//using NPOI.SS.Formula.Functions;
|
|||
|
//using ServiceStack.DataAnnotations;
|
|||
|
|
|||
|
//namespace BZPT.Domains
|
|||
|
//{
|
|||
|
// public class AutoMapperProfile : Profile, IProfile
|
|||
|
// {
|
|||
|
// [Autowired]
|
|||
|
// private IRedisService _redisService { get; set; }
|
|||
|
// private Dictionary<string, string> user;
|
|||
|
// public AutoMapperProfile(IRedisService redisService)
|
|||
|
// {
|
|||
|
// _redisService = redisService;
|
|||
|
// user = this._redisService.GlobalHashGetAllAsync<string>(CacheKeyBZPT.CACHE_USER_ALL).Result;
|
|||
|
|
|||
|
// //用户到VO对象的映射
|
|||
|
// CreateMap<User, UserVO>()
|
|||
|
// .ForMember(dst=>dst.Organization,src=>src.MapFrom(z=>z.Organization.Name))// 指定某个的属性从另一个对象的子属性获取(展平对象)
|
|||
|
// .ForMember(dst => dst.RoleName,src => src.MapFrom(z => GetRoleName(z.Roles))) //来源字段
|
|||
|
// .ForMember(dst => dst.DutyName, src => src.MapFrom(z => z.Dutys == null ? string.Empty : GetDutyName(z.Dutys)))
|
|||
|
// .ForMember(dst => dst.DutyID,
|
|||
|
// src => src.MapFrom(z => z.Dutys == null || !z.Dutys.Any()
|
|||
|
// ? new string[] { } // 返回 []
|
|||
|
// : GetDutyID(z.Dutys).ToArray())) // 如果有元素,连接两个空字符串并返回
|
|||
|
// .ForMember(dst => dst.FilePath, src => src.MapFrom(z => z.OtherAttachments.SA04)) //来源字段
|
|||
|
// .ForMember(dst => dst.Email, src => src.MapFrom(z => DCodeEmail(z.Email)))
|
|||
|
// .ForMember(dst => dst.MobileNum,opt => opt.MapFrom(src => DCodedMobile(src.MobileNum)))
|
|||
|
// .ForMember(dst => dst.CreateUserName, src => src.MapFrom(z => GetUserName(z.CreateUser)))
|
|||
|
// .ReverseMap();
|
|||
|
|
|||
|
// CreateMap<User, UserDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser)))
|
|||
|
// .ForMember(dst => dst.Password, src => ReplacePassword())
|
|||
|
// .ForMember(dst => dst.Email, src => src.MapFrom(z => DCodeEmail(z.Email)))
|
|||
|
// .ForMember(dst => dst.MobileNum, opt => opt.MapFrom(src => DCodedMobile(src.MobileNum)))
|
|||
|
// .ReverseMap();
|
|||
|
|
|||
|
// CreateMap<Organization, OrganizationDto>()
|
|||
|
// .ForMember(dst => dst.Parents, src => src.MapFrom(z => z.Parents.Split(",", StringSplitOptions.RemoveEmptyEntries)))
|
|||
|
// .ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
// CreateMap<User, ResetUserVO>().ReverseMap();
|
|||
|
|
|||
|
// CreateMap<Dictionary, DictionaryDto>().ReverseMap();
|
|||
|
// CreateMap<DictionaryItem, DictionaryItemDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<Role, RoleDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
|
|||
|
// CreateMap<Region, RegionDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<SysClient, SysClientDto>().ReverseMap();
|
|||
|
|
|||
|
// CreateMap<Country, CountryDto>(MemberList.Destination).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<Resources, ResourcesDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
// CreateMap<Resources, ResourceTreeNode>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
// CreateMap<Duty, DutyDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<OwnerUnit, OwnerUnitDto>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
// CreateMap<Section, SectionDto>()
|
|||
|
// .ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser)))
|
|||
|
// .ForMember(dst => dst.CreateUserId, src => src.MapFrom(z => z.CreateUser))
|
|||
|
// .ReverseMap();
|
|||
|
|
|||
|
// CreateMap<OtherAttachments, OtherAttachmentsDto>().ReverseMap();
|
|||
|
// CreateMap<AttachmentConfig, AttachmentConfigDto>().ReverseMap();
|
|||
|
// CreateMap<OperationLog, OperationLogDto>().ReverseMap();
|
|||
|
// CreateMap<ErrorLog, ErrorLogDto>().ReverseMap();
|
|||
|
// CreateMap<ProjectInfo, ProjectInfoDto>()
|
|||
|
// .ForMember(dst => dst.CreateUserId, src => src.MapFrom(z => z.CreateUser))
|
|||
|
// .ForMember(dst=>dst.CreateUser,src=>src.MapFrom(z=> GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<LaborTeam, LaborTeamDto>()
|
|||
|
// .ForMember(dst => dst.CreateUserId, src => src.MapFrom(z => z.CreateUser))
|
|||
|
// .ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<WorkerGroup, WorkerGroupDto>()
|
|||
|
// .ForMember(dst => dst.CreateUserId, src => src.MapFrom(z => z.CreateUser))
|
|||
|
// .ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser))).ReverseMap();
|
|||
|
|
|||
|
// CreateMap<MobileVersion, MobileVersionVO>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser)))
|
|||
|
// .ForMember(dst => dst.FilePath, src => src.MapFrom(z => z.OtherAttachments.SA02))
|
|||
|
// .ReverseMap();
|
|||
|
// CreateMap<MobileMenu, MobileMenuVO>().ForMember(dst => dst.CreateUser, src => src.MapFrom(z => GetUserName(z.CreateUser)))
|
|||
|
// .ForMember(dst => dst.FilePath, src => src.MapFrom(z => z.OtherAttachments.SA04))
|
|||
|
// .ReverseMap();
|
|||
|
// CreateMap<MobileVersion, MobileVersionDto>().ReverseMap();
|
|||
|
// CreateMap<MobileMenu, MobileMenuDto>().ReverseMap();
|
|||
|
|
|||
|
// }
|
|||
|
// public string ReplacePassword()
|
|||
|
// {
|
|||
|
// return string.Empty;
|
|||
|
// }
|
|||
|
// public string GetRoleName(List<Role> roles) {
|
|||
|
// if(roles == null || roles.Count == 0)return string.Empty;
|
|||
|
// StringBuilder strRole = new StringBuilder();
|
|||
|
// foreach (Role role in roles) {
|
|||
|
// strRole.Append(role.Name);
|
|||
|
// strRole.Append(",");
|
|||
|
// }
|
|||
|
// return strRole.ToString();
|
|||
|
// }
|
|||
|
|
|||
|
// public string GetDutyName(List<Duty> Dutys)
|
|||
|
// {
|
|||
|
// StringBuilder strDuty = new StringBuilder();
|
|||
|
// foreach (Duty duty in Dutys)
|
|||
|
// {
|
|||
|
// strDuty.Append(duty.Name);
|
|||
|
// strDuty.Append(",");
|
|||
|
// }
|
|||
|
// return strDuty.ToString();
|
|||
|
// }
|
|||
|
|
|||
|
// public string GetUserName(string userid)
|
|||
|
// {
|
|||
|
// if (user.ContainsKey(userid))
|
|||
|
// return user[userid];
|
|||
|
// else return userid;
|
|||
|
// }
|
|||
|
|
|||
|
// // GetDutyID 方法
|
|||
|
// public string[] GetDutyID(List<Duty> Dutys)
|
|||
|
// {
|
|||
|
// if (Dutys == null || Dutys.Count == 0)
|
|||
|
// {
|
|||
|
// return new string[0]; // 如果传入的列表为空,返回空字符串数组
|
|||
|
// }
|
|||
|
|
|||
|
// string[] dutyIds = new string[Dutys.Count];
|
|||
|
|
|||
|
// for (int i = 0; i < Dutys.Count; i++)
|
|||
|
// {
|
|||
|
// dutyIds[i] = Dutys[i].Id; // 将每个 Duty 的 Id 存入数组
|
|||
|
// }
|
|||
|
|
|||
|
// return dutyIds;
|
|||
|
// }
|
|||
|
|
|||
|
// public string DCodeEmail(string eml)
|
|||
|
// {
|
|||
|
// var deml=AES.Decode(eml);
|
|||
|
// return MaskingHelper.MaskEmail(deml);
|
|||
|
// }
|
|||
|
// public string DCodedMobile(string phone)
|
|||
|
// {
|
|||
|
// phone = AES.Decode(phone);
|
|||
|
// return MaskingHelper.MaskMobile(phone);
|
|||
|
// }
|
|||
|
|
|||
|
// /// <summary>
|
|||
|
// /// 字符串转时间类型
|
|||
|
// /// </summary>
|
|||
|
// public class DateTimeTypeConverter : ITypeConverter<string, DateTime>
|
|||
|
// {
|
|||
|
// public DateTime Convert(string source, DateTime destination, ResolutionContext context)
|
|||
|
// {
|
|||
|
// return System.Convert.ToDateTime(source);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// /// <summary>
|
|||
|
// /// 字符串转Type类型
|
|||
|
// /// </summary>
|
|||
|
// public class TypeTypeConverter : ITypeConverter<string, Type>
|
|||
|
// {
|
|||
|
// public Type Convert(string source, Type destination, ResolutionContext context)
|
|||
|
// {
|
|||
|
// return Assembly.GetEntryAssembly().GetType(source);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|