private void modifyStatus <T>(Action <JobStatusDTO> change, string failureMessage)
        {
            var jobKey = JobStatus.GetKey(typeof(T));

            try
            {
                var status = _persistence.Find(_channels.Name, jobKey);
                if (status == null)
                {
                    _logger.Info(() => "Unable to find a persisted record of Job {0} on channel {1}, creating a new one".ToFormat(jobKey, _channels.Name));
                    status = new JobStatusDTO {
                        NodeName = _channels.Name, JobKey = jobKey
                    };
                }

                status.Started = null;

                var current = status.LastExecution;

                change(status);

                _persistence.Persist(status);

                if (status.LastExecution != null && !ReferenceEquals(current, status.LastExecution))
                {
                    _persistence.RecordHistory(_channels.Name, jobKey, status.LastExecution);
                }
            }
            catch (Exception e)
            {
                var id = JobStatusDTO.ToId(_channels.Name, jobKey);
                _logger.Error(id, failureMessage, e);
            }
        }
 public static string ToId(string node, string job)
 {
     return("History-" + JobStatusDTO.ToId(node, job));
 }
Beispiel #3
0
 public JobStatusDTO Find(string nodeName, string jobKey)
 {
     return(_statusCache[JobStatusDTO.ToId(nodeName, jobKey)]);
 }