/// <summary> /// Stops monitoring the job and fires up <see cref="E:Sitecore.Jobs.AsyncUI.JobMonitor.JobFinished" /> event. /// </summary> private void OnJobFinished(RunnerOutput runnerOutput) { JobHandle = Handle.Null; var eventArgs = new SessionCompleteEventArgs { RunnerOutput = runnerOutput }; JobFinished?.Invoke(this, eventArgs); }
public void Run() { try { Method(this.Session, Script); if (Context.Job == null) { return; } var output = new RunnerOutput { Exception = null, Output = this.Session.Output.ToHtml(), HasErrors = this.Session.Output.HasErrors, }; Context.Job.Status.Result = output; JobContext.MessageQueue.PutMessage(new CompleteMessage { RunnerOutput = output }); } catch (ThreadAbortException ex) { TurboConsoleLog.Error("Script was aborted", ex); if (!Environment.HasShutdownStarted) { Thread.ResetAbort(); } } catch (Exception ex) { TurboConsoleLog.Error("Error while executing script.", ex); if (!Context.Job.IsNull()) { var output = new RunnerOutput() { Exception = ex, Output = String.Empty, //TODO: Implement HasErrors = true }; Context.Job.Status.Result = output; var message = new CompleteMessage { RunnerOutput = output }; JobContext.MessageQueue.PutMessage(message); } } }