public Task ExportPKAnalysesToCSVAsync(PopulationSimulation populationSimulation) { _buildingBlockTask.Load(populationSimulation); if (!populationSimulation.HasPKAnalyses) { throw new PKSimException(PKSimConstants.Error.CannotExportPKAnalysesPleaseRunSimulation(populationSimulation.Name)); } return(exportToFileAsync(PKSimConstants.UI.ExportPKAnalysesToCSVTitle, Constants.Filter.CSV_FILE_FILTER, CoreConstants.DefaultPKAnalysesExportNameFor(populationSimulation.Name), async fileName => { await ExportPKAnalysesToCSVAsync(populationSimulation, fileName); }, Constants.DirectoryKey.REPORT)); }
public void RenameSimulation(Simulation simulation, string newName) { _buildingBlockTask.Load(simulation); //rename model, all object path and results //was the presenter open for the simulation? if yes var presenterWasOpen = _applicationController.HasPresenterOpenedFor(simulation); _applicationController.Close(simulation); //Model and root string oldName = simulation.Name; simulation.Name = newName; simulation.Model.Name = simulation.Name; simulation.Model.Root.Name = simulation.Name; _renameAbsolutePathVisitor.RenameAllAbsolutePathIn(simulation, oldName); _buildingBlockInSimulationManager.UpdateBuildingBlockNamesUsedIn(simulation); _simulationPathUpdater.UpdatePathsForRenamedSimulation(simulation, oldName, newName); //presenter was not open, nothing to do if (!presenterWasOpen) { return; } //edit the simulation back, since it was edited _buildingBlockTask.Edit(simulation); }
public void Clone(Simulation simulationToClone) { if (_buildingBlockInSimulationManager.StatusFor(simulationToClone) != BuildingBlockStatus.Green) { throw new PKSimException(PKSimConstants.Error.SimulationCloneOnlyAvailableWhenBuildingBlocksAreUptodate); } _buildingBlockTask.Load(simulationToClone); using (var presenter = _applicationController.Start <ICloneSimulationPresenter>()) { var cloneCommand = presenter.CloneSimulation(simulationToClone); //User cancel action. return if (cloneCommand.IsEmpty()) { return; } var clone = presenter.Simulation; _simulationResultsTask.CloneResults(simulationToClone, clone); clone.Creation.AsCloneOf(simulationToClone); _simulationSettingsRetriever.SynchronizeSettingsIn(clone); var addCommand = new AddBuildingBlockToProjectCommand(clone, _executionContext).Run(_executionContext); addCommand.Description = PKSimConstants.Command.CloneEntity(PKSimConstants.ObjectTypes.Simulation, simulationToClone.Name, clone.Name); _buildingBlockTask.AddCommandToHistory(addCommand); //after clone => we go in edit mode _buildingBlockTask.Edit(clone); } }
public void Clone(Simulation simulationToClone) { if (_buildingBlockInProjectManager.StatusFor(simulationToClone) != BuildingBlockStatus.Green) { throw new PKSimException(PKSimConstants.Error.SimulationCloneOnlyAvailableWhenBuildingBlocksAreUptodate); } _buildingBlockTask.Load(simulationToClone); using (var presenter = _applicationController.Start <ICloneSimulationPresenter>()) { var cloneCommand = presenter.CloneSimulation(simulationToClone); //User cancel action. return if (cloneCommand.IsEmpty()) { return; } var clone = presenter.Simulation; _simulationResultsTask.CloneResults(simulationToClone, clone); // The simulation must be renamed after results are added to the simulation _renameBuildingBlockTask.RenameSimulation(clone, presenter.CloneName); clone.Creation.AsCloneOf(simulationToClone); _simulationSettingsRetriever.SynchronizeSettingsIn(clone); var addCommand = _buildingBlockTask.AddToProject(clone, editBuildingBlock: true, addToHistory: false); addCommand.Description = PKSimConstants.Command.CloneEntity(PKSimConstants.ObjectTypes.Simulation, simulationToClone.Name, clone.Name); _buildingBlockTask.AddCommandToHistory(addCommand); } }
private void configure(Simulation simulationToConfigure, Func <IConfigureSimulationPresenter, IPKSimCommand> configureAction) { _buildingBlockTask.Load(simulationToConfigure); using (var presenter = _applicationController.Start <IConfigureSimulationPresenter>()) { var activeSubject = _activeSubjectRetriever.Active <IPKSimBuildingBlock>(); var configureCommand = configureAction(presenter); //User cancel action. return if (configureCommand.IsEmpty()) { return; } //Before swapping simulation=>update results and charts information from the original simulation var simulation = presenter.Simulation; _simulationResultsTask.CopyResults(simulationToConfigure, simulation); _simulationSettingsRetriever.SynchronizeSettingsIn(simulation); //We have the same simulation=> we should update the id simulation.Id = simulationToConfigure.Id; _parameterIdUpdater.UpdateSimulationId(simulation); //was the presenter open for the simulation? if yes var presenterWasOpen = _applicationController.HasPresenterOpenedFor(simulationToConfigure); simulation.Creation.CreationMode = CreationMode.Configure; var swapSimulationCommand = new SwapSimulationCommand(simulationToConfigure, simulation, _executionContext).Run(_executionContext); swapSimulationCommand.ReplaceNameTemplateWithName(simulation.Name); swapSimulationCommand.ReplaceTypeTemplateWithType(PKSimConstants.ObjectTypes.Simulation); _buildingBlockTask.AddCommandToHistory(swapSimulationCommand); //no active presenter: nothing to do if (activeSubject == null) { return; } //presenter was not open, nothing to do if (!presenterWasOpen) { return; } //edit the simulation back, since it was edited _buildingBlockTask.Edit(simulation); //now, was the simulation the active presenter? if no, we need to active the other presenter if (activeSubject != simulationToConfigure) { _buildingBlockTask.Edit(activeSubject); } } }
protected override void PerformExecute() { var fileName = _dialogCreator.AskForFileToSave(PKSimConstants.UI.SaveSimulationParameterToCsvFile, Constants.Filter.CSV_FILE_FILTER, Subject.Name); if (string.IsNullOrEmpty(fileName)) { return; } _buildingBlockTask.Load(Subject); _parametersReportCreator.ExportParametersTo(Subject.Model, fileName); }
public void Load(ISimulationSubject buildingBlockToLoad) { _buildingBlockTask.Load(buildingBlockToLoad); }