public void PublishStatusUpdate(long jobRunId, JobRunStates state)
        {
            if (!this.jobRunStatusUpdates.ContainsKey(jobRunId))
            {
                this.jobRunStatusUpdates.Add(jobRunId, new List <JobRunStates>());
            }

            this.jobRunStatusUpdates[jobRunId].Add(state);

            foreach (var kvp in this.statusUpdateWaitCallBacks)
            {
                try
                {
                    var callback = kvp.Key;

                    var callbackHasPermitted = callback(this.jobRunStatusUpdates);

                    if (callbackHasPermitted)
                    {
                        kvp.Value.Set();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Example #2
0
        public void UpdateState(long jobRunId, JobRunStates state)
        {
            Logger.InfoFormat("[{0}] The JobRun with id: {0} has switched to the '{1}'-State", jobRunId, state);

            var jobRun = this.repository.GetJobRunById(jobRunId);

            jobRun.State = this.mapper.Map <ComponentModel.JobStorage.Model.JobRunStates>(state);

            if (state == JobRunStates.Started)
            {
                jobRun.ActualStartDateTimeUtc = DateTime.UtcNow;
            }

            if (state == JobRunStates.Completed || state == JobRunStates.Failed)
            {
                jobRun.ActualEndDateTimeUtc = DateTime.UtcNow;
            }

            this.repository.Update(jobRun);

            if (state == JobRunStates.Completed || state == JobRunStates.Failed)
            {
                this.messengerHub.Publish(new JobRunCompletedMessage(this)
                {
                    Id = jobRunId, IsSuccessful = state == JobRunStates.Completed
                });
            }
        }
Example #3
0
 public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
 {
     return(new PagedResult <JobRun>
     {
         Items = new List <JobRun>(),
         TotalItems = 0,
         PageSize = pageSize,
         Page = page
     });
 }
Example #4
0
        public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
        {
            var jobruns = this.repository.GetJobRunsByState((ComponentModel.JobStorage.Model.JobRunStates)state, page, pageSize, jobTypeFilter, jobUniqueNameFilter, query, showDeleted, sort);

            return(new PagedResult <JobRun>
            {
                Items = this.mapper.Map <List <JobRun> >(jobruns.Items),
                TotalItems = jobruns.TotalItems,
                Page = page,
                PageSize = pageSize
            });
        }
Example #5
0
        private void AddJobRun(DateTime plannedStartDateTimeUtc, JobRunStates state)
        {
            var scheduledTrigger = new InstantTrigger()
            {
                JobId = this.demoJob1Id, IsActive = true
            };
            var demoJob = this.repository.GetJob(this.demoJob1Id);

            var jobRun = this.repository.SaveNewJobRun(demoJob, scheduledTrigger, plannedStartDateTimeUtc);

            jobRun.State = state;
            this.repository.Update(jobRun);
        }
Example #6
0
        public List <JobRun> GetJobRunsByState(JobRunStates state, int page = 0, int pageSize = 50)
        {
            using (var session = this._documentStore.OpenSession())
            {
                var stateFromModel = (Model.JobRunStates)state;

                return(session.Query <Model.JobRun>()
                       .Where(p => p.State == stateFromModel)
                       .OrderByDescending(o => o.PlannedStartDateTimeUtc)
                       .Skip(page * pageSize)
                       .Take(pageSize)
                       .ToList()
                       .Select(s => s.ToModel())
                       .ToList());
            }
        }
Example #7
0
        public IEnumerable <JobRun> GetJobRunsByStateRange(JobRunStates minState, JobRunStates maxState)
        {
            if (maxState < minState)
            {
                throw new ArgumentOutOfRangeException(nameof(maxState), $"The parameter '{nameof(maxState)}' should not be lower than '{nameof(minState)}'");
            }

            for (var i = minState; i <= maxState; i++)
            {
                var currentState = (JobRunStates)i;

                var jobRunsByState = this.GetJobRunsByState(currentState);

                foreach (var jobRun in jobRunsByState)
                {
                    yield return(jobRun);
                }
            }
        }
Example #8
0
        public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
        {
            int totalItems;

            var enumerable = this.ApplyFiltersAndPaging(page, pageSize, jobTypeFilter, jobUniqueNameFilter, query, this.localJobRuns.Where(p => p.State == state), out totalItems);

            if (sort == null || sort.Length == 0)
            {
                enumerable = enumerable.OrderByDescending(o => o.PlannedStartDateTimeUtc);
            }
            else
            {
                enumerable = ApplySorting(sort, enumerable, this.JobRunOrderByMapping);
            }

            return(new PagedResult <JobRun>
            {
                Page = page,
                PageSize = pageSize,
                Items = enumerable.ToList(),
                TotalItems = totalItems,
            });
        }
 public void RaiseStatusChange(JobRunStates state)
 {
     this.progressChannel.PublishStatusUpdate(this.jobRunInfo.Id, state);
 }
Example #10
0
 public List <JobRun> GetJobRunsByState(JobRunStates state, int page = 0, int pageSize = 50)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public List <JobRun> GetJobRunsByState(JobRunStates state, int page = 0, int pageSize = 50)
 {
     return(new List <JobRun>());
 }
Example #12
0
 public List <JobRun> GetJobRunsByState(JobRunStates state, int page = 0, int pageSize = 50)
 {
     return(this.localJobRuns.Where(jr => jr.State == state).ToList().Clone());
 }
Example #13
0
 public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
 {
     return(this.storageProvider.GetJobRunsByState(state, page, pageSize, jobTypeFilter, jobUniqueNameFilter, query, showDeleted, sort));
 }
Example #14
0
 public List <JobRun> GetJobRunsByState(JobRunStates state, int page = 0, int pageSize = 50)
 {
     this.CheckFailAll();
     return(this.inMemoryVersion.GetJobRunsByState(state, page, pageSize));
 }
Example #15
0
 public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
 {
     throw new NotImplementedException();
 }
Example #16
0
 public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
 {
     this.CheckFailAll();
     return(this.inMemoryVersion.GetJobRunsByState(state, page, pageSize, jobTypeFilter, jobUniqueNameFilter, query, showDeleted, sort));
 }
Example #17
0
 public List <JobRun> GetJobRunsByState(JobRunStates state)
 {
     return(this.storageProvider.GetJobRunsByState(state));
 }
 public PagedResult <JobRun> GetJobRunsByState(JobRunStates state, int page = 1, int pageSize = 50, string jobTypeFilter = null, string jobUniqueNameFilter = null, string query = null, bool showDeleted = false, params string[] sort)
 {
     return(this.GetJobRuns(sql => sql.Where(p => p.State == state), page, pageSize, jobTypeFilter, jobUniqueNameFilter, query, showDeleted, sort));
 }
Example #19
0
        public void PublishStatusUpdate(long jobRunId, JobRunStates state)
        {
            var coreState = this.mapper.Map <Core.Models.JobRunStates>(state);

            this.jobRunService.UpdateState(jobRunId, coreState);
        }