//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2022-01-05 09:17:10 
//     对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;

namespace IRaCIS.Core.Application.Contracts
{
    public class SystemDocumentAttachmentView : SystemDocumentAttachmentAddOrEdit
    {

        public DateTime CreateTime { get; set; }

        public DateTime UpdateTime { get; set; }

    }


    public class SystemDocumentAttachmentAddOrEdit
    {
        public Guid? Id { get; set; }

        public string FileFormat { get; set; }

        public string Name { get; set; }

        public string FileName { get; set; }

        public string FilePath { get; set; }

        public decimal? FileSize { get; set; }

        public bool OffLine { get; set; }

        public Guid SystemDocumentId { get; set; }
    }

    public class SystemDocumentAttachmentQuery : PageInput
    {
        public string? FileFormat { get; set; }

        public string? FileName { get; set; }

        public string? FilePath { get; set; }

        public decimal? FileSize { get; set; }

        public bool? OffLine { get; set; }

        public Guid? SystemDocumentId { get; set; }
    }


    /// <summary> SystemDocumentView  列表视图模型 </summary>
    public class SystemDocumentView : SystemDocumentAddOrEdit
    {
        public string FullFilePath { get; set; } = string.Empty;
        public DateTime CreateTime { get; set; }
        public DateTime UpdateTime { get; set; }

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

        public int AttachmentCount { get; set; }

        public List<NeedConfirmedUserTypeView> NeedConfirmedUserTypeList { get; set; } = new List<NeedConfirmedUserTypeView>();
    }

    public class UnionDocumentView : SystemDocumentAddOrEdit
    {
        public string FullFilePath { get; set; } = string.Empty;
        public DateTime CreateTime { get; set; }
        public DateTime UpdateTime { get; set; }

        public bool IsSystemDoc { get; set; }

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

    }

    public class TrialSignDocView : UnionDocumentWithConfirmInfoView
    {
        public string TrialCode { get; set; }
        public string ResearchProgramNo { get; set; }

        public string ExperimentName { get; set; }


    }


    public class UnionDocumentWithConfirmInfoView : UnionDocumentView
    {

        public bool IsNeedSendEmial { get; set; }
        public DateTime UserCreateTime { get; set; }



        public DateTime? ConfirmTime { get; set; }

        public Guid? ConfirmUserId { get; set; }

        public bool IsConfirmed => ConfirmTime != null;

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

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


        public int AttachmentCount { get; set; }

        public DateTime? SuggestFinishTime
        {
            get
            {

                if (this.CreateTime > this.UserCreateTime && this.CurrentStaffTrainDays != null)
                {
                    return  DateTime.Parse(this.CreateTime.AddDays(this.CurrentStaffTrainDays.Value).ToString("yyyy-MM-dd")+" 22:00:00");
                }

                if (this.CreateTime < this.UserCreateTime && this.NewStaffTrainDays != null)
                {
                    return DateTime.Parse(this.UserCreateTime.AddDays(this.NewStaffTrainDays.Value).ToString("yyyy-MM-dd") + " 22:00:00");
                }

                return null;

            }
        }

        public string DocTypeCode { get; set; }

        public List<string> UserConfirmedUserTypeList => (DocNeedSignUserTypeList != null && IdentityUserTypeList != null) ? IdentityUserTypeList.Intersect(DocNeedSignUserTypeList).ToList() : new List<string>();


        public IEnumerable<string> IdentityUserTypeList { get; set; }
        public IEnumerable<string> DocNeedSignUserTypeList { get; set; }

    }


    public class TrialUserDto
    {
        public Guid UserId { get; set; }
        public string UserName { get; set; } = string.Empty;

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

    public class DocumentUnionWithUserStatView : UnionDocumentView
    {
        public int? DocumentUserCount { get; set; }
        public int? DocumentConfirmedUserCount { get; set; }
    }

