示例#1
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                string groupProcess = string.Format("GroupProcess{0}", DateTime.Now.ToBinary());

                int threads = GestaoEscolarServicosBO.GetQuantidadeMaximaFilaFechamento();
                threads = threads <= 0 ? 1 : threads;

                for (int i = 0; i < threads; i++)
                {
                    var jobKey = new JobKey(string.Format("UniqueJobID{0}", i), groupProcess);

                    IJobDetail jobDetail = JobBuilder.Create <MS_JOB_ProcessamentoNotaFrequenciaFechamento>()
                                           .WithIdentity(jobKey)
                                           .Build();

                    ITrigger trigger = TriggerBuilder.Create()
                                       .WithIdentity(string.Format("UniqueTriggerID{0}", i), groupProcess)
                                       .StartNow()
                                       .ForJob(jobDetail)
                                       .Build();

                    context.Scheduler.ScheduleJob(jobDetail, trigger);
                }
            }
            catch (Exception ex)
            {
                Util.GravarErro(ex, context.Scheduler.Context);
            }
        }