Пример #1
0
        public virtual void ScriptFinished(ScriptFinishedEventArgs.ScriptFinishedResult result, string error = null)
        {
            engineLogger.Information("Result Code: " + result.ToString());

            //add result variable if missing
            var resultVar = VariableList.Where(f => f.VariableName == "taskt.Result").FirstOrDefault();

            //handle if variable is missing
            if (resultVar == null)
            {
                resultVar = new Script.ScriptVariable()
                {
                    VariableName = "taskt.Result", VariableValue = ""
                };
            }

            //check value
            var resultValue = resultVar.VariableValue.ToString();


            if (error == null)
            {
                engineLogger.Information("Error: None");

                if (taskModel != null && serverSettings.ServerConnectionEnabled)
                {
                    HttpServerClient.UpdateTask(taskModel.TaskID, "Completed", "Script Completed Successfully");
                }

                if (string.IsNullOrEmpty(resultValue))
                {
                    TasktResult = "Successfully Completed Script";
                }
                else
                {
                    TasktResult = resultValue;
                }
            }

            else
            {
                engineLogger.Information("Error: " + error);

                if (taskModel != null)
                {
                    HttpServerClient.UpdateTask(taskModel.TaskID, "Error", error);
                }

                TasktResult = error;
            }

            engineLogger.Dispose();


            CurrentStatus = EngineStatus.Finished;
            ScriptFinishedEventArgs args = new ScriptFinishedEventArgs();

            args.LoggedOn      = DateTime.Now;
            args.Result        = result;
            args.Error         = error;
            args.ExecutionTime = sw.Elapsed;
            args.FileName      = FileName;

            Core.Server.SocketClient.SendExecutionLog("Result Code: " + result.ToString());
            Core.Server.SocketClient.SendExecutionLog("Total Execution Time: " + sw.Elapsed);


            //convert to json
            var serializedArguments = Newtonsoft.Json.JsonConvert.SerializeObject(args);

            //write execution metrics
            if ((engineSettings.TrackExecutionMetrics) && (FileName != null))
            {
                var summaryLogger = new Logging().CreateJsonLogger("Execution Summary", Serilog.RollingInterval.Infinite);
                summaryLogger.Information(serializedArguments);
                summaryLogger.Dispose();
            }


            Core.Client.EngineBusy = false;


            if (serverSettings.ServerConnectionEnabled)
            {
                HttpServerClient.CheckIn();
            }


            ScriptFinishedEvent?.Invoke(this, args);
        }
Пример #2
0
        public virtual void ScriptFinished(ScriptFinishedEventArgs.ScriptFinishedResult result, string error = null)
        {
            engineLogger.Information("Result Code: " + result.ToString());



            if (error == null)
            {
                engineLogger.Information("Error: None");

                if (taskModel != null && serverSettings.ServerConnectionEnabled)
                {
                    HttpServerClient.UpdateTask(taskModel.TaskID, "Completed", "Script Completed Successfully");
                }
            }

            else
            {
                engineLogger.Information("Error: " + error);

                if (taskModel != null)
                {
                    HttpServerClient.UpdateTask(taskModel.TaskID, "Error", error);
                }
            }

            engineLogger.Dispose();


            CurrentStatus = EngineStatus.Finished;
            ScriptFinishedEventArgs args = new ScriptFinishedEventArgs();

            args.LoggedOn      = DateTime.Now;
            args.Result        = result;
            args.Error         = error;
            args.ExecutionTime = sw.Elapsed;
            args.FileName      = FileName;

            Core.Server.SocketClient.SendExecutionLog("Result Code: " + result.ToString());
            Core.Server.SocketClient.SendExecutionLog("Total Execution Time: " + sw.Elapsed);


            //convert to json
            var serializedArguments = Newtonsoft.Json.JsonConvert.SerializeObject(args);

            //write execution metrics
            if ((engineSettings.TrackExecutionMetrics) && (FileName != null))
            {
                var summaryLogger = new Logging().CreateJsonLogger("Execution Summary", Serilog.RollingInterval.Infinite);
                summaryLogger.Information(serializedArguments);
                summaryLogger.Dispose();
            }


            Core.Client.EngineBusy = false;


            if (serverSettings.ServerConnectionEnabled)
            {
                HttpServerClient.CheckIn();
            }


            ScriptFinishedEvent?.Invoke(this, args);
        }