private static string ZipXlsFiles(List <string> fileList) { string zipFileName = Guid.NewGuid().ToString() + ".zip"; string zipFilePath = RunDirectory.LinkTempPath(zipFileName); ZipCompress zip = new ZipCompress(); zip.BeginZip(zipFilePath); try { foreach (string xlsFileName in fileList) { string filePath = RunDirectory.LinkTempPath(xlsFileName); try { zip.AddFileToZip(filePath, xlsFileName); } finally { File.Delete(filePath); } } } finally { zip.FinishZip(); } return(zipFileName); }
private static string WriteExcelFile(IWorkbook workbook, string fileName) { string result = string.Empty; bool flag = string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(fileName.Trim()); if (flag) { result = Guid.NewGuid().ToString() + ".xls"; } else { result = fileName; } string filePath = RunDirectory.LinkTempPath(result); bool flag2 = File.Exists(filePath); if (flag2) { File.Delete(filePath); } FileStream file = new FileStream(filePath, FileMode.Create); workbook.Write(file); file.Close(); workbook = null; return(result); }
protected override void PrepareData() { this._DownloadFileFullPath = RunDirectory.LinkTempPath(this._FileName); bool flag = File.Exists(this._DownloadFileFullPath); if (flag) { this._FileStream = File.OpenRead(this._DownloadFileFullPath); return; } throw new Exception("文件已被他人删除,请刷新后查看!"); }
/// <summary> /// Encapsulates logic for running tests. /// </summary> public override void Execute() { if (!ContinueExecution) { // If the run directory already exists, we need to get rid of it for // now. In the future we may add a directory versioning scheme so // that the results of multiple runs can be retained. if (RunDirectory.Exists) { RunDirectory.Delete(true); } RunDirectory.Create(); } else { if (!RunDirectory.Exists) { throw new InvalidOperationException("No run directory exists - the ContinueExecution mode is only intended for finishing an incomplete run."); } } // TestRecords.RegisterKey(Environment.MachineName, RunDirectory); FilteringSettings filteringSettings = FilteringSettings; TestRecords tests = TestRecords.Discover(DiscoveryInfoPath, filteringSettings); tests.Filter(filteringSettings, DiscoveryInfoPath.Directory); tests.Distribute(RunDirectory, null, DiscoveryInfoPath.Directory); DirectoryInfo distributedExecutionDirectory = TestRecords.GetDistributedDirectory(Environment.MachineName, RunDirectory); tests = TestRecords.Load(distributedExecutionDirectory); ExecutionSettings settings = new ExecutionSettings(); settings.Tests = tests; settings.TestBinariesDirectory = DiscoveryInfoPath.Directory; settings.DebugTests = DebugTests; settings.DebugSti = DebugSti; settings.WaitForDebugger = WaitForDebugger; settings.LogFilesPath = distributedExecutionDirectory; settings.FixedTestExecutionDirectory = FixedTestExecutionDirectory; settings.JitDebuggerCommand = JitDebuggerCommand; settings.TimeoutMultiplier = TimeoutMultiplier; settings.ContinueExecution = ContinueExecution; settings.CodeCoverageEnabled = CodeCoverage; settings.CodeCoverageImport = CodeCoverageImport; settings.RerunFailures = RerunFailures; settings.SkipDxDiag = SkipDxDiag; CodeCoverageUtilities.ValidateForCodeCoverage(CodeCoverage, CodeCoverageImport); tests.Execute(settings); tests.Save(distributedExecutionDirectory); ExecutionBackupStore.ClearAllIntermediateTestResults(settings.LogFilesPath); TestRecords.Merge(RunDirectory, CodeCoverage, CodeCoverageImport); // RunCommand's report policy will be to publish reports to a // Report subdirectory of the RunDirectory. tests = TestRecords.Load(RunDirectory); string reportDirectoryPath = Path.Combine(RunDirectory.FullName, "Report"); RunInfo runInfo = RunInfo.FromOS(); runInfo.Save(RunDirectory); Console.WriteLine("Saving Report to: {0}\\LabReport.xml", reportDirectoryPath); tests.GenerateXmlReport(tests, runInfo, new DirectoryInfo(reportDirectoryPath), DiscoveryInfoPath.Directory); tests.DisplayConsoleSummary(); }
protected string LinkTempPath(string fileName) { return(RunDirectory.LinkTempPath(fileName)); }