Ejemplo n.º 1
0
        public async Task PlanExecution(ISyncAgentScheduler scheduler, Dictionary <string, object> dataParams = null)
        {
            IJobDetail job = JobBuilder.Create <JobSchedulerJob>()
                             .WithIdentity(nameof(JobSchedulerJob))
                             .Build();

            ITrigger trigger = TriggerBuilder.Create()
                               .StartNow()
                               .WithSimpleSchedule(x => x
                                                   .WithIntervalInSeconds(5)
                                                   .WithMisfireHandlingInstructionIgnoreMisfires()
                                                   .RepeatForever())
                               .Build();

            job.JobDataMap.Put("Scheduler", scheduler);             //todo to const

            await scheduler.PlanJob(job, trigger);
        }
Ejemplo n.º 2
0
        public async Task PlanExecution(ISyncAgentScheduler scheduler, Dictionary <string, object> dataParams = null)
        {
            if (dataParams != null && dataParams.ContainsKey(nameof(SyncAgentTask)))             //todo keys to const
            {
                if (dataParams[nameof(SyncAgentTask)] is SyncAgentTask syncAgentTask)
                {
                    IJobDetail job = JobBuilder.Create <IsolatedWorkExecutorJob>()
                                     .WithIdentity(syncAgentTask.Id.ToString())
                                     .Build();

                    ITrigger trigger = TriggerBuilder.Create()
                                       .StartNow()
                                       .Build();

                    job.JobDataMap.Put(nameof(SyncAgentTask), syncAgentTask);

                    await scheduler.PlanJob(job, trigger);

                    return;
                }
            }
            throw new ArgumentException($"Parameter {nameof(SyncAgentTask)} is required to plan execution of {nameof(IsolatedWorkExecutorJob)}");
        }