Пример #1
0
        public ActionResult SnimiFakturu([FromQuery] int nalogid, [FromBody] Finansije obj)
        {
            try
            {
                var nalog = _session.Get <RadniNalog>(nalogid);
                obj.RadniNalog = nalog;
                obj.Rbr        = Helper.RedniBroj(_session, "finansije" + obj.Vrsta.ToLower(), obj.Datum);
                var kn = Tuv.Helper.Helper.GetIso8601WeekOfYear(obj.Datum);

                //obj.Kn = kn;
                var kurs = _session.QueryOver <KursnaLista>()
                           .Where(x => x.Godina == obj.Datum.Year)
                           .And(x => x.Nedelja == kn)
                           .SingleOrDefault <KursnaLista>()
                           .Kurs;
                obj.Kurs = kurs;
                _session.SaveOrUpdate(obj);
                _session.Flush();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Json(new { Success = false, Message = ex.Message, Obj = obj }));
            }
            return(Json(new { Success = true, Message = "", Obj = obj }));
        }
Пример #2
0
        public ActionResult AddFunds()
        {
            User     user  = _session.Get <User>(_context.UserId);
            AddFunds funds = Mapper.Map <AddFunds>(user);

            return(View(funds));
        }
Пример #3
0
 public OnepNetwork Get(long id)
 {
     using (var tx = _session.BeginTransaction())
     {
         var onepNetwork = _session.Get <OnepNetwork>(id);
         tx.Commit();
         Debug.WriteLine(ReferenceEquals(onepNetwork.OnepTerminationpoints[0].OnepAmpRole, onepNetwork.OnepAmptps[0]));
         Debug.WriteLine($"{onepNetwork.OnepTerminationpoints[0].Id}, {onepNetwork.OnepAmptps[0].Id}");
         return(null);
     }
 }
Пример #4
0
 public T RetornarPorId(int Id)
 {
     using (NHibernate.ISession session = SessionFactory.AbrirSession())
     {
         return(session.Get <T>(Id));
     }
 }
