using DbCommon.BusinessCore.BaseCore;
using Pms.DataLibrary.Order;
using ProjectManagementSystem.Common.Core;
using ProjectManagementSystem.Common.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.TaskEvent
{
    public class ProcessPmsTaskInfo : ICustomProcess
    {
        private PmsTaskInfoManager pmsTaskInfoManger = new PmsTaskInfoManager();
        public void CustomProcess(List<TaskData> taskDataList)
        {
            //预约任务处理
            var dataList = pmsTaskInfoManger.Query();

            for (int i = 0; i < dataList.Count; i++)
            {
                var data = dataList[i];
                var response = PmsTaskService.Instance.TaskAdd(data);
                if (response.code == 20000)
                {
                    pmsTaskInfoManger.Delete(data.TaskID);
                }
                else
                {
                    if (data.Message != response.message)
                    {
                        data.Message = response.message;
                        pmsTaskInfoManger.Update(data);
                    }
                }
            }
        }
    }
}
