Esempio n. 1
0
        public async Task CommitAsync()
        {
            try
            {
                // commit transaction if there is one active
                if (_transaction != null && _transaction.IsActive)
                {
                    _session.Flush();
                    _session.Clear();
                }

                if (_transaction != null)
                {
                    await _transaction.CommitAsync();
                }
            }
            catch
            {
                // rollback if there was an exception
                if (_transaction != null && _transaction.IsActive)
                {
                    await _transaction.RollbackAsync();
                }
                throw;
            }
            finally
            {
                CloseSession();
            }
        }
Esempio n. 2
0
        public void ApplyQonverterSettings(IDictionary<Analysis, QonverterSettings> qonverterSettings)
        {
            clearData();
            setControlsWhenDatabaseLocked(true);

            var workerThread = new BackgroundWorker()
            {
                WorkerReportsProgress = true,
                WorkerSupportsCancellation = true
            };

            workerThread.DoWork += (s, e) =>
            {
                var qonverter = new Qonverter();
                qonverter.QonversionProgress += progressMonitor.UpdateProgress;
                foreach (var item in qonverterSettings)
                    qonverter.SettingsByAnalysis[(int) item.Key.Id] = item.Value.ToQonverterSettings();

                //qonverter.LogQonversionDetails = true;
                qonverter.Reset(Text);
                qonverter.Qonvert(Text);
            };

            workerThread.RunWorkerCompleted += (s, e) =>
            {
                if (e.Result is Exception)
                {
                    Program.HandleException(e.Result as Exception);
                    setControlsWhenDatabaseLocked(false);
                    return;
                }

                lock (session)
                {
                    var sessionFactory = DataModel.SessionFactoryFactory.CreateSessionFactory(Text, new SessionFactoryConfig { WriteSqlToConsoleOut = true });
                    session = sessionFactory.OpenSession();
                    //session.CreateSQLQuery("PRAGMA temp_store=MEMORY").ExecuteUpdate();
                    _layoutManager.SetSession(session);

                    // delete old filters since they are not valid with different qonverter settings
                    session.CreateSQLQuery("DELETE FROM FilterHistory").ExecuteUpdate();
                    session.Clear();

                    if (basicFilter == null)
                        basicFilter = new DataFilter()
                        {
                            MaximumQValue = 0.02,
                            MinimumDistinctPeptides = 2,
                            MinimumSpectra = 2,
                            MinimumAdditionalPeptides = 1,
                            GeneLevelFiltering = false,
                            DistinctMatchFormat = new DistinctMatchFormat
                            {
                                IsChargeDistinct = true,
                                IsAnalysisDistinct = false,
                                AreModificationsDistinct = true,
                                ModificationMassRoundToNearest = 1.0m
                            }
                        };

                    basicFilterControl.DataFilter = basicFilter;

                    viewFilter = basicFilter;

                    session.Close();
                    sessionFactory.Close();
                }

                progressMonitor = new ProgressMonitor();
                progressMonitor.ProgressUpdate += progressMonitor_ProgressUpdate;
                basicFilterControl = new BasicFilterControl();
                basicFilterControl.BasicFilterChanged += basicFilterControl_BasicFilterChanged;
                basicFilterControl.ShowQonverterSettings += ShowQonverterSettings;
                dataFilterPopup = new Popup(basicFilterControl) { FocusOnOpen = true };
                dataFilterPopup.Closed += dataFilterPopup_Closed;
                new Thread(() => OpenFiles(new List<string> { Text }, null)).Start();
            };

            workerThread.RunWorkerAsync();
        }