using PmsSecondaryPackaging.Interface.Model.Carrier;
using PmsSecondaryPackaging.Interface.Model.StepBook;
using PmsSecondaryPackaging.Interface.Model.TaskBook;
using PmsSecondaryPackaging.TaskManager.TaskBookBehavior;
using System.Collections.Generic;
using System.Threading;

namespace ProjectManagementSystem.TaskBookEvent
{
    public class TaskBookBehavior_65051 : BaseTaskBookBehavior
    {
        public TaskBookBehavior_65051() : base(65051)
        {

        }
        public override bool TaskBookSetting(TaskDetailInfoModel taskDetailInfo, List<StepDetailInfoModel> taskStepInfoList, CarrierInfoModel carrierInfo)
        {
            IsEnable = false; Asynchronous = true;
            return base.TaskBookSetting(taskDetailInfo, taskStepInfoList, carrierInfo);
        }


        public override bool TaskBookTermination(TaskDetailInfoModel taskDetailInfo, List<StepDetailInfoModel> taskStepInfoList, CarrierInfoModel carrierInfo)
        {
            return base.TaskBookTermination(taskDetailInfo, taskStepInfoList, carrierInfo);
        }

        public override bool TaskBookOperator(TaskDetailInfoModel taskDetailInfo, List<StepDetailInfoModel> taskStepInfoList, CarrierInfoModel carrierInfo)
        {
            StepDeleteInfoModel stepDeleteInfoModel = new StepDeleteInfoModel();
            stepDeleteInfoModel.TaskID = taskDetailInfo.TaskID;
            stepDeleteInfoModel.StepID = taskDetailInfo.CurrentStepID + 1;
            bool success = InterfaceService.DeleteTaskStep(stepDeleteInfoModel, out string Message);
            while (!success)
            {
                textDocument.WriteFile("");
                success = InterfaceService.DeleteTaskStep(stepDeleteInfoModel, out Message);
                Thread.Sleep(1000);
            }
            return true;
        }
    }
}
