Exemplo n.º 1
0
        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);
                }
            }
        }
 private T TryGetSettingValue <T>(string fieldName, T defaultValue, Func <T> action)
 {
     try
     {
         var result = action();
         if (result != null && !String.IsNullOrEmpty(result.ToString()))
         {
             return(result);
         }
         return(defaultValue);
     }
     catch (Exception ex)
     {
         TurboConsoleLog.Error($"Error while restoring setting {fieldName}.", ex);
         return(defaultValue);
     }
 }