Exemple #1
0
        public void OpenProject(string fileFullPath)
        {
            try
            {
                //notify the action loading project
                _eventPublisher.PublishEvent(new ProjectLoadingEvent());

                //retrieve project from file
                _workspacePersistor.LoadSession(this, fileFullPath);

                if (_project == null)
                {
                    return;
                }

                updateProjectPropertiesFrom(fileFullPath);

                //notify event project loaded with the project
                _eventPublisher.PublishEvent(new ProjectLoadedEvent(_project));
            }
            catch (Exception)
            {
                //exception while opening the file
                ReleaseLock();
                throw;
            }
            finally
            {
                if (_project == null)
                {
                    ReleaseLock();
                }
            }
        }
Exemple #2
0
        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()}");
        }
Exemple #3
0
        public void OpenProject(string fileFullPath)
        {
            LoadProject(() =>
            {
                //retrieve project from file. This will load the project into the workbook itself
                _workspacePersistor.LoadSession(this, fileFullPath);

                if (Project == null)
                {
                    return;
                }

                updateProjectPropertiesFrom(fileFullPath);
            });
        }
        protected override Task Context()
        {
            _logger             = A.Fake <ILogger>();
            _workspacePersitor  = A.Fake <IWorkspacePersistor>();
            _workspace          = A.Fake <IWorkspace>();
            _simulationExporter = A.Fake <ISimulationExporter>();
            _lazyLoadTask       = A.Fake <ILazyLoadTask>();
            sut = new ExportSimulationRunner(_logger, _workspacePersitor, _workspace, _simulationExporter, _lazyLoadTask);

            _project     = new PKSimProject();
            _simulation1 = createSimulationWithResults(_simulation1Name);
            _simulation2 = createSimulationWithResults(_simulation2Name);

            A.CallTo(() => _workspacePersitor.LoadSession(_workspace, _projectFileName)).Invokes(x => { _workspace.Project = _project; });


            return(_completed);
        }
Exemple #5
0
        private async Task exportProject(ExportRunOptions runOptions)
        {
            var projectFile = runOptions.ProjectFile;

            if (!FileHelper.FileExists(projectFile))
            {
                throw new OSPSuiteException($"Project file '{projectFile}' does not exist.");
            }

            DirectoryHelper.CreateDirectory(runOptions.OutputFolder);

            _logger.AddInfo($"Starting project export for '{projectFile}'");

            _workspacePersistor.LoadSession(_workspace, projectFile);
            _logger.AddDebug($"Project loaded successfully from '{projectFile}'");

            await ExportSimulationsIn(_workspace.Project, runOptions);

            _logger.AddInfo($"Project export for '{projectFile}' terminated");
        }