public ActionResult ExecutePreConversion(Job job) { var scriptFilename = job.Profile.CustomScript.ScriptFilename; var loadScriptResult = _customScriptLoader.LoadScriptWithValidation(scriptFilename); if (!loadScriptResult.Result) { _logger.Error($"Exception during compilation of CustomScript: {loadScriptResult.ExceptionMessage}"); return(loadScriptResult.Result); } _logger.Trace($"Loaded CustomScript: {scriptFilename}"); try { var loadedScript = loadScriptResult.Script; var scriptResult = loadedScript.PreConversion(job, _logger); switch (scriptResult) { case ScriptResult.Abort: _logger.Error("Executing CustomScript PreConversion returned ScriptResult Abort"); return(new ActionResult(ErrorCode.CustomScriptPreConversion_ScriptResultAbort)); case ScriptResult.Success: default: return(new ActionResult()); } } catch (Exception e) { _logger.Error($"Exception during execution of CustomScript PreConversion:\r\n{e.Message}"); return(new ActionResult(ErrorCode.CustomScriptPreConversion_Exception)); } }
public void Check_ActionIsEnabled_RetunrsResultFromCustomScriptLoaderLoadScriptWithValidation() { _profile.CustomScript.Enabled = true; _profile.CustomScript.ScriptFilename = _scriptFilename; _customScriptLoader.LoadScriptWithValidation(_scriptFilename).Returns(new LoadScriptResult(_actionResult, null, "")); var result = _customScriptAction.Check(_profile, null, CheckLevel.Profile); _customScriptLoader.Received(1).LoadScriptWithValidation(_scriptFilename); Assert.AreEqual(_actionResult, result); }
public ActionResult Check(ConversionProfile profile, Accounts accounts, CheckLevel checkLevel) { if (!profile.CustomScript.Enabled) { return(new ActionResult()); } var loadResult = _customScriptLoader.LoadScriptWithValidation(profile.CustomScript.ScriptFilename); return(loadResult.Result); }