    public class TrialUserUnionDocumentView
    {
        public Guid UserId { get; set; }

        public string UserTypeShortName { get; set; } = string.Empty;
        public string UserName { get; set; } = string.Empty;
        public string RealName { get; set; } = string.Empty;


        public int? SystemDocumentCount { get; set; }
        public int? TrialDocumentCount { get; set; }
        public int? TrialDocumentConfirmedCount { get; set; }
        public int? SystemDocumentConfirmedCount { get; set; }

        //public List<UnionDocumentView> DocumentList { get; set; }
    }






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

        public bool? IsDeleted { get; set; }
        public Guid? SystemDocumentId { get; set; }

        public Guid? FileTypeId { get; set; }

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

        public bool IsSigned { get; set; }


        public Guid? UserTypeId { get; set; }

        public DocUserSignType? DocUserSignType { get; set; }

        public DateTime? BeginCreateTime { get; set; }

        public DateTime? EndCreateTime { get; set; }


    }

    public class GetNextUnSignDocumentInDto
    {
        public Guid? TrialId { get; set; }

        public bool Asc { get; set; } = true;
        public string SortField { get; set; } = "";
    }

    public class TrialDocQuery : PageInput
    {
        public Guid? TrialId { get; set; }

        public Guid? FileTypeId { get; set; }

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


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

        public bool IsSigned { get; set; }

    }

    public class TrialUserDocUnionQuery : PageInput
    {
        [NotDefault]
        public Guid TrialId { get; set; }

        public Guid? FileTypeId { get; set; }


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

        public bool? IsSign { get; set; }

    }

    public class UserConfirmCommand
    {

        [NotDefault]
        public Guid DocumentId { get; set; }


        public bool isSystemDoc { get; set; }

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


    public class SystemDocQuery : PageInput
    {
        public Guid? FileTypeId { get; set; }


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

        public bool? IsSign { get; set; }

        public Guid? UserTypeId { get; set; }
        public Guid? UserId { get; set; }

        public bool? IsConfirmed { get; set; }

        /// <summary>
        /// 课时状态
        /// </summary>
        public bool? IsDeleted { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartConfirmTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndConfirmTime { get; set; }


        public DateTime? BeginCreateTime { get; set; }

        public DateTime? EndCreateTime { get; set; }
    }

    public class DocumentTrialUnionQuery : TrialUserDocUnionQuery
    {

        public Guid? UserTypeId { get; set; }
        public Guid? UserId { get; set; }

        public bool? IsConfirmed { get; set; }

        /// <summary>
        /// 课时状态
        /// </summary>
        public bool? IsDeleted { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartConfirmTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndConfirmTime { get; set; }

        public DateTime? BeginCreateTime { get; set; }

        public DateTime? EndCreateTime { get; set; }
    }

    ///<summary> SystemDocumentAddOrEdit  列表查询参数模型</summary>
    public class SystemDocumentAddOrEdit
    {
        public Guid? Id { get; set; }
        public Guid FileTypeId { get; set; }
        public string Name { get; set; } = string.Empty;
        public string Path { get; set; } = string.Empty;

        public bool IsDeleted { get; set; }

        public int SignViewMinimumMinutes { get; set; }

        public DocUserSignType DocUserSignType { get; set; }

        /// <summary>
        /// 现有员工培训天数
        /// </summary>
        public int? CurrentStaffTrainDays { get; set; }


        /// <summary>
        /// 新员工培训天数
        /// </summary>
        public int? NewStaffTrainDays { get; set; }

        /// <summary>
        /// 是否发布
        /// </summary>

        public bool IsPublish { get; set; } = false;

    }


    public class PublishSystemDocumentInDto
    {
        public List<Guid> Ids { get; set; }
    }

    public class AddOrEditSystemDocument : SystemDocumentAddOrEdit
    {

        public List<Guid> NeedConfirmedUserTypeIdList { get; set; } = new List<Guid>();
    }
}