Пример #1
0
        public void LaunchJob(IJobSchedule jobEntry)
        {
            IExecutableJob jobExecutable = null;

            try
            {
                m_log.Info($"Vytvarim instanci {jobEntry.ScheduledJob.ModuleClass}");
                jobExecutable = m_serviceLocator.InstantiateNow <IExecutableJob>(jobEntry.ScheduledJob.ModuleClass);

                if (jobExecutable == null)
                {
                    throw new InvalidOperationException("Cannot instantiate the job");
                }

                m_log.Info($"Job instance created {jobExecutable}");
            }
            catch (Exception ex)
            {
                m_log.Error("Job instantiation failed", ex);
                return;
            }

            m_scheduledJobs.MarkJobStarted(jobEntry);

            try
            {
                m_log.Info("Spoustim job");
                jobExecutable.Run(jobEntry.ScheduledJob.CustomData);

                m_log.Info("Job uspesne dokoncen");
                m_scheduledJobs.MarkJobSucceeded(jobEntry);
            }
            catch (Exception ex)
            {
                m_log.Error("Job selhal", ex);
                m_scheduledJobs.MarkJobFailed(jobEntry);
            }
        }
Пример #2
0
 public void OnJobSucceeded(IJob job)
 {
     m_scheduledJobs.MarkJobSucceeded(m_scheduledJobs.GetJobByUid(job.Uid));
 }