/// <summary> /// Вызвать скрипт /// </summary> /// <param name="jsScript"></param> /// <returns></returns> public async Task <JsScriptExecutedResult> RunScriptDetaiiled(string jsScript) { if (string.IsNullOrWhiteSpace(jsScript)) { return(new JsScriptExecutedResult("Скрипт не может быть пустой строкой")); } var startDate = DateTime.UtcNow; var context = GetContext(); JsScriptExecutedResult result = new JsScriptExecutedResult { Script = jsScript, StartedOnUtc = startDate }; try { context.Engine.Execute(jsScript); result.IsSucceeded = true; result.ErrorMessage = null; result.ExceptionData = null; } catch (Exception ex) { Logger.LogError(ex, "RunScriptDetaiiled.Error"); result.IsSucceeded = false; result.ErrorMessage = ex.Message; result.ExceptionData = new ExcepionData { Message = ex.Message, StackTrace = ex.StackTrace }; } result.FinishedOnUtc = DateTime.UtcNow; result.ConsoleLogs = context.ConsoleLogs; result.ExecutionLogs = context.ExecutionLogs; await Storage.AddResult(result); return(result); }
/// <inheritdoc /> public Task AddResult(JsScriptExecutedResult model) { return(Task.CompletedTask); }