private async Task runAndExportSimulationsInSnapshotFile(FileInfo projectFile, string outputFolder, SimulationExportMode simulationExportMode) { _logger.AddInfo($"Starting batch simulation export for file '{projectFile}'"); try { var project = await _snapshotTask.LoadProjectFromSnapshotFileAsync(projectFile.FullName); var simulations = project.All <Simulation>(); var numberOfSimulations = simulations.Count; _logger.AddInfo($"{numberOfSimulations} {"simulation".PluralizeIf(numberOfSimulations)} found in file '{projectFile}'", project.Name); var simulationExportOptions = new SimulationExportOptions { OutputFolder = outputFolder, ExportMode = simulationExportMode, ProjectName = project.Name, PrependProjectName = true }; foreach (var simulation in simulations) { _logger.AddDebug($"Starting batch simulation export for simulation '{simulation.Name}'", project.Name); await _simulationExporter.RunAndExport(simulation, _simulationRunOptions, simulationExportOptions); _allSimulationNames.Add(simulation.Name); } } catch (Exception e) { _logger.AddException(e); } }
public async Task <SimulationExport> ExportSimulation(Simulation simulation, ExportRunOptions exportRunOptions, PKSimProject project) { var projectName = project.Name; var simulationName = simulation.Name; var simulationFolder = Path.Combine(exportRunOptions.OutputFolder, FileHelper.RemoveIllegalCharactersFrom(simulationName)); DirectoryHelper.CreateDirectory(simulationFolder); var simulationExport = new SimulationExport { Project = projectName, SimulationFolder = simulationFolder, Simulation = simulationName }; var simulationRunOptions = new SimulationRunOptions(); _lazyLoadTask.Load(simulation); _lazyLoadTask.LoadResults(simulation); var simulationExportOptions = new SimulationExportOptions { OutputFolder = simulationFolder, ExportMode = exportRunOptions.ExportMode, ProjectName = projectName, }; if (!simulation.OutputSelections.HasSelection) { _logger.AddWarning($"Simulation '{simulationName}' does not have any selected output and will not be exported", projectName); return(simulationExport); } if (exportRunOptions.RunSimulation) { await _simulationExporter.RunAndExport(simulation, simulationRunOptions, simulationExportOptions); } else if (simulation.HasResults) { await _simulationExporter.Export(simulation, simulationExportOptions); } else { _logger.AddWarning($"Simulation '{simulationName}' does not have any results and will not be exported", projectName); return(simulationExport); } _logger.AddDebug($"Simulation '{simulationName}' exported to '{simulationFolder}'", projectName); return(simulationExport); }
public async Task <SimulationMapping> ExportSimulation(Simulation simulation, ExportRunOptions exportRunOptions, PKSimProject project) { var projectName = project.Name; var simulationName = simulation.Name; var simulationFile = FileHelper.RemoveIllegalCharactersFrom(simulationName); var simulationFolder = Path.Combine(exportRunOptions.OutputFolder, simulationFile); DirectoryHelper.CreateDirectory(simulationFolder); var simulationExport = new SimulationMapping { Project = projectName, Path = simulationFolder, Simulation = simulationName, SimulationFile = simulationFile }; var simulationRunOptions = new SimulationRunOptions(); _lazyLoadTask.Load(simulation); _lazyLoadTask.LoadResults(simulation); var simulationExportOptions = new SimulationExportOptions { OutputFolder = simulationFolder, ExportMode = exportRunOptions.ExportMode, ProjectName = projectName, }; if (exportRunOptions.RunSimulation) { await _simulationExporter.RunAndExport(simulation, simulationRunOptions, simulationExportOptions); } else { await _simulationExporter.Export(simulation, simulationExportOptions); } _logger.AddDebug($"Simulation '{simulationName}' exported to '{simulationFolder}'", projectName); return(simulationExport); }