Interaction logic for NewDatabaseLocationDialog.xaml
Inheritance: System.Windows.Window
Exemplo n.º 1
0
        void AddDatabaseLocation(SessionBase session, string directory)
        {
            DatabaseLocationMutable newLocationMutable = new DatabaseLocationMutable(session);

            newLocationMutable.DirectoryPath = directory;
            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);
                }
            }
        }
Exemplo n.º 2
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;
            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);
                }
            }
        }
Exemplo 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);
                }
            }
        }
Exemplo n.º 4
0
 void AddDatabaseLocation(SessionBase session, string directory)
 {
   DatabaseLocationMutable newLocationMutable = new DatabaseLocationMutable(session);
   newLocationMutable.DirectoryPath = directory;
   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);
     }
   }
 }
Exemplo n.º 5
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.Session;
      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);
        }
      }
    }
Exemplo n.º 6
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;
   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);
     }
   }
 }