当前位置: 首页>>代码示例>>C#>>正文


C# Report.Finish方法代码示例

本文整理汇总了C#中Report.Finish方法的典型用法代码示例。如果您正苦于以下问题:C# Report.Finish方法的具体用法?C# Report.Finish怎么用?C# Report.Finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Report的用法示例。


在下文中一共展示了Report.Finish方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunAsync


//.........这里部分代码省略.........
                throw new ArgumentException("Compilation path is not set");

            //Check if all folders are present
            string rootfolder = PathExtension.FullPath(compilationPath);
            if (PathExtension.DirectoryExists(rootfolder) == false)
                throw new CompilationFolderException(rootfolder);

            //Check subfolders
            string assetScriptsPath = PathExtension.Combine(rootfolder, Xteq5EngineConstant.DirectoryNameAssets);
            CheckCompilationSubfolder(assetScriptsPath);

            string testScriptsPath = PathExtension.Combine(rootfolder, Xteq5EngineConstant.DirectoryNameTests);
            CheckCompilationSubfolder(testScriptsPath);

            string modulePath = PathExtension.Combine(rootfolder, Xteq5EngineConstant.DirectoryNameModules);
            CheckCompilationSubfolder(modulePath);


            //Perform a WMI test to make sure the script are able to access WMI data
            WMITest wmiTest = new WMITest();
            wmiTest.Test();


            //Create the result object
            Report report = new Report();

            //Set source folder
            report.CompilationFolder = compilationPath;

            //Everything looks fine so far. Let's go. 
            PSScriptRunnerPreferences prefs = new PSScriptRunnerPreferences();

            //We require at least version 4 of PowerShell
            prefs.RequiredPSVersion = 4;

            //Load modules from this path
            prefs.ModulePath = modulePath;

            //Add Xteq5EngineVersion read-only variable
            prefs.Variables.Add(new VariablePlain(Xteq5EngineConstant.VariableNameEngineVersion, Xteq5EngineConstant.Version, true));
            //Add Xteq5Running read-only variable
            prefs.Variables.Add(new VariablePlain(Xteq5EngineConstant.VariableNameIsActive, true, true));


            //Execute all assets
            List<AssetRecord> assets;
            using (PSScriptRunner psScriptRunnerAssets = new PSScriptRunner(prefs))
            {
                //Check that the PowerShell environment is ready. If not, we'll error out from here. 
                psScriptRunnerAssets.TestPowerShellEnvironment();

                //Now execute all assets
                AssetScriptRunner assetRunner = new AssetScriptRunner();
                assets = await assetRunner.Run(psScriptRunnerAssets, assetScriptsPath, progress);
            }


            //Add Xteq5Assets read-only variable
            Hashtable hashtableAssets = CreateHashtableFromAssetRecords(assets);
            prefs.Variables.Add(new VariablePlain(Xteq5EngineConstant.VariableNameAssets, hashtableAssets, true));

            //Execute all tests
            List<TestRecord> tests;
            using (PSScriptRunner psScriptRunnerTests = new PSScriptRunner(prefs))
            {
                //No TestPowerShellEnvironment() here, we should be OK if the first test worked

                TestScriptRunner testsRunner = new TestScriptRunner();
                tests = await testsRunner.RunAsync(psScriptRunnerTests, testScriptsPath, progress);
            }


            //Contstruct the final result            
            report.UserName = Environment.UserName;
            report.ComputerName = Environment.MachineName;
            report.EngineVersion = Xteq5EngineConstant.Version;

            report.Assets = assets;
            report.Tests = tests;

            CalculateRecordStatistics(report, assets, tests);

            //Set IssuesFound
            report.IssuesFound = false;
            report.TestIssuesFound = false;
            report.AssetIssuesFound = false;

            if ((report.AssetStatiscs.FatalCount + report.AssetStatiscs.MajorCount + report.AssetStatiscs.MinorCount) > 0)
                report.AssetIssuesFound = true;

            if ((report.TestStatiscs.FatalCount + report.TestStatiscs.MajorCount + report.TestStatiscs.MinorCount) > 0)
                report.TestIssuesFound = true;

            if (report.AssetIssuesFound || report.TestIssuesFound)
                report.IssuesFound = true;


            report.Finish();
            return report;
        }
开发者ID:c0ns0le,项目名称:Xteq5,代码行数:101,代码来源:Xteq5Runner.cs


注:本文中的Report.Finish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。