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);
                }
            }
        }
Beispiel #2
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);
                }
            }
        }
 public void moveDatabaseLocations(SessionBase session, string updatedHostName, string newPath)
 {
     session.BeginUpdate(false);
     DatabaseLocation bootLocation = session.DatabaseLocations.LocationForDb(0);
     DatabaseLocation locationNew = new DatabaseLocation(updatedHostName, newPath, bootLocation.StartDatabaseNumber, bootLocation.EndDatabaseNumber, session,
         bootLocation.CompressPages, bootLocation.PageEncryption, bootLocation.IsBackupLocation, bootLocation.BackupOfOrForLocation);
     bootLocation = session.NewLocation(locationNew);
     session.Commit(false);
 }
Beispiel #4
0
        public void moveDatabaseLocations(SessionBase session, string updatedHostName, string newPath)
        {
            session.BeginUpdate(false);
            DatabaseLocation bootLocation = session.DatabaseLocations.LocationForDb(0);
            DatabaseLocation locationNew  = new DatabaseLocation(updatedHostName, newPath, bootLocation.StartDatabaseNumber, bootLocation.EndDatabaseNumber, session,
                                                                 bootLocation.CompressPages, bootLocation.PageEncryption, bootLocation.IsBackupLocation, bootLocation.BackupOfOrForLocation);

            bootLocation = session.NewLocation(locationNew);
            session.Commit(false);
        }
        //[TestCase(false)]
        public void CreateDataWithBackupServer(bool useServerSession)
        {
            int    loops            = 30000;
            UInt16 objectsPerPage   = 300;
            UInt16 pagesPerDatabase = 65000;
            int    j;

            if (Directory.Exists(backupDir))
            {
                foreach (string s in Directory.GetFiles(backupDir))
                {
                    File.Delete(s);
                }
                foreach (string s in Directory.GetDirectories(backupDir))
                {
                    Directory.Delete(s, true);
                }
            }
            else
            {
                Directory.CreateDirectory(systemDir);
            }
            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                Placement  place            = new Placement(11, 1, 1, objectsPerPage, pagesPerDatabase);
                Man        aMan             = null;
                Woman      aWoman           = null;
                const bool isBackupLocation = true;
                session.BeginUpdate();
                // we need to have backup locations special since server is not supposed to do encryption or compression
                DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                       PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, isBackupLocation, session.DatabaseLocations.Default());
                session.NewLocation(backupLocation);
                for (j = 1; j <= loops; j++)
                {
                    aMan = new Man(null, aMan, DateTime.UtcNow);
                    aMan.Persist(place, session);
                    aWoman = new Woman(aMan, aWoman);
                    aWoman.Persist(place, session);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000000 == 0)
                    {
                        Console.WriteLine("Loop # " + j);
                    }
                }
                UInt64 id = aWoman.Id;
                Console.WriteLine("Commit, done Loop # " + j);
                session.Commit();
            }
        }
Beispiel #6
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);
                }
            }
        }
Beispiel #7
0
        //[TestCase(true)]
        //[TestCase(false)]
        public void CreateDataWithBackupServerAutoPlacement(bool useServerSession)
        {
            int loops = 100000;
            int j;

            if (Directory.Exists(backupDir))
            {
                Directory.Delete(backupDir, true); // remove systemDir from prior runs and all its databases.
            }
            Directory.CreateDirectory(backupDir);
            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                Man        aMan             = null;
                Woman      aWoman           = null;
                const bool isBackupLocation = true;
                session.BeginUpdate();
                // we need to have backup locations special since server is not supposed to do encryption or compression
                DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                       PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, isBackupLocation, session.DatabaseLocations.Default());
                session.NewLocation(backupLocation);
                for (j = 1; j <= loops; j++)
                {
                    aMan = new Man(null, aMan, DateTime.Now);
                    session.Persist(aMan);
                    aWoman = new Woman(aMan, aWoman);
                    session.Persist(aWoman);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000000 == 0)
                    {
                        Console.WriteLine("Loop # " + j);
                    }
                }
                UInt64 id = aWoman.Id;
                Console.WriteLine("Commit, done Loop # " + j);
                session.Commit();
            }
        }
 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);
     }
   }
 }