//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2022-10-20 11:52:31 
//     对此文件的更改可能会导致不正确的行为，并且如果重新生成代码，这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;

namespace IRaCIS.Core.Application.ViewModel
{
    /// <summary> TrialEmailNoticeConfigView  列表视图模型 </summary>
    public class TrialEmailNoticeConfigView : TrialEmailNoticeConfigAddOrEdit
    {

        public Guid UpdateUserId { get; set; }

        public DateTime UpdateTime { get; set; }

        public DateTime CreateTime { get; set; }

        public Guid CreateUserId { get; set; }

        public string TrialCriterionName { get; set; }


        public List<EmailUserInfoDto> TrialEmailNoticeUserList { get; set; }


        public new List<UserTypeEnum> ToUserTypeList => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.To).Select(t => t.UserType).ToList();
        public new List<UserTypeEnum> CopyUserTypeList => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.Copy).Select(t => t.UserType).ToList();

        public List<CriterionType>? SysCriterionTypeList { get; set; }

    }


    public class EmailUserInfoDto
    {

        public Guid TrialEmailNoticeConfigId { get; set; }


        public EmailUserType EmailUserType { get; set; }



        public UserTypeEnum UserType { get; set; }
    }


    public class GetTrialEmailSetOutDto
    {
        public Guid TrialId { get; set; }

        /// <summary>
        /// 发件箱账号
        /// </summary>
        public string EmailFromEmail { get; set; } = string.Empty;

        /// <summary>
        /// 发件人
        /// </summary>
        public string EmailFromName { get; set; } = string.Empty;

        /// <summary>
        /// 密码/授权码
        /// </summary>
        public string EmailAuthorizationCode { get; set; } = string.Empty;

        /// <summary>
        /// SMTP服务器
        /// </summary>
        public string EmailSMTPServerAddress { get; set; } = string.Empty;

        /// <summary>
        /// SMTP端口
        /// </summary>
        public int EmailSMTPServerPort { get; set; }

        /// <summary>
        /// 是否配置过邮箱
        /// </summary>
        public bool IsConfigureEmail { get; set; } = false;
    }

    public class SetTrialEmailInDto : GetTrialEmailSetOutDto
    {

    }
    public class GetTrialEmailSetInDto
    {
        public Guid TrialId { get; set; }
    }

    ///<summary>TrialEmailNoticeConfigQuery  列表查询参数模型</summary>
    public class TrialEmailNoticeConfigQuery
    {
        [NotDefault]
        public Guid TrialId { get; set; }

        public string EmailTopic { get; set; } = string.Empty;

        public EmailBusinessScenario? BusinessScenarioEnum { get; set; }

        public CriterionType? CriterionTypeEnum { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }

        public bool IsDistinguishCriteria { get; set; }

        public string SortField { get; set; } = string.Empty;

        public bool Asc { get; set; }

        public bool? IsEnable { get; set; }

        public int? EmailUrgentEnum { get; set; }

        public UserTypeEnum? ToUserType { get; set; }

        public UserTypeEnum? CopyUserType { get; set; }

        public BusinessModule? BusinessModuleEnum { get; set; }
    }


    public class GenerateEmailCommand
    {
        public Guid SubjectId { get; set; }

        public CriterionType CriterionType { get; set; }

        public EmailBusinessScenario BusinessScenarioEnum { get; set; }
    }

    public class BatchAddTrialEmailNoticeConfig
    {



        public Guid? Id { get; set; }

        public EmailBusinessScenario BusinessScenarioEnum { get; set; }

        public string Code { get; set; } = string.Empty;



        public Guid TrialId { get; set; }


        public List<UserTypeEnum> ToUserTypeList { get; set; }
        public List<UserTypeEnum> CopyUserTypeList { get; set; }


        public bool IsEnable { get; set; }
        public bool IsAutoSend { get; set; }


        public bool IsReturnRequired { get; set; }



        /// <summary> 业务模块 /// </summary>
        public int BusinessModuleEnum { get; set; }

        /// <summary> 业务层级 /// </summary>
        public int BusinessLevelEnum { get; set; }


        /// <summary> 邮件加急类型 /// </summary>
        public int EmailUrgentEnum { get; set; }

        /// <summary> 定时周期 /// </summary>
        public string EmailCron { get; set; } = string.Empty;

        /// <summary> 邮件主题 /// </summary>
        public string EmailTopic { get; set; } = string.Empty;

        public string EmailTopicCN { get; set; } = string.Empty;

        /// <summary> 附件 /// </summary>
        public string AttachPath { get; set; } = string.Empty;

        public string AttachCNPath { get; set; } = string.Empty;

        public string Description { get; set; } = string.Empty;


        public string AttachName { get; set; } = string.Empty;
        public string AttachNameCN { get; set; } = string.Empty;


        public string EmailHtmlContent { get; set; } = string.Empty;
        public string EmailHtmlContentCN { get; set; } = string.Empty;


        public int? EmailDelaySeconds { get; set; }

        [Comment("邮件配置的多个标准")]
        public List<CriterionType>? CriterionTypeList { get; set; }

        public bool IsDistinguishCriteria { get; set; }

    }


    ///<summary> TrialEmailNoticeConfigAddOrEdit  列表查询参数模型</summary>
    public class TrialEmailNoticeConfigAddOrEdit : BatchAddTrialEmailNoticeConfig
    {

        public Guid? TrialReadingCriterionId { get; set; }


        public string AuthorizationCode { get; set; } = string.Empty;

        public string SMTPServerAddress { get; set; } = string.Empty;

        public int SMTPServerPort { get; set; }


        public string FromName { get; set; } = string.Empty;

        public string FromEmail { get; set; } = string.Empty;

        public List<Guid> BlackUserIdList { get; set; }
    }


}