Пример #5
0
 public static T Find <T>(int id)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         return(session.Get <T>(id));
     }
 }
        public ActionResult Edit(int id, Tarefa tarefa)
        {
            try
            {
                // TODO: Add update logic here
                using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
                {
                    var tarefaAlterado = session.Get <Tarefa>(id);
                    tarefaAlterado.Id            = tarefa.Id;
                    tarefaAlterado.Titulo        = tarefa.Titulo;
                    tarefaAlterado.Descricao     = tarefa.Descricao;
                    tarefaAlterado.Data_Cadastro = tarefa.Data_Cadastro;
                    tarefaAlterado.Data_Entrega  = tarefa.Data_Entrega;
                    using (ITransaction transacao = session.BeginTransaction())
                    {
                        session.Save(tarefaAlterado);
                        transacao.Commit();
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Пример #7
0
        public ActionResult Edit(int id, Cat cat)
        {
            try
            {
                using (NHibernate.ISession session = _sessionFactory.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        var catUpdate = session.Get <Cat>(id);

                        if (catUpdate != null && ModelState.IsValid)
                        {
                            catUpdate.Name = cat.Name;
                            catUpdate.Sex  = cat.Sex;
                            cat.Weight     = cat.Weight;
                            session.Merge <Cat>(cat);
                            transaction.Commit();
                        }
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(View(ex));
            }
        }
Пример #8
0
 public ActionResult Statystyki(int StatystykiMeczuID)
 {
     using (NHibernate.ISession session = NHIbernateSession.OpenSession())
     {
         var statystyki = session.Get <StatystykiMeczu>(StatystykiMeczuID);
         return(View(statystyki));
     }
 }
Пример #9
0
 // GET: Zawodnik/Delete/5
 public ActionResult Delete(int ZawodnikID)
 {
     using (NHibernate.ISession session = NHIbernateSession.OpenSession())
     {
         var zawodnik = session.Get <Zawodnik>(ZawodnikID);
         return(View(zawodnik));
     }
 }
 // GET: Tarefa/Edit/5
 public ActionResult Edit(int id)
 {
     using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
     {
         var tarefa = session.Get <Tarefa>(id);
         return(View(tarefa));
     }
 }
 //Get CheckList/Delete/5
 public ActionResult Delete(int id)
 {
     using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
     {
         var checklist = session.Get <Checklist>(id);
         return(View(checklist));
     }
 }
 //Get CheckList/Edit/5
 public ActionResult Edit(int id)
 {
     using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
     {
         var anexo = session.Get<Anexos>(id);
         return View(anexo);
     }
 }
Пример #13
0
 // GET: CatController/Edit/5
 public ActionResult Edit(int id)
 {
     using (NHibernate.ISession session = _sessionFactory.OpenSession())
     {
         var cat = session.Get <Cat>(id);
         return(View(cat));
     }
 }
Пример #14
0
 public ActionResult DetailsSklad(int SkladID)
 {
     using (NHibernate.ISession session = NHIbernateSession.OpenSession())
     {
         var objEmployee = session.Get <Druzyna>(SkladID);
         return(View(objEmployee));
     }
 }
Пример #15
0
 // GET: Druzyna/Details/5
 public ActionResult DetailsStatystyki(int StatystykiDruzynyID)
 {
     using (NHibernate.ISession session = NHIbernateSession.OpenSession())
     {
         var statystyki = session.Get <StatystykiDruzyny>(StatystykiDruzynyID);
         return(View(statystyki));
     }
 }
Пример #16
0
        public ActionResult Delete(int MeczID)
        {
            using (NHibernate.ISession session = NHIbernateSession.OpenSession())
            {
                var mecz = session.Get <Mecz>(MeczID);

                return(View(mecz));
            }
        }
Пример #17
0
        public ActionResult Get(int id)
        {
            //this.repo.find("Dokument?entitet=" + entitet + "&entitetopis=" + entitetoipis + "&entitetid" + entitet)
            try
            {
                var dokument = _session.Get <Zapis>(id);

                var ms = new MemoryStream(dokument.Data);
                ms.Seek(0, SeekOrigin.Begin);
                return(File(ms, "application/octet-stream", dokument.FileName)); // returns a FileStreamResult
            }

            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Json(new { Success = false, Message = ex.Message }));
            }
        }
Пример #18
0
        public ActionResult EditSklad(int SkladID)
        {
            using (NHibernate.ISession session = NHIbernateSession.OpenSession())
            {
                var druzyna = session.Get <SkladZawodnik>(SkladID);

                return(View(druzyna));
            }
        }
Пример #19
0
        public IActionResult Get(int id)
        {
            using (NHibernate.ISession session = NHibernateHelper.OpenSession())
            {
                var todo = session.Get <Todo>(id);

                return(Ok(todo));
            }
        }
Пример #20
0
        // GET: Druzyna/Delete/5
        public ActionResult Delete(int DruzynaID)
        {
            using (NHibernate.ISession session = NHIbernateSession.OpenSession())
            {
                var druzyna = session.Get <Druzyna>(DruzynaID);

                return(View(druzyna));
            }
        }
        public void CanAddCustomer()
        {
            var customer = new Customer {
                Firstname = "Steve", Lastname = "Bohlen"
            };
            var newIdentity = _session.Save(customer);


            var testCustomer = _session.Get <Customer>(newIdentity);

            Assert.NotNull(testCustomer);
        }
Пример #22
0
 public IActionResult Delete(int id)
 {
     try {
         using (NHibernate.ISession session = NHibernateHelper.OpenSession())
         {
             var todo = session.Get <Todo>(id);
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Delete(todo);
                 transaction.Commit();
                 return(Ok());
             }
         }
     } catch {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Erro ao acessar o banco"));
     }
 }
Пример #23
0
        public async Task <IActionResult> Login(Login login)
        {
            if (!ModelState.IsValid)
            {
                return(View(login));
            }

            User maybeUser = _session.Query <User>()
                             .Where(u => u.Username == login.Username)
                             .SingleOrDefault();

            if (maybeUser == null)
            {
                ModelState.AddModelError(string.Empty, "Invalid Username");
                login.Username = string.Empty;
                login.Password = string.Empty;
                return(View(login));
            }

            if (maybeUser.Password != login.Password)
            {
                ModelState.AddModelError(string.Empty, "Invalid Password");
                login.Password = string.Empty;
                return(View(login));
            }

            var user = _session.Get <User>(maybeUser.Id);

            var userInformations = new List <UserInfo>
            {
                new UserNameInfo(user.Username),
                new UserIdInfo(user.Id),
                new UserTypeInfo(user.IsAdmin),
            };

            await _authManager.SignInAsync(userInformations, new Infrastructure.Authentication.CookieOptions()
            {
                AllowRefresh       = true,
                ExpirationDateTime = DateTime.Now.AddHours(1),
                IsPersistent       = false
            });


            return(RedirectToAction("Index", "Games"));
        }
Пример #24
0
        public ActorUpdateResponse Update(ActorUpdateRequest request)
        {
            var response  = new ActorUpdateResponse();
            var repoActor = _session.Get <en.Actor>(request.Id);

            repoActor.FirstName  = request.FirstName;
            repoActor.LastName   = request.LastName;
            repoActor.LastUpdate = DateTime.UtcNow;

            try
            {
                _actorRepository.Update(repoActor);
                response.CompletedAt = DateTime.UtcNow;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = $"Could not update Actor {ex.Message}";
            }

            return(response);
        }
Пример #25
0
        public IActionResult Put(int id, Todo todo)
        {
            try {
                using (NHibernate.ISession session = NHibernateHelper.OpenSession())
                {
                    var todoAlterado = session.Get <Todo>(id);

                    todoAlterado.Name       = todo.Name;
                    todoAlterado.isComplete = todo.isComplete;

                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(todoAlterado);
                        transaction.Commit();

                        return(Ok());
                    }
                }
            } catch {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Erro ao acessar banco de dados"));
            }
        }
Пример #26
0
        public ActionResult Delete(long id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                using (ISession session = _nHibernateSession.OpenSession())
                {
                    Expense expense = session.Get <Expense>(id);

                    using (ITransaction trans = session.BeginTransaction())
                    {
                        session.Delete(expense);
                        trans.Commit();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
Пример #27
0
        public ActionResult Delete(int MeczID, Mecz mecz)
        {
            int StatystykiMeczuID = MeczID;

            try
            {
                using (NHibernate.ISession session = NHIbernateSession.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        session.Delete(mecz);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception exception)
            {
                return(View());
            }

            try
            {
                using (NHibernate.ISession session = NHIbernateSession.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        var statystyki = session.Get <StatystykiMeczu>(StatystykiMeczuID);
                        session.Delete(statystyki);
                        transaction.Commit();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                return(View());
            }
        }
 public ActionResult Edit(int id, Checklist checklist)
 {
     try
     {
         using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
         {
             var checklistAlterado = session.Get <Checklist>(id);
             checklistAlterado.Id        = checklist.Id;
             checklistAlterado.CheckList = checklist.CheckList;
             checklistAlterado._Tarefa   = checklist._Tarefa;
             using (ITransaction transacao = session.BeginTransaction())
             {
                 session.Save(checklistAlterado);
                 transacao.Commit();
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, Anexos anexo)
 {
     try
     {
         using (NHibernate.ISession session = NHibernateHelper.AbreSessao())
         {
             var anexoAlterado = session.Get<Anexos>(id);
             anexoAlterado.Id = anexo.Id;
             anexoAlterado.Caminho_Arquivo = anexo.Caminho_Arquivo;
             anexoAlterado._Tarefa = anexo._Tarefa;
             using (ITransaction transacao = session.BeginTransaction())
             {
                 session.Save(anexoAlterado);
                 transacao.Commit();
             }
         }
         return RedirectToAction(nameof(Index));
     }
     catch
     {
         return View();
     }
 }
Пример #30
0
        public ActionResult Delete(int ZawodnikID, Zawodnik zawodnik)
        {
            int StatystykiZawodnikaID = ZawodnikID;

            try
            {
                using (NHibernate.ISession session = NHIbernateSession.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        session.Delete(zawodnik);
                        transaction.Commit();
                    }
                }
            }
            catch (Exception exception)
            {
                return(View());
            }
            try
            {
                using (NHibernate.ISession session = NHIbernateSession.OpenSession())
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        var statystyki = session.Get <StatystykiZawodnika>(StatystykiZawodnikaID);
                        session.Delete(statystyki);
                        transaction.Commit();
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                return(View());
            }
        }
Пример #31
0
        void OpenFiles (IList<string> filepaths, TreeNode rootNode = null)
        {
            try
            {
                var xml_filepaths = filepaths.Where(filepath => !filepath.EndsWith(".idpDB"));
                var idpDB_filepaths = filepaths.Where(filepath => filepath.EndsWith(".idpDB"));
                bool openSingleFile = xml_filepaths.Count() + idpDB_filepaths.Count() == 1;

                if (xml_filepaths.Count() + idpDB_filepaths.Count() == 0)
                {
                    if (Program.IsHeadless)
                    {
                        Console.Error.WriteLine("Headless mode must be passed some idpDB files to merge.");
                        Close();
                        return;
                    }
                    else
                        throw new Exception("no filepaths to open");
                }

                if (Program.IsHeadless && xml_filepaths.Any())
                    Program.HandleUserError(new Exception("headless mode only supports merging and filtering idpDB files"));

                // warn if idpDBs already exist
                bool warnOnce = false, skipReconvert = false;
                var skipFiles = new List<string>();
                foreach (string filepath in xml_filepaths)
                {
                    string idpDB_filepath = Path.ChangeExtension(filepath.Replace(".pep.xml", ".pepXML"), ".idpDB");
                    if (File.Exists(idpDB_filepath))
                    {
                        if (!warnOnce && MessageBox.Show("Some of these files have already been converted. Do you want to reconvert them?",
                                                         "Result already converted",
                                                         MessageBoxButtons.YesNo,
                                                         MessageBoxIcon.Exclamation,
                                                         MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                            skipReconvert = true;
                        warnOnce = true;
                        if (skipReconvert)
                            skipFiles.Add(filepath);
                        else
                            File.Delete(idpDB_filepath);
                    }
                }
                xml_filepaths = xml_filepaths.Where(o => !skipFiles.Contains(o));
                idpDB_filepaths = idpDB_filepaths.Union(skipFiles.Select(o => Path.ChangeExtension(o.Replace(".pep.xml", ".pepXML"), ".idpDB")));


                // determine if merged filepath exists and that it's a valid idpDB
                var potentialPaths = filepaths.Select(item =>
                                                      Path.Combine(Path.GetDirectoryName(item) ?? string.Empty,
                                                                   Path.GetFileNameWithoutExtension(item) ??

                                                                   string.Empty) + ".idpDB").ToList();

                // for Mascot files (*.dat), use parseSource() to get the real filename, else save time by just using filename without extension
                var sourceNames = filepaths.Select(o => Path.Combine(Path.GetDirectoryName(o), o.ToLower().EndsWith(".dat") ? Parser.ParseSource(o) : Path.GetFileNameWithoutExtension(o.Replace(".pep.xml", ".pepXML")) + Path.GetExtension(o)));

                string commonFilepath = Util.GetCommonFilename(sourceNames);
                if (!openSingleFile && potentialPaths.Contains(commonFilepath))
                    commonFilepath = commonFilepath.Replace(".idpDB", " (merged).idpDB");
                string mergeTargetFilepath = defaultMergedOutputFilepath ?? commonFilepath;
                if (!openSingleFile && File.Exists(mergeTargetFilepath) && Program.IsHeadless)
                    File.Delete(mergeTargetFilepath);
                else
                {
                    // check that the single idpDB is writable; if not, it needs to be copied
                    if (openSingleFile)
                    {
                        // sanity check that file exists after the path manipulation above
                        if (idpDB_filepaths.Count() == 1 && !File.Exists(mergeTargetFilepath))
                            throw new Exception(String.Format("error in internal path manipulation for opening single idpDB: {0} transformed to {1} which does not exist", sourceNames.First(), mergeTargetFilepath));

                        string oldFilename = mergeTargetFilepath;

                        while (true)
                        {
                            if (canReadWriteInDirectory(Path.GetDirectoryName(mergeTargetFilepath)))
                                break;

                            MessageBox.Show("IDPicker files cannot be opened from a read-only location, pick a writable path to copy it to.");

                            if (!saveFileDialog(ref mergeTargetFilepath))
                                return;
                        }

                        // if location was changed, copy to the new location
                        if (oldFilename != mergeTargetFilepath)
                        {
                            toolStripStatusLabel.Text = "Copying idpDB...";
                            File.Copy(oldFilename, mergeTargetFilepath, true);
                        }
                    }
                    else
                    {
                        // if not headless and MergedOutputFilepath is unset,
                        // then give the user a chance to override the merge target location
                        if (!Program.IsHeadless &&
                            defaultMergedOutputFilepath == null &&
                            !saveFileDialog(ref mergeTargetFilepath, "Choose where to create the merged idpDB"))
                            return;

                        while (true)
                        {
                            if (!canReadWriteInDirectory(Path.GetDirectoryName(mergeTargetFilepath)))
                            {
                                MessageBox.Show("IDPicker files cannot be merged to a read-only location, pick a writable path.");

                                if (Program.IsHeadless || !saveFileDialog(ref mergeTargetFilepath, "Pick a writable path in which to create the merged idpDB"))
                                    return;

                                continue;
                            }

                            // the SaveFileDialog already asked the user to confirm overwriting an existing file
                            if (File.Exists(mergeTargetFilepath))
                                File.Delete(mergeTargetFilepath);

                            break;
                        }
                    }
                }

                // set main window title
                BeginInvoke(new MethodInvoker(() => Text = mergeTargetFilepath));

                //set up delayed messages so non-fatal errors that occur at the end arent lost
                var delayedMessages = new List<string[]>();
                if (xml_filepaths.Count() > 0)
                {
                    importCancelled = false;

                    // loop until the import settings don't result in any fatal errors, or user cancels
                    while (!importCancelled)
                    {
                        Parser parser = new Parser();
                        Invoke(new MethodInvoker(() => parser.ImportSettings += importSettingsHandler));

                        var ilr = new IterationListenerRegistry();

                        var progressForm = new ProgressForm(xml_filepaths, ilr)
                        {
                            Text = "Import Progress",
                            StartPosition = FormStartPosition.CenterParent,
                        };

                        Invoke(new MethodInvoker(() => progressForm.Show(this)));

                        try
                        {
                            parser.Parse(xml_filepaths, ilr);

                            // read log for non-fatal errors
                            //string log = Logger.Reader.ReadToEnd().Trim();
                            //if (log.Length > 0)
                            //    Invoke(new MethodInvoker(() => UserDialog.Show(this, "Log Messages", new TextBox {Multiline = true, Text = log.Replace("\n", "\r\n"), ReadOnly = true, Size = new Size(800, 600),  ScrollBars = ScrollBars.Both}, MessageBoxButtons.OK)));

                            break; // no fatal errors, break the loop
                        }
                        catch (Exception ex)
                        {
                            if (ex.Message.Contains("no peptides found mapping to a decoy protein") ||
                                ex.Message.Contains("peptides did not map to the database") ||
                                ex.Message.Contains("duplicate protein id"))
                                Program.HandleUserError(ex);
                            else
                                throw;
                        }
                        finally
                        {
                            importCancelled |= progressForm.Cancelled;
                            Invoke(new MethodInvoker(() => progressForm.Close()));
                        }
                    }

                    if (importCancelled)
                        return;

                    idpDB_filepaths = idpDB_filepaths.Union(xml_filepaths.Select(o => Path.ChangeExtension(o.Replace(".pep.xml", ".pepXML"), ".idpDB")));
                }

                if (idpDB_filepaths.Count() > 1)
                {
                    var merger = new MergerWrapper(mergeTargetFilepath, idpDB_filepaths);
                    toolStripStatusLabel.Text = "Merging results...";
                    merger.MergingProgress += progressMonitor.UpdateProgress;
                    merger.Start();

                    idpDB_filepaths = new List<string>() {mergeTargetFilepath};
                }

                // HACK: this needs to be handled more gracefully
                if (!IsHandleCreated)
                    return;

                if (Properties.GUI.Settings.Default.WarnAboutNonFixedDrive && !Util.IsPathOnFixedDrive(mergeTargetFilepath))
                {
                    string oldFilename = mergeTargetFilepath;
                    bool copyLocal = true;
                    Invoke(new MethodInvoker(() =>
                                                 {
                                                     var form = new NonFixedDriveWarningForm();
                                                     if (form.ShowDialog(this) == DialogResult.Ignore)
                                                         copyLocal = false;
                                                 }));

                    if (copyLocal)
                    {
                        string newFilename = Path.GetFileName(mergeTargetFilepath);
                        if (!saveFileDialog(ref newFilename, "Pick a local path to copy the idpDB to"))
                            return;

                        toolStripStatusLabel.Text = "Copying idpDB...";
                        File.Copy(oldFilename, newFilename, true);
                        mergeTargetFilepath = newFilename;

                        // set main window title
                        BeginInvoke(new MethodInvoker(() => Text = mergeTargetFilepath));
                    }
                }

                if (!IsHandleCreated)
                    return;

                Util.PrecacheFile(mergeTargetFilepath, progressMonitor.UpdateProgress);

                if (!IsHandleCreated)
                    return;

                BeginInvoke(new MethodInvoker(() =>
                {
                    clearProgress();
                    toolStripStatusLabel.Text = "Upgrading schema and creating session factory...";
                    statusStrip.Refresh();
                }));

                var sessionFactory = DataModel.SessionFactoryFactory.CreateSessionFactory(mergeTargetFilepath, new SessionFactoryConfig { WriteSqlToConsoleOut = true });
                if (logForm != null) logForm.SetSessionFactory(sessionFactory);

                BeginInvoke(new MethodInvoker(() =>
                {
                    // reload qonverter settings because the ids may change after merging
                    toolStripStatusLabel.Text = "Loading qonverter settings...";
                    statusStrip.Refresh();
                    session = sessionFactory.OpenSession();
                    session.DefaultReadOnly = true;

                    session.CreateSQLQuery("PRAGMA temp_store=MEMORY; PRAGMA mmap_size=70368744177664; -- 2^46").ExecuteUpdate();

                    toolStripStatusLabel.Text = "Refreshing group structure...";
                    statusStrip.Refresh();
                    var usedGroups = GroupingControlForm.SetInitialStructure(rootNode, session, defaultApplySourceGroupHierarchy);
                    if (usedGroups != null && usedGroups.Any())
                    {
                        var allGroupsByName = session.Query<SpectrumSourceGroup>().ToDictionary(o => o.Name);
                        var usedGroupsByName = usedGroups.ToDictionary(o => o.Name);

                        // if usedGroupsByName does not contain a key from allGroupsByName, delete the group
                        foreach (var unusedGroup in allGroupsByName.Where(o => !usedGroupsByName.ContainsKey(o.Key)))
                            session.Delete(unusedGroup);
                    }
                    session.Flush();

                    // check for embedded gene metadata;
                    // if it isn't there, ask the user if they want to embed it;
                    // if not, disable gene-related features
                    if (!Program.IsHeadless && !Embedder.HasGeneMetadata(mergeTargetFilepath) && Properties.GUI.Settings.Default.WarnAboutNoGeneMetadata)
                    {
                        bool embedGeneMetadata = true;
                        Invoke(new MethodInvoker(() =>
                                                     {
                                                         var form = new EmbedGeneMetadataWarningForm();
                                                         if (form.ShowDialog(this) == DialogResult.Ignore)
                                                             embedGeneMetadata = false;
                                                     }));

                        if (embedGeneMetadata)
                        {
                            loadRefSeqGeneMetadata(); // will call OpenFiles() after embedding, so return immediately
                            return;
                        }
                    }
                    else
                    {
                        // disable gene-related features
                    }


                    qonverterSettingsByAnalysis = session.Query<QonverterSettings>().ToDictionary(o => session.Get<Analysis>(o.Id));

                    _layoutManager.SetSession(session);

                    //set or save default layout
                    dockPanel.Visible = true;
                    _layoutManager.CurrentLayout = _layoutManager.GetCurrentDefault();

                    //breadCrumbControl.BreadCrumbs.Clear();

                    // pick a default RoundToNearest based on number of distinct modifications
                    decimal roundToNearest = 1m;
                    var distinctModificationFormat = new DistinctMatchFormat();
                    var modMasses = session.CreateQuery("SELECT DISTINCT mod.MonoMassDelta FROM Modification mod").List<double>();
                    for (int i = 4; i > 0; --i)
                    {
                        distinctModificationFormat.ModificationMassRoundToNearest = (decimal) (1.0 / Math.Pow(10, i));
                        if (modMasses.Select(o => distinctModificationFormat.Round(o)).Distinct().Count() < 30)
                        {
                            roundToNearest = distinctModificationFormat.ModificationMassRoundToNearest.Value;
                            break;
                        }
                    }
                    modificationTableForm.RoundToNearest = roundToNearest;

                    basicFilter = DataFilter.LoadFilter(session);

                    // if user has overridden filters from the command-line, make sure to reapply the filter
                    if (!defaultDataFilter.PersistentDataFilter.Equals(defaultDataFilter.OriginalPersistentDataFilter))
                        basicFilter = null;

                    if (basicFilter == null)
                    {
                        basicFilter = new DataFilter(defaultDataFilter);
                        basicFilterControl.DataFilter = basicFilter;

                        viewFilter = basicFilter;

                        ApplyBasicFilter();
                    }
                    else
                    {
                        basicFilterControl.DataFilter = basicFilter;

                        viewFilter = basicFilter;

                        try
                        {
                            // check that the unfiltered tables exist
                            session.CreateSQLQuery("SELECT COUNT(*) FROM UnfilteredProtein").UniqueResult();

                            setData();
                        }
                        catch
                        {
                            ApplyBasicFilter();
                        }
                    }

                    if (TestUILayout)
                    {
                        int i = 0;
                        foreach(var form in dockPanel.Contents)
                        {
                            ++i;
                            form.DockingHandler.DockAreas = (form.DockingHandler.DockAreas | DockAreas.Float);
                            var rect = dockPanel.ClientRectangle;
                            rect.Offset(i * 15, i * 15);
                            rect.Size = new System.Drawing.Size(960, 600);
                            form.DockingHandler.Show(dockPanel, rect);
                        }
                    }

                    toolStripStatusLabel.Text = "Ready";
                    Activate();
                }));

                //show list of delayed non-fatal errors
                if (delayedMessages.Any())
                {
                    var sb = new StringBuilder();
                    foreach (var message in delayedMessages)
                        sb.AppendLine(string.Format("{0}:{1}{2}{1}", message[0], Environment.NewLine, message[1]));
                    var messageString = sb.ToString();

                    ShowExpandedMessageBox(messageString);
                }
            }
            catch (Exception ex)
            {
                Program.HandleException(ex);
            }
        }