asmrobot
2024-12-31 a8536c3c73a4445b1f1252a1d3271e0c73b35613
src/RichCreator/Jobs/JobMonitor.cs
@@ -18,6 +18,7 @@
using System.Threading.Tasks;
using ZTImage.Configuration;
using RichCreator.Maps;
using RichCreator.Utility.Maps;
namespace RichCreator
{
@@ -30,15 +31,15 @@
        private WeGameJob wegameJob;
        private JobBase dnfJob;
        private Int32 taskIndex;
        private MapType mapType;
        Int32 runningStep = RunningStep.None;
        public JobMonitor(Int32 taskIndex)
        public JobMonitor(MapType maptype)
        {
            this.config = ConfigHelper.GetInstance<RichCreatorConfig>();
            this.cancelTokenSource = new CancellationTokenSource();
            this.taskIndex = taskIndex;
            this.mapType = maptype;
        }
        /// <summary>
@@ -51,7 +52,13 @@
                throw new Exception("不能多次运行");
            }
            canRun = false;
            ThreadPool.QueueUserWorkItem(MonitorBusinessThread);
            Thread thread = new Thread(MonitorBusinessThread);
            thread.IsBackground = true;
            thread.Start();
            //ThreadPool.QueueUserWorkItem(MonitorBusinessThread);
        }
        //停止
@@ -84,6 +91,7 @@
            for (; accountIndex < accountCount; accountIndex++)
            {
                RunningModel.UpdateAccountIndex(accountIndex+1);
                if (runningStep < RunningStep.SelectRole)
                {
                    string username, password;
@@ -109,7 +117,7 @@
                //设为顶层
                WindowUtils.SetDnfToTop();
                this.dnfJob = GetDNFJob();
                this.dnfJob = new DNFJob(this.mapType, this.config);
                jobResult = this.dnfJob.Do(this.cancelTokenSource.Token, runningStep);
                if (jobResult != ZTResult.Success)
                {
@@ -158,23 +166,5 @@
            ProcessUtils.CloseWeGame();
        }
        /// <summary>
        /// 根据当前选择的地图实例化DNF地图
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private JobBase GetDNFJob()
        {
            switch (this.taskIndex)
            {
                case 0:
                    return new DNFJob<LindongMap>(this.config);
                case 1:
                    return new DNFJob<SkillMap>(this.config);
                case 2:
                    return new DNFJob<TestMap>(this.config);
            }
            throw new Exception("this task index is error");
        }
    }
}