Ejemplo n.º 1
0
        public IEnumerable <ScheduledJobStatus> GetStatus()
        {
            return(m_cache.ReadThrough($"jobsStat_{m_session.Project.Id}",
                                       TimeSpan.FromSeconds(20),
                                       () =>
            {
                var scheduler = m_jobsRepository.GetCompleteScheduler().OrderBy(s => s.LoopLaunchPriority).ToList();

                var result = new List <ScheduledJobStatus>(scheduler.Count);

                foreach (var sch in scheduler)
                {
                    result.Add(new ScheduledJobStatus()
                    {
                        ScheduleId = sch.Id,
                        Name = sch.ScheduledJob.Name,
                        LastRun =
                            sch.LastStartDt == null
                                    ? "Nikdy"
                                    : DateUtil.FormatDateWithAgo(sch.LastStartDt ?? sch.LastEndDt.Value, true),
                        CanBeStarted = sch.CanBeStartedManually && !IsRunning(sch),
                        CurrentStatus = GetJobStatus(sch),
                        StartMode = GetStartMode(sch)
                    });
                }

                return result;
            }));
        }
Ejemplo n.º 2
0
        protected override void StartJob(IJob job)
        {
            var elsaJob = job as ElsaJob;

            if (string.IsNullOrWhiteSpace(elsaJob?.Uid))
            {
                throw new InvalidOperationException("ElsaJob expected");
            }

            var jobEntity = m_jobsRepository.GetCompleteScheduler().FirstOrDefault(j => j.Uid == job.Uid);

            if (jobEntity == null)
            {
                throw new InvalidOperationException($"Invalid job Uid {elsaJob.Uid}");
            }

            m_executor.LaunchJob(jobEntity);
        }