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); } }
protected override void UpdateSimulationProperties() { var oldName = Simulation.Name; try { Simulation.Name = _simulationPropertiesDTO.Name; base.UpdateSimulationProperties(); } finally { //reset name to ensure that rename simulation will work Simulation.Name = oldName; } //here we need to rename the full simulation in order to have a consistent naming throughout the model _renameBuildingBlockTask.RenameSimulation(Simulation, _simulationPropertiesDTO.Name); }