Inheritance: TreeViewItemViewModel
Ejemplo n.º 1
0
        private void RemoveDatabaseLocationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            DatabaseLocationViewModel view       = (DatabaseLocationViewModel)menuItem.DataContext;
            DatabaseLocation          dbLocation = view.DatabaseLocation;
            SessionBase session = dbLocation.GetSession();

            if (session.InTransaction)
            {
                session.Commit();
            }
            session.BeginUpdate();
            try
            {
                session.DeleteLocation(dbLocation);
                session.Commit();
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
            }
            catch (Exception ex)
            {
                session.Abort();
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void DatabaseLocationOrderByMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            DatabaseLocationViewModel view = (DatabaseLocationViewModel)menuItem.DataContext;

            view.OrderDatabasesByName = menuItem.IsChecked;
        }
Ejemplo n.º 3
0
        private void EditDatabaseLocationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            DatabaseLocationViewModel view             = (DatabaseLocationViewModel)menuItem.DataContext;
            DatabaseLocation          dbLocation       = view.DatabaseLocation;
            SessionBase             session            = dbLocation.GetSession();
            DatabaseLocationMutable newLocationMutable = new DatabaseLocationMutable(session);

            newLocationMutable.BackupOfOrForLocation = dbLocation.BackupOfOrForLocation;
            newLocationMutable.CompressPages         = dbLocation.CompressPages;
            newLocationMutable.PageEncryption        = dbLocation.PageEncryption;
            newLocationMutable.StartDatabaseNumber   = dbLocation.StartDatabaseNumber;
            newLocationMutable.EndDatabaseNumber     = dbLocation.EndDatabaseNumber;
            newLocationMutable.IsBackupLocation      = dbLocation.IsBackupLocation;
            newLocationMutable.DirectoryPath         = dbLocation.DirectoryPath;
            newLocationMutable.HostName = dbLocation.HostName;
            if (dbLocation.DesKey != null)
            {
                newLocationMutable.DesKey = SessionBase.TextEncoding.GetString(dbLocation.DesKey, 0, dbLocation.DesKey.Length);
            }

            var  popup  = new NewDatabaseLocationDialog(newLocationMutable, dbLocation);
            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.IsBackupLocation,
                                                                        newLocationMutable.IsBackupLocation ? newLocationMutable.BackupOfOrForLocation : dbLocation.BackupOfOrForLocation);
                    if (session.InTransaction)
                    {
                        session.Commit();
                    }
                    session.BeginUpdate();
                    newLocation        = session.NewLocation(newLocation);
                    newLocation.DesKey = SessionBase.TextEncoding.GetBytes(newLocationMutable.DesKey);
                    session.Commit();
                    m_viewModel      = new AllFederationsViewModel();
                    base.DataContext = m_viewModel;
                }
                catch (Exception ex)
                {
                    session.Abort();
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        private void RestoreDatabaseLocationMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            DatabaseLocationViewModel view       = (DatabaseLocationViewModel)menuItem.DataContext;
            DatabaseLocation          dbLocation = view.DatabaseLocation;
            SessionBase session = dbLocation.GetSession();

            if (session.InTransaction)
            {
                session.Commit();
            }
            //DatabaseLocationMutable newLocationMutable = new DatabaseLocationMutable(session);
            //newLocationMutable.DirectoryPath = dbLocation.DirectoryPath;
            //newLocationMutable.HostName = dbLocation.HostName;
            //var popup = new RestoreDialog(newLocationMutable);
            //bool? result = popup.ShowDialog();
            //if (result != null && result.Value)
            {
                dbLocation.SetPage(null); // fake it as a transient object before restore !
                dbLocation.Id = 0;        // be careful about doing this kind of make transient tricks, references from objects like this are still persistent.
                // if (session.OptimisticLocking) // && session.GetType() == typeof(ServerClientSession))
                {
                    // session.Dispose();
                    // session = new ServerClientSession(session.SystemDirectory, session.SystemHostName, 2000, false, false); // need to use pessimstic locking for restore
                    // = new SessionNoServer(session.SystemDirectory); // need to use pessimstic locking for restore
                }
                session.BeginUpdate();
                try
                {
                    session.RestoreFrom(dbLocation, DateTime.Now);
                    session.Commit(false, true); // special flags when commit of a restore ...
                    m_viewModel      = new AllFederationsViewModel();
                    base.DataContext = m_viewModel;
                }
                catch (Exception ex)
                {
                    session.Abort();
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
 public DatabaseViewModel(DatabaseLocationViewModel databaseLocationView, Database database)
     : base(databaseLocationView, true)
 {
     m_database = database;
 }
Ejemplo n.º 6
0
 public DatabaseViewModel(DatabaseLocationViewModel databaseLocationView, Database database)
   : base(databaseLocationView, true)
 {
   m_database = database;
 }
Ejemplo n.º 7
0
 public DatabaseViewModel(DatabaseLocationViewModel databaseLocationView, Database database)
     : base(databaseLocationView, true)
 {
     m_session = database.Session;
     m_dbid    = database.DatabaseNumber;
 }
Ejemplo n.º 8
0
 public DatabaseViewModel(DatabaseLocationViewModel databaseLocationView, Database database)
   : base(databaseLocationView, true)
 {
   m_session = database.Session;
   m_dbid = database.DatabaseNumber;
 }