Пример #1
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);
            }
        }
Пример #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);
                }
            }
        }
Пример #3
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);
            }
        }
Пример #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);
                }
            }
        }
Пример #5
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);
            }
        }
Пример #6
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();
   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);
   }
 }
Пример #7
0
        bool AddFederation(DirectoryInfo dirInfo)
        {
            FederationInfo info = new FederationInfo();

            if (dirInfo != null)
            {
                info.SystemDbsPath = dirInfo.FullName;
            }
            ConnectionDialog popup  = new ConnectionDialog(info);
            bool?            result = popup.ShowDialog();

            if (result != null && result.Value)
            {
                if (info.HostName == null || info.HostName.Length == 0)
                {
                    info.HostName = SessionBase.LocalHost;
                }
                SessionBase session = m_viewModel.ActiveSession;
                if (session.InTransaction)
                {
                    session.Commit();
                }
                session.BeginUpdate();
                session.Persist(info);
                session.Commit();
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
                return(true);
            }
            return(false);
        }
Пример #8
0
 public MainWindow(string dbFilePath)
 {
   InitializeComponent();
   m_viewModel = new AllFederationsViewModel();
   DirectoryInfo dirInfo = m_viewModel.Initialize(dbFilePath);
   DataCache.MaximumMemoryUse = 3000000000; // 3 GB, set this to what fits your case
   bool addedFd = false;
   if (dirInfo != null)
     addedFd = AddFederation(dirInfo);
   if (addedFd == false)
     base.DataContext = m_viewModel;
 }
Пример #9
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;
        }
Пример #10
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);
                }
            }
        }
Пример #11
0
 private void AddMenuItem_Click(object sender, RoutedEventArgs e)
 {
   FederationInfo info = new FederationInfo();
   ConnectionDialog popup = new ConnectionDialog(info);
   bool? result = popup.ShowDialog();
   if (result != null && result.Value)
   {
     SessionBase session = m_viewModel.ActiveSession;
     session.BeginUpdate();
     session.Persist(info);
     session.Commit();
     m_viewModel = new AllFederationsViewModel();
     base.DataContext = m_viewModel;
   }
 }
Пример #12
0
        private void AddMenuItem_Click(object sender, RoutedEventArgs e)
        {
            FederationInfo   info   = new FederationInfo();
            ConnectionDialog popup  = new ConnectionDialog(info);
            bool?            result = popup.ShowDialog();

            if (result != null && result.Value)
            {
                SessionBase session = m_viewModel.ActiveSession;
                session.BeginUpdate();
                session.Persist(info);
                session.Commit();
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
            }
        }
Пример #13
0
        public MainWindow(string dbFilePath)
        {
            InitializeComponent();
            _dbFilePath = dbFilePath;
            m_viewModel = new AllFederationsViewModel();
            DirectoryInfo dirInfo = m_viewModel.Initialize(dbFilePath);
            //DataCache.MaximumMemoryUse = 3000000000; // 3 GB, set this to what fits your case
            bool addedFd = false;

            if (dirInfo != null)
            {
                addedFd = AddFederation(dirInfo);
            }
            if (addedFd == false)
            {
                base.DataContext = m_viewModel;
            }
        }
Пример #14
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);
                }
            }
        }
Пример #15
0
 bool AddFederation(DirectoryInfo dirInfo)
 {
   FederationInfo info = new FederationInfo();
   if (dirInfo != null)
     info.SystemDbsPath = dirInfo.FullName;
   ConnectionDialog popup = new ConnectionDialog(info);
   bool? result = popup.ShowDialog();
   if (result != null && result.Value)
   {
     if (info.HostName == null || info.HostName.Length == 0)
       info.HostName = SessionBase.LocalHost;
     SessionBase session = m_viewModel.ActiveSession;
     if (session.InTransaction)
       session.Commit();
     session.BeginUpdate();
     session.Persist(info);
     session.Commit();
     m_viewModel = new AllFederationsViewModel();
     base.DataContext = m_viewModel;
     return true;
   }
   return false;
 }
Пример #16
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.Session;
   session.BeginUpdate();
   info.Unpersist(session);
   session.Commit();
   m_viewModel = new AllFederationsViewModel();
   base.DataContext = m_viewModel;
 }
Пример #17
0
 public MainWindow()
 {
   InitializeComponent();
   m_viewModel = new AllFederationsViewModel();
   base.DataContext = m_viewModel;
 }
Пример #18
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);
   }
 }
Пример #19
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);
     }
   }
 }
Пример #20
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);
        }
      }
    }
Пример #21
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.Session;
   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.Page = 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);
     }
   }
 }
Пример #22
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.Session;
   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);
   }
 }
Пример #23
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);
     }
   }
 }
Пример #24
0
 public MainWindow()
 {
     InitializeComponent();
     m_viewModel      = new AllFederationsViewModel();
     base.DataContext = m_viewModel;
 }