/// <summary> /// Option for DLL use as alternate to Run which only outputs a file to return results as string /// CommandOption defaults will not have been set when used as DLL via CLI processing so some checks added /// </summary> /// <returns>output results</returns> public VerifyRulesResult GetResult() { WriteOnce.SafeLog("VerifyRulesCommand::Run", LogLevel.Trace); WriteOnce.Operation(MsgHelp.FormatString(MsgHelp.ID.CMD_RUNNING, "Verify Rules")); VerifyRulesResult verifyRulesResult = new VerifyRulesResult() { AppVersion = Utils.GetVersionString() }; try { RulesVerifier verifier = new RulesVerifier(_rules_path, _options.Log); verifyRulesResult.ResultCode = VerifyRulesResult.ExitCode.Verified; verifyRulesResult.RuleStatusList = verifier.Verify(); verifyRulesResult.ResultCode = verifier.IsVerified ? VerifyRulesResult.ExitCode.Verified : VerifyRulesResult.ExitCode.NotVerified; } catch (OpException e) { WriteOnce.Error(e.Message); //caught for CLI callers with final exit msg about checking log or throws for DLL callers throw; } return(verifyRulesResult); }
/// <summary> /// Option for DLL use as alternate to Run which only outputs a file to return results as string /// CommandOption defaults will not have been set when used as DLL via CLI processing so some checks added /// </summary> /// <returns>output results</returns> public VerifyRulesResult GetResult() { WriteOnce.SafeLog("VerifyRulesCommand::Run", LogLevel.Trace); WriteOnce.Operation(MsgHelp.FormatString(MsgHelp.ID.CMD_RUNNING, "Verify Rules")); VerifyRulesResult verifyRulesResult = new VerifyRulesResult() { AppVersion = Utils.GetVersionString() }; try { RulesVerifier verifier = new RulesVerifier(_rules_path, _options.Log); verifier.Verify(_options.Failfast); verifyRulesResult.ResultCode = VerifyRulesResult.ExitCode.Verified; RuleSet rules = verifier.CompiledRuleset; foreach (Rule rule in rules) { verifyRulesResult.RuleStatusList.Add(new RuleStatus() { RulesId = rule.Id, RulesName = rule.Name, Verified = true }); } } catch (OpException e) { WriteOnce.Error(e.Message); //caught for CLI callers with final exit msg about checking log or throws for DLL callers throw;; } return(verifyRulesResult); }