private async Task exportProjectResults(FileInfo projectFile, DirectoryInfo originalDirectory, DirectoryInfo afterConversionDirectory, DirectoryInfo newDirectory, DirectoryInfo pkmlOldDirectory, DirectoryInfo pkmlNewDirectory) { int simulationCount = 0; var begin = DateTime.UtcNow; _logger.AddInSeparator($"Loading simulations in project file '{projectFile.FullName}'"); _workspacePersistor.LoadSession(_workspace, projectFile.FullName); var project = _workspace.Project; foreach (var simulation in project.All <IndividualSimulation>()) { try { var res = await exportSimulation(originalDirectory, afterConversionDirectory, newDirectory, pkmlOldDirectory, pkmlNewDirectory, simulation, project); if (res) { simulationCount++; } } catch (Exception e) { _logger.AddError(e.FullMessage()); _logger.AddError(e.FullStackTrace()); } } var end = DateTime.UtcNow; var timeSpent = end - begin; _workspace.CloseProject(); _logger.AddInfo($"{simulationCount} simulations exported from project '{projectFile.FullName}' in {timeSpent.ToDisplay()}"); }
public virtual async Task RunBatch() { if (_isRunning) { return; } _isRunning = true; _logPresenter.ClearLog(); _view.CalculateEnabled = false; try { await StartBatch(); } catch (Exception e) { _batchLogger.AddError(e.FullMessage()); } _isRunning = false; _view.CalculateEnabled = true; if (shouldClose) { Exit(); } }
private async Task exportSimulationTo(FileInfo simulationFile, string outputFolder, BatchExportMode batchExportMode) { _logger.AddInSeparator($"Starting batch simulation for file '{simulationFile}'"); try { var simForBatch = _simulationLoader.LoadSimulationFrom(simulationFile.FullName); var simText = simForBatch.NumberOfSimulations > 1 ? "simulations" : "simulation"; _logger.AddInfo($"{simForBatch.NumberOfSimulations} {simText} found in file '{simulationFile}'"); var simulation = simForBatch.Simulation; var defaultSimulationName = FileHelper.FileNameFromFileFullPath(simulationFile.FullName); var allParameters = _entitiesInContainerRetriever.ParametersFrom(simulation); await _simulationExporter.RunAndExport(simulation, outputFolder, defaultSimulationName, simForBatch.Configuration, batchExportMode); _allSimulationNames.Add(defaultSimulationName); foreach (var parameterValueSet in simForBatch.ParameterVariationSets) { string currentName = $"{defaultSimulationName}_{parameterValueSet.Name}"; var command = updateParameters(allParameters, parameterValueSet); await _simulationExporter.RunAndExport(simulation, outputFolder, currentName, simForBatch.Configuration, batchExportMode); _allSimulationNames.Add(currentName); _commandTask.ResetChanges(command, _executionContext); } //when simulation is not used anymore, unregister simulation _executionContext.Unregister(simulation); } catch (Exception e) { _logger.AddError($"{e.FullMessage()}\n{e.FullStackTrace()}"); } }
public Task RunBatch(dynamic parameters) { var inputFolder = parameters.inputFolder; return(Task.Run(() => { _logger.AddInfo($"Starting batch run: {DateTime.Now.ToIsoFormat(withSeconds: true)}"); var inputDirectory = new DirectoryInfo(inputFolder); if (!inputDirectory.Exists) { _logger.AddError($"Input folder '{inputFolder}' does not exist"); return; } var allSimulationFiles = inputDirectory.GetFiles(Constants.Filter.PKML_FILE_FILTER); if (allSimulationFiles.Length == 0) { _logger.AddError($"No Pkml file found in '{inputFolder}'"); return; } var begin = DateTime.UtcNow; foreach (var simulationFile in allSimulationFiles) { try { compute(simulationFile.FullName); } catch (Exception e) { _logger.AddError(e.FullMessage()); } } var end = DateTime.UtcNow; var timeSpent = end - begin; _logger.AddInfo($"{allSimulationFiles.Length} simulations computed in '{timeSpent.ToDisplay()}'"); _logger.AddInfo($"Batch run finished: {DateTime.Now.ToIsoFormat(withSeconds: true)}"); })); }