public void SaveSession(ICoreWorkspace workspace, string fileFullPath)
        {
            using (var progress = _progressManager.Create())
            {
                progress.Initialize(5);

                progress.IncrementProgress(PKSimConstants.UI.CreatingProjectDatabase);

                _sessionManager.CreateFactoryFor(fileFullPath);

                using (var session = _sessionManager.OpenSession())
                    using (var transaction = session.BeginTransaction())
                    {
                        progress.IncrementProgress(PKSimConstants.UI.SavingProject);
                        workspace.UpdateJournalPathRelativeTo(fileFullPath);
                        _projectPersistor.Save(workspace.Project, session);

                        progress.IncrementProgress(PKSimConstants.UI.SavingHistory);
                        _historyManagerPersistor.Save(workspace.HistoryManager, session);

                        progress.IncrementProgress(PKSimConstants.UI.SavingLayout);
                        if (workspace is IWithWorkspaceLayout withWorkspaceLayout)
                        {
                            _workspaceLayoutPersistor.Save(withWorkspaceLayout.WorkspaceLayout, session);
                        }

                        transaction.Commit();
                    }

                progress.IncrementProgress(PKSimConstants.UI.CompressionProject);
                _projectFileCompressor.Compress(fileFullPath);

                //once saved, we can
                _projectPersistor.UpdateProjectAfterSave(workspace.Project);
            }


            workspace.Project.Name = FileHelper.FileNameFromFileFullPath(fileFullPath);
        }
Exemple #2
0
        public void Save(IMoBiContext context)
        {
            var project = context.CurrentProject;

            _sessionManager.CreateFactoryFor(project.FilePath);

            using (var session = _sessionManager.OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    context.UpdateJournalPathRelativeTo(project.FilePath);
                    _projectPersistor.Save(project, context);
                    _historyManagerPersistor.Save(context.HistoryManager, _sessionManager.CurrentSession);
                    transaction.Commit();
                }

            // after save was successfull, compress file
            _projectFileCompressor.Compress(project.FilePath);
            project.Name              = FileHelper.FileNameFromFileFullPath(project.FilePath);
            project.HasChanged        = false;
            context.ProjectIsReadOnly = false;
            GC.Collect();
        }