Inheritance: TreeViewItemViewModel
Exemple #1
0
        private void Create1000TestObjectsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;

            if (session.InTransaction)
            {
                session.Commit();
            }
            session.BeginUpdate();
            //session.EnableSyncByTrackingChanges = true;
            try
            {
                for (int i = 0; i < 1000; i++)
                {
                    VelocityDbList <OptimizedPersistable> list = new VelocityDbList <OptimizedPersistable>();
                    //for (int j = 0; j < 10; j++)
                    //  list.Add(new OptimizedPersistable());
                    session.Persist(list);
                }
                session.Commit();
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
            }
            catch (Exception ex)
            {
                session.Abort();
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void SyncFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;
            var lDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Choose Federation Sync Destination Folder",
            };

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string destdir = lDialog.SelectedPath;
                if (session.InTransaction)
                {
                    session.Commit(); // must not be in transaction while copying databases
                }
                using (SessionBase sessionDestination = new SessionNoServer(destdir))
                {
                    sessionDestination.SyncWith(session);
                }
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
                MessageBox.Show("Databases synced with " + destdir + " at " + DateTime.Now);
            }
        }
Exemple #3
0
        private void CopyFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;
            var lDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Choose Federation Copy Folder",
            };

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string copyDir = lDialog.SelectedPath;
                if (session.InTransaction)
                {
                    session.Commit(); // must not be in transaction while copying databases
                }
                session.CopyAllDatabasesTo(copyDir);
                session = info.GetSession();
                session.BeginUpdate();
                FederationCopyInfo copyInfo = new FederationCopyInfo(Dns.GetHostName(), copyDir);
                session.Persist(copyInfo);
                info.Update();
                info.FederationCopies.Add(copyInfo);
                session.Commit();
                MessageBox.Show("Databases copied to " + copyDir + " at " + DateTime.Now);
            }
        }
        private void NewDatabaseLocationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem                menuItem           = (MenuItem)sender;
            FederationViewModel     view               = (FederationViewModel)menuItem.DataContext;
            FederationInfo          info               = view.Federationinfo;
            SessionBase             session            = view.Session;
            DatabaseLocationMutable newLocationMutable = new DatabaseLocationMutable(session);
            var  popup  = new NewDatabaseLocationDialog(newLocationMutable, null);
            bool?result = popup.ShowDialog();

            if (result != null && result.Value)
            {
                try
                {
                    DatabaseLocation newLocation = new DatabaseLocation(newLocationMutable.HostName, newLocationMutable.DirectoryPath, newLocationMutable.StartDatabaseNumber,
                                                                        newLocationMutable.EndDatabaseNumber, session, newLocationMutable.CompressPages, newLocationMutable.PageEncryption, newLocationMutable.BackupOfOrForLocation != null,
                                                                        newLocationMutable.BackupOfOrForLocation);
                    if (session.InTransaction)
                    {
                        session.Commit();
                    }
                    session.BeginUpdate();
                    session.NewLocation(newLocation);
                    session.Commit();
                    m_viewModel      = new AllFederationsViewModel();
                    base.DataContext = m_viewModel;
                }
                catch (Exception ex)
                {
                    session.Abort();
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #5
0
        private void NewDatabaseLocationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;

            AddDatabaseLocation(session, "");
        }
Exemple #6
0
        private void RemoveFederationInfoMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = info.GetSession();

            session.BeginUpdate();
            info.Unpersist(session);
            session.Commit();
            m_viewModel      = new AllFederationsViewModel();
            base.DataContext = m_viewModel;
        }
        private void ValidateFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;

            session.Verify();
            session = info.Session;
            session.BeginUpdate();
            info.Update();
            info.Validated.Add(DateTime.Now);
            session.Commit();
        }
        private void CopyFederationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;
            var lDialog = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Choose Federation Copy Folder",
            };

            if (lDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string copyDir = lDialog.SelectedPath;
                session.CopyAllDatabasesTo(copyDir);
                session = info.Session;
                session.BeginUpdate();
                FederationCopyInfo copyInfo = new FederationCopyInfo(Dns.GetHostName(), copyDir);
                session.Persist(copyInfo);
                info.Update();
                info.FederationCopies.Add(copyInfo);
                session.Commit();
            }
        }