using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Enums;
using APT.BaseData.Domain.Enums.PF;
using APT.BaseData.Domain.IServices;
using APT.BaseData.Domain.IServices.FM;
using APT.Infrastructure.Api;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.SC;
using APT.MS.Domain.Enums;
using InfluxData.Net.InfluxDb.Models.Responses;
using MySqlX.XDevAPI.Common;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;

namespace APT.BaseData.Services.DomainServices
{
    /// <summary>
    /// 获取会议Model
    /// </summary>
    public class SCMTMeetingService : CommonService, ISCMTMeetingService
    {
        IFMNotificationTaskService NotificationTaskService { get; set; }
        public SCMTMeetingService(IRepository repository, IFMNotificationTaskService notificationTaskService)
        : base(repository)
        {
            NotificationTaskService = notificationTaskService;
        }

        /// <summary>
        /// 获取会议 Model
        /// </summary>
        /// <param name="MEETINGID"></param>
        /// <param name="NAME"></param>
        /// <param name="THEME"></param>
        /// <param name="CODE"></param>
        /// <param name="ORG_ID"></param>
        /// <param name="DEPARTMENT_ID"></param>
        /// <param name="DEPARTMENT_TYPE"></param>
        /// <param name="USER_ID_ORIGINATOR"></param>
        /// <param name="CREACTTYPE"></param>
        /// <param name="MEETINGTYPE"></param>
        /// <param name="listUserID"></param>
        /// <param name="entity"></param>
        /// <param name="listAllUser"></param>
        public List<T_SC_MT_MEETING_PALL> GetEntityInfo(Guid MEETINGID, string NAME, string THEME, string CODE, Guid? ORG_ID, Guid DEPARTMENT_ID, int? DEPARTMENT_TYPE, Guid USER_ID_ORIGINATOR, CREACTTYPEEnum CREACTTYPE, SCMEETINGTYPE MEETINGTYPE, IEnumerable<Guid> listUserID, out T_SC_MT_MEETING entity)
        {
            var listAllUser = new List<T_SC_MT_MEETING_PALL>();
            entity = new T_SC_MT_MEETING();
            if (listUserID == null || !listUserID.Any())
            {
                return listAllUser;
            }
            if (listUserID != null && listUserID.Any())
            {
                listUserID = listUserID.Distinct();
            }

            entity.ID = MEETINGID;
            entity.CODE = CODE;
            entity.NAME = NAME;
            entity.MEETINGTYPE = MEETINGTYPE;
            entity.DEPARTMENT_ID = DEPARTMENT_ID;
            entity.LEVELVALUE = DEPARTMENT_TYPE;
            entity.USER_ID_ORIGINATOR = USER_ID_ORIGINATOR;//组长
            entity.BEGIN_TIME = DateTime.Now;
            entity.STATUS = PFStandardStatus.Draft;
            entity.PERSCORE = 0;
            entity.IS_DELETED = false;
            entity.ORG_ID = ORG_ID;
            entity.ENTITY_ORG_TPYE = 0;
            entity.FLOW_STATUS = 0;
            entity.FLOW_SEND_STATUS = 0;
            entity.CREATE_TIME = DateTime.Now;
            entity.CREATER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
            entity.CREACTTYPE = CREACTTYPE;
            entity.ISBEGIN = false;
            entity.ISCANCEL = false;
            //entity.CheckLevel_ENUMS_ID = ;
            //entity.Nav_MinutesID = ;
            //entity.ADDRESS = ;
            entity.THEME = THEME;
            //entity.PLANSET_ID = ;
            //entity.USER_ID_RECORDER = ;
            //entity.USER_ID_HOST = ;
            //entity.RECORD = ;
            //entity.APPROVE_ID = ;
            //entity.FORM_ID = ;
            //entity.FLOW_ID = ;
            //entity.MODIFY_TIME = ;
            //entity.MODIFIER_ID = ;
            //entity.CONTENT = ;

            foreach (var item in listUserID)
            {
                T_SC_MT_MEETING_PALL modelUser = new T_SC_MT_MEETING_PALL();
                modelUser.ID = Guid.NewGuid();
                modelUser.MEETING_ID = entity.ID;
                modelUser.PERSONTYPE = SCMEETINGPERSONTYPE.ALL;
                modelUser.USER_ID = item;
                modelUser.IS_DELETED = false;
                modelUser.ORG_ID = entity.ORG_ID;
                //modelUser.ENTITY_ORG_TPYE = "";
                //modelUser.FORM_ID = "";
                //modelUser.FLOW_STATUS = "";
                //modelUser.FLOW_SEND_STATUS = "";
                //modelUser.FLOW_ID = "";
                //modelUser.CREATE_TIME = "";
                //modelUser.MODIFY_TIME = "";
                //modelUser.CREATER_ID = "";
                //modelUser.MODIFIER_ID = "";
                //modelUser.JOINRESULT = "";
                //modelUser.NOTJOINREASON = "";
                modelUser.PERSONNATURE = PersonNature.JOIN;
                listAllUser.Add(modelUser);
            }
            return listAllUser;
        }
    }
}
