예제 #1
0
파일: Workspace.cs 프로젝트: zrolfs/pwiz
 public void SetTaskScheduler(TaskScheduler taskScheduler)
 {
     _taskScheduler = taskScheduler;
     if (_taskScheduler != null)
     {
         if (SessionFactory == null)
         {
             OpenSessionFactory();
         }
         _databasePoller = _databasePoller ?? new DatabasePoller(this);
         _databasePoller.Start();
         _resultCalculator = _resultCalculator ?? new ResultCalculator(this);
         _resultCalculator.Start();
         _chromatogramGenerator = _chromatogramGenerator ?? new ChromatogramGenerator(this);
         _chromatogramGenerator.Start();
     }
     else
     {
         if (null != _chromatogramGenerator)
         {
             _chromatogramGenerator.Stop();
         }
         if (null != _resultCalculator)
         {
             _resultCalculator.Stop();
         }
         if (null != _databasePoller)
         {
             _databasePoller.Stop();
         }
         CloseSessionFactory();
     }
 }
예제 #2
0
파일: Workspace.cs 프로젝트: zrolfs/pwiz
        public void Save(LongOperationBroker longOperationBroker)
        {
            longOperationBroker.UpdateStatusMessage("Synchronizing with database changes");
            int reconcileAttempt = 1;

            while (true)
            {
                var dirtyPeptideAnalyses = PeptideAnalyses.ListDirty()
                                           .ToDictionary(pa => pa.Id, pa => pa.ChromatogramsWereLoaded);
                if (DatabasePoller.TryLoadAndMergeChanges(dirtyPeptideAnalyses))
                {
                    break;
                }
                reconcileAttempt++;
                longOperationBroker.UpdateStatusMessage("Synchronizing with database changes attempt #" + reconcileAttempt);
            }
            using (var session = OpenWriteSession())
            {
                session.BeginTransaction();
                UpdateWorkspaceVersion(longOperationBroker, session, SavedWorkspaceChange);
                bool workspaceChanged = false;
                var  dbWorkspace      = LoadDbWorkspace(session);
                longOperationBroker.UpdateStatusMessage("Saving tracer definitions");
                workspaceChanged = TracerDefs.Save(session, dbWorkspace) || workspaceChanged;
                longOperationBroker.UpdateStatusMessage("Saving modifications");
                workspaceChanged = Modifications.Save(session, dbWorkspace) || workspaceChanged;
                longOperationBroker.UpdateStatusMessage("Saving settings");
                workspaceChanged = Settings.Save(session, dbWorkspace) || workspaceChanged;
                longOperationBroker.UpdateStatusMessage("Saving data files");
                foreach (var msDataFile in MsDataFiles.ListDirty())
                {
                    msDataFile.Save(session);
                }
                longOperationBroker.UpdateStatusMessage("Saving peptides");
                foreach (var peptide in Peptides.ListDirty())
                {
                    peptide.Save(session);
                }
                longOperationBroker.UpdateStatusMessage("Saving peptide analyses");
                foreach (var peptideAnalysis in PeptideAnalyses.ListDirty())
                {
                    if (longOperationBroker.WasCancelled)
                    {
                        return;
                    }
                    peptideAnalysis.Save(session);
                }
                if (workspaceChanged)
                {
                    session.Save(new DbChangeLog(this));
                }
                longOperationBroker.SetIsCancelleable(false);
                session.Transaction.Commit();
            }
        }
        private void frmTestForm_Load(object sender, EventArgs e)
        {
            DbMessenger messenger = DbMessenger.SingleOrDefault(m => m.Name.ToLower() == "messagingtoolkit".ToLower());

            if (messenger != null)
            {
                DatabasePoller poller = new DatabasePoller(messenger, null);
                poller.Name = messenger.Name;
                Thread worker = new Thread(new ThreadStart(poller.StartTimer));
                worker.IsBackground = true;
                worker.Name         = messenger.Name;
                worker.Start();
            }
        }
예제 #4
0
파일: Workspace.cs 프로젝트: zrolfs/pwiz
 public void Dispose()
 {
     if (null != _chromatogramGenerator)
     {
         _chromatogramGenerator.Dispose();
         _chromatogramGenerator = null;
     }
     if (null != _databasePoller)
     {
         _databasePoller.Dispose();
         _databasePoller = null;
     }
     if (null != _resultCalculator)
     {
         _resultCalculator.Dispose();
         _resultCalculator = null;
     }
 }