示例#1
0
        private void ContextOnEnded(object sender, JobRunEndedEventArgs args)
        {
            var jobRunContext = sender as IJobRunContext;

            if (jobRunContext == null)
            {
                return;
            }

            JobRunInfo run;

            lock (this.syncRoot)
            {
                jobRunContext.Ended -= this.ContextOnEnded;

                run = args.JobRun;
                Logger.Info($"Removing context for JobRun with Id: {run.Id} (TriggerId: {run.TriggerId}, JobId: {run.JobId})");

                this.activeContexts.Remove(jobRunContext);
            }

            if (args.ExitCode == 0)
            {
                try
                {
                    this.progressChannel.PublishStatusUpdate(run.Id, JobRunStates.Completed);
                }
                catch (Exception e)
                {
                    Logger.ErrorException($"Exception while setting the end-time of the jobRun with id: {run.Id} (TriggerId: {run.TriggerId}, JobId: {run.JobId})", e);
                }

                if (args.DidReportProgress)
                {
                    try
                    {
                        this.progressChannel.PublishProgressUpdate(args.JobRun.Id, 100);
                    }
                    catch (Exception e)
                    {
                        Logger.ErrorException($"Exception while setting progress to 100% after completion of the jobRun with id: {run.Id} (TriggerId: {run.TriggerId}, JobId: {run.JobId})", e);
                    }
                }
            }
            else
            {
                Logger.Error($"The process within the context JobRun has exited with a non-zero exit code. JobRunId: {run.Id} (TriggerId: {run.TriggerId}, JobId: {run.JobId})");

                try
                {
                    this.progressChannel.PublishStatusUpdate(run.Id, JobRunStates.Failed);
                }
                catch (Exception e)
                {
                    Logger.ErrorException($"Exception while setting the 'Failed'-State to the jobRun with id: {run.Id} (TriggerId: {run.TriggerId}, JobId: {run.JobId})", e);
                }
            }
        }
示例#2
0
        protected virtual void OnEnded(JobRunEndedEventArgs e)
        {
            Logger.Info($"[{this.jobRunInfo.Id}] The Runner with ProcessId '{e.ProcInfo.Id}' has ended at '{e.ProcInfo.ExitTime}'. ExitCode: '{e.ProcInfo.ExitCode}'");

            this.Ended?.Invoke(this, e);
        }