Exemplo n.º 1
0
 public async Task AddDefaultJob(DefaultJob defaultJob)
 {
     foreach (var item in defaultJob.Jobs)
     {
         ScheduleManage.Instance.AddScheduleList(item);
         //if (item.JobName == defaultJob.WxSyncAccessTokenJob)
         //{
         //    await SchedulerCenter.Instance.RunScheduleJob<ScheduleManage, WxAccessTokenJob>(item.JobGroup, item.JobName);
         //}
         //else if (item.JobName == defaultJob.WxSyncUserInfoJob)
         //{
         //    await SchedulerCenter.Instance.RunScheduleJob<ScheduleManage, WxUserInfoJob>(item.JobGroup, item.JobName);
         //}
     }
 }
Exemplo n.º 2
0
        public virtual void AddSprite(Sprite s)
        {
            if (DefaultJob == null)
            {
                Logger.Warn("Attempted to add Sprite " + s + " to default job, but no default job found!");
            }

            if (DefaultJob != null)
            {
                DefaultJob.AddSprite(s);
                s._worlds.Add(this);
                s.OnAddedToWorld(this);
            }
            var logical = s as ILogical;

            if (logical != null)
            {
                AddLogical(logical);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化调度
        /// </summary>
        /// <returns></returns>
        public async Task Initialize()
        {
            List <ScheduleEntity> list = await this.GetEntityListAsync();

            foreach (var item in list)
            {
                //加载调度
                ScheduleManage.Instance.AddScheduleList(item);
                ///运行
                await SchedulerCenter.Instance.RunScheduleJob <ScheduleManage>(item.JobGroup, item.JobName);
            }
            //判断默认任务是否存在
            DefaultJob defaultJob = new DefaultJob();

            if (list.Select(m => m.JobName).Intersect(defaultJob.Jobs.Select(n => n.JobName)).Count() <= 0)//判断是否有交集
            {
                foreach (var item in defaultJob.Jobs)
                {
                    if (list.Select(m => m.JobName).Contains(item.JobName) == false)
                    {
                        await this.AddOrUpdateAsync(new SysSchedule
                        {
                            JobId        = item.JobId,
                            JobGroup     = item.JobGroup,
                            JobName      = item.JobName,
                            Cron         = item.Cron,
                            Status       = (byte)item.Status,
                            BeginTime    = item.BeginTime,
                            AssemblyName = item.AssemblyName,
                            ClassName    = item.ClassName,
                            CreateTime   = DateTime.Now
                        });
                    }
                }
            }
            await AddDefaultJob(defaultJob);
        }