public void CreateLocationSameHostServer(bool optimisticLocking)
 {
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     DatabaseLocation remoteLocation = new DatabaseLocation(Dns.GetHostName(), location2Dir, locationStartDbNum, locationEndDbNum, session, PageInfo.compressionKind.LZ4, 0);
     remoteLocation = session.NewLocation(remoteLocation);
     Database database = session.NewDatabase(remoteLocation.StartDatabaseNumber);
     Assert.NotNull(database);
     session.Commit();
   }
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     Database database = session.OpenDatabase(locationStartDbNum, false);
     Assert.NotNull(database);
     session.DeleteDatabase(database);
     session.Commit();
   }
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.DeleteLocation(session.DatabaseLocations.LocationForDb(locationStartDbNum));
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.Commit();
   }
 }
        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);
                }
            }
        }
 //[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.UtcNow);
       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();
   }
 }
        public void CreateDataWithBackupServer()
        {
            int loops = 30000;
            int j;

            using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
            {
                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(backupHost, backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                       PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.noEncryption, isBackupLocation, session.DatabaseLocations.Default());
                session.NewLocation(backupLocation);
                session.Commit();
                session.BeginUpdate();
                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 VelocityDb.WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000000 == 0)
                    {
                        Console.WriteLine("Loop # " + j);
                    }
                }
                UInt64 id = aWoman.Id;
                Console.WriteLine("Commit, done Loop # " + j);
                session.Commit();
            }
        }
 public void CreateDataWithBackupServer()
 {
   int loops = 30000;
   int j;
   using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
   {
     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(backupHost, backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
       PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.noEncryption, isBackupLocation, session.DatabaseLocations.Default());
     session.NewLocation(backupLocation);
     session.Commit();
     session.BeginUpdate();
     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 VelocityDb.WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
       if (j % 1000000 == 0)
         Console.WriteLine("Loop # " + j);
     }
     UInt64 id = aWoman.Id;
     Console.WriteLine("Commit, done Loop # " + j);
     session.Commit();
   }
 }
 public void CreateLocationSameHostServer(bool optimisticLocking)
 {
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         DatabaseLocation remoteLocation = new DatabaseLocation(Dns.GetHostName(), location2Dir, locationStartDbNum, locationEndDbNum, session, PageInfo.compressionKind.LZ4, 0);
         remoteLocation = session.NewLocation(remoteLocation);
         Database database = session.NewDatabase(remoteLocation.StartDatabaseNumber);
         Assert.NotNull(database);
         session.Commit();
     }
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         Database database = session.OpenDatabase(locationStartDbNum, false);
         Assert.NotNull(database);
         session.DeleteDatabase(database);
         session.Commit();
     }
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         foreach (DatabaseLocation loc in session.DatabaseLocations)
         {
             Console.WriteLine(loc.ToStringDetails(session, false));
         }
         session.DeleteLocation(session.DatabaseLocations.LocationForDb(locationStartDbNum));
         foreach (DatabaseLocation loc in session.DatabaseLocations)
         {
             Console.WriteLine(loc.ToStringDetails(session, false));
         }
         session.Commit();
     }
 }
Exemple #7
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);
                }
            }
        }
Exemple #8
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);
            }
        }
 public void aaaFakeLicenseDatabaseCleanup(bool deleteLocationProperly, bool useServerSession)
 {
     if (deleteLocationProperly)
     {
         using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
         {
             session.BeginUpdate();
             DatabaseLocation defaultLocation = session.DatabaseLocations.Default();
             List <Database>  dbList          = session.OpenLocationDatabases(defaultLocation, true);
             foreach (Database db in dbList)
             {
                 if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers)
                 {
                     session.DeleteDatabase(db);
                 }
             }
             session.DeleteLocation(defaultLocation);
             session.Commit();
         }
     }
     foreach (string s in Directory.GetFiles(systemDir))
     {
         File.Delete(s);
     }
     using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
     {
         session.BeginUpdate();
         UInt32 dbNum = session.DatabaseNumberOf(typeof(NotSharingPage));
         session.NewDatabase(dbNum);
         session.Commit();
     }
     File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
 }
Exemple #10
0
        public static string GetDatabaseStructure(TargetVersion version, DatabaseLocation location)
        {
            var builder = new StringBuilder();

            using (var isql = new Process())
            {
                isql.StartInfo = new ProcessStartInfo
                {
                    FileName               = Path.Combine(GetFirebirdLocation(version), "isql.exe"),
                    Arguments              = $"-x {GetDatabasePath(version, location)}",
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true
                };
                isql.OutputDataReceived += (sender, e) =>
                {
                    if (e.Data != null)
                    {
                        if (e.Data.StartsWith("/* CREATE DATABASE '", StringComparison.InvariantCulture))
                        {
                            return;
                        }
                        builder.AppendLine(e.Data);
                    }
                };
                isql.Start();
                isql.BeginOutputReadLine();
                isql.WaitForExit();
            }
            return(builder.ToString().Trim());
        }
 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);
 }
Exemple #12
0
            public static void ExecuteScript(TargetVersion version, DatabaseLocation location, string resourceName)
            {
                var assembly = Assembly.GetExecutingAssembly();

                using (var reader = new StreamReader(assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{resourceName}"), Encoding.UTF8))
                {
                    ExecuteScript(version, location, new FbScript(reader.ReadToEnd()));
                }
            }
Exemple #13
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);
        }
Exemple #14
0
 private static bool IsDatabaseLocationLocal(
     DatabaseLocation databaseLocation)
 {
     return(string.Compare(
                databaseLocation.HostName, SessionBase.LocalHost,
                StringComparison.Ordinal) == 0 &&
            string.Compare(
                databaseLocation.DirectoryPath, Session.SystemDirectory,
                StringComparison.Ordinal) == 0);
 }
Exemple #15
0
 public void RestoreAll()
 {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         session.BeginUpdate();
         DatabaseLocation backupLocation = session.DatabaseLocations.LocationForDb(backupLocationStartDbNum);
         session.RestoreFrom(backupLocation, DateTime.Now);
         session.Commit(false);
     }
 }
Exemple #16
0
 public LocationDetails(DatabaseLocation databaseAddress)
 {
     LocationId   = databaseAddress.LocationId;
     UserId       = databaseAddress.UserId;
     LocationName = databaseAddress.LocationName;
     AddressLine  = databaseAddress.AddressLine;
     City         = databaseAddress.City;
     State        = databaseAddress.State;
     Zip          = databaseAddress.Zip;
 }
 public void RestoreAll()
 {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         session.BeginUpdate();
         DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default());
         session.RestoreFrom(backupLocation, DateTime.UtcNow);
         session.Commit(false, true);
     }
 }
Exemple #18
0
 public void RestoreAllViaServer()
 {
     using (ServerClientSession session = new ServerClientSession(systemDir, null, 2000, false)) // don't use optimistic locking for restore
     {
         session.BeginUpdate();
         DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default());
         session.RestoreFrom(backupLocation, DateTime.Now);
         session.Commit(false);
     }
 }
 void BtnOkClick(object pSender, RoutedEventArgs pEvents)
 {
     if (m_newLocation.IsBackupLocation)
     {
         DatabaseLocation backedUpLocation = (DatabaseLocation)BackupOfLocationBox.SelectedValue;
         m_newLocation.BackupOfOrForLocation = backedUpLocation;
     }
     m_newLocation.CompressPages  = (PageInfo.compressionKind)CompressionBox.SelectedValue;
     m_newLocation.PageEncryption = (PageInfo.encryptionKind)EncryptionBox.SelectedValue;
     m_newLocation.HostName       = HostTextBox.Text;
     m_newLocation.DirectoryPath  = DirectoryTextBox.Text;
     DialogResult = true;
 }
Exemple #20
0
 public override bool ContainsDatabase(DatabaseLocation location, UInt32 dbNum, string extension = ".odb")
 {
   if (location != null)
   {
     if (dbNum < location.StartDatabaseNumber || dbNum > location.EndDatabaseNumber)
       return false;
     //string fullPath = location.DirectoryPath + Path.DirectorySeparatorChar + dbNum.ToString() + extension;
     string fullPath = dbNum.ToString() + extension; // handle multiple database locations later
     CloudFile cloudFile = m_databaseDir.GetFileReference(fullPath);
     return cloudFile.Exists();
   }
   return false;
 }
Exemple #21
0
 private static void ExecuteScript(TargetVersion version, DatabaseLocation location, FbScript script)
 {
     using (var connection = new FbConnection(GetConnectionString(version, location)))
     {
         script.Parse();
         if (script.Results.Any())
         {
             var be = new FbBatchExecution(connection);
             be.AppendSqlStatements(script);
             be.Execute();
         }
     }
 }
Exemple #22
0
        public bool SaveLocation(LocationDetails locationDetails)
        {
            DatabaseLocation dbLocation = new DatabaseLocation(locationDetails);

            dbLocation.EscapeStringFields();
            if (dbLocation.LocationId > 0)
            {
                return(_dbQueryService.PersistExistingLocation(dbLocation));
            }
            else
            {
                return(_dbQueryService.PersistNewLocation(dbLocation));
            }
        }
        public void createDatabaseLocations(SessionBase session)
        {
            session.BeginUpdate();
            Person person = new Person("Mats", "Persson", 54);

            session.Persist(person);
            var       otherLocation = new DatabaseLocation(session.SystemHostName, otherDbDir, otherStartdbId, session.DefaultDatabaseLocation().EndDatabaseNumber, session);
            Placement place         = new Placement(otherStartdbId);
            Person    person2       = new Person("Mats", "Persson", 27);

            session.Persist(place, person2);
            session.Commit();
            verifyDatabaseLocations(session);
        }
 public NewDatabaseLocationDialog(DatabaseLocationMutable newLocation, DatabaseLocation existingLocation)
 {
   InitializeComponent();
   m_existingLocation = existingLocation;
   if (m_existingLocation != null)
     Title = "Edit " + m_existingLocation.ToString();
   m_newLocation = newLocation;
   if (m_newLocation.IsBackupLocation)
   {
     BackupOfLocationLabel.Content = "Backup";
     BackupOfLocationBox.IsReadOnly = true;
   }
   base.DataContext = this;
 }
        //[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();
            }
        }
Exemple #26
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);
                }
            }
        }
 public void DeleteBackupLocation()
 {
     using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
     {
         session.BeginUpdate();
         DatabaseLocation backupLocation = session.DatabaseLocations.LocationForDb(backupLocationStartDbNum);
         List <Database>  dbList         = session.OpenLocationDatabases(backupLocation, true);
         foreach (Database db in dbList)
         {
             session.DeleteDatabase(db);
         }
         session.DeleteLocation(backupLocation);
         session.Commit();
     }
 }
 public NewDatabaseLocationDialog(DatabaseLocationMutable newLocation, DatabaseLocation existingLocation)
 {
     InitializeComponent();
     m_existingLocation = existingLocation;
     if (m_existingLocation != null)
     {
         Title = "Edit " + m_existingLocation.ToString();
     }
     m_newLocation = newLocation;
     if (m_newLocation.IsBackupLocation)
     {
         BackupOfLocationLabel.Content  = "Backup";
         BackupOfLocationBox.IsReadOnly = true;
     }
     base.DataContext = this;
 }
        public void RestoreToBackupServer()
        {
            using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost))
            {
                session.ClearServerCache(); // normally don't use this function but use it here to simulate a server going down and restarting
            }

            using (ServerClientSession session = new ServerClientSession(s_systemDir, backupHost, 1000, true, inMemoryOnly))
            {
                session.BeginUpdate();
                DatabaseLocation backupLocation = new DatabaseLocation(backupHost, backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
                                                                       PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default());
                session.RestoreFrom(backupLocation, DateTime.MaxValue);
                session.Commit(false, true);
            }
        }
Exemple #30
0
        public static string GetConnectionString(TargetVersion version, DatabaseLocation location)
        {
            var builder =
                new FbConnectionStringBuilder
            {
                Database      = GetDatabasePath(version, location),
                UserID        = "sysdba",
                Password      = "******",
                ServerType    = FbServerType.Embedded,
                ClientLibrary = Path.Combine(GetFirebirdLocation(version), $"fbclient.dll"),
                Charset       = "utf8",
                Pooling       = false,
            };

            return(builder.ToString());
        }
Exemple #31
0
 static void Main(string[] args)
 {
     try
     {
         using (SessionNoServer session = new SessionNoServer(s_systemDir))
         {
             DatabaseLocation localLocation = new DatabaseLocation(Dns.GetHostName(), Path.Combine(session.SystemDirectory, "desEncryptedLocation"), desEncryptedStartDatabaseNumber, UInt32.MaxValue,
                                                                   session, PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.desEncrypted);
             session.BeginUpdate();
             session.NewLocation(localLocation);
             localLocation.DesKey = SessionBase.TextEncoding.GetBytes("5d9nndwy"); // Des keys are 8 bytes long
             Person robinHood = new Person("Robin", "Hood", 30);
             Person billGates = new Person("Bill", "Gates", 56, robinHood);
             Person steveJobs = new Person("Steve", "Jobs", 56, billGates);
             robinHood.BestFriend = billGates;
             session.Persist(steveJobs);
             steveJobs.Friends.Add(billGates);
             steveJobs.Friends.Add(robinHood);
             billGates.Friends.Add(billGates);
             robinHood.Friends.Add(steveJobs);
             session.Commit();
         }
         using (SessionNoServer session = new SessionNoServer(s_systemDir))
         { // Des keys are not persisted in DatabaseLocation (for safety). Instead they are stored as *.des files
           // in the users document directory of the user that created the DatabaseLocation. These files can be copied
           // to other user's document directory when acccess is desired for other users.
           // Path to user document dir is given by C#: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
             session.BeginRead();
             var allPersonsEnum = session.AllObjects <Person>();
             foreach (Person obj in allPersonsEnum)
             {
                 Person person = obj as Person;
                 if (person != null)
                 {
                     Console.WriteLine(person.FirstName);
                 }
             }
             session.Commit();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
 public void Dispose()
 {
     using (SessionNoServer session = new SessionNoServer(SystemDir))
     {
         session.BeginUpdate();
         DatabaseLocation defaultLocation = session.DatabaseLocations.Default();
         List <Database>  dbList          = session.OpenLocationDatabases(defaultLocation, true);
         foreach (Database db in dbList)
         {
             if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers)
             {
                 session.DeleteDatabase(db);
             }
         }
         session.DeleteLocation(defaultLocation);
         session.Commit();
     }
 }
 public void DeleteDefaultLocation()
 {
     using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
     {
         session.BeginUpdate();
         DatabaseLocation defaultLocation = session.DatabaseLocations.Default();
         List <Database>  dbList          = session.OpenLocationDatabases(defaultLocation, true);
         foreach (Database db in dbList)
         {
             if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers)
             {
                 session.DeleteDatabase(db);
             }
         }
         session.DeleteLocation(defaultLocation);
         session.Commit();
     }
 }
Exemple #34
0
 static void Main(string[] args)
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     {
       DatabaseLocation localLocation = new DatabaseLocation(Dns.GetHostName(), Path.Combine(session.SystemDirectory, "desEncryptedLocation"), desEncryptedStartDatabaseNumber, UInt32.MaxValue,
         session, PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.desEncrypted);
       session.BeginUpdate();
       session.NewLocation(localLocation);
       localLocation.DesKey = SessionBase.TextEncoding.GetBytes("5d9nndwy"); // Des keys are 8 bytes long
       Person robinHood = new Person("Robin", "Hood", 30);
       Person billGates = new Person("Bill", "Gates", 56, robinHood);
       Person steveJobs = new Person("Steve", "Jobs", 56, billGates);
       robinHood.BestFriend = billGates;
       session.Persist(steveJobs);
       steveJobs.Friends.Add(billGates);
       steveJobs.Friends.Add(robinHood);
       billGates.Friends.Add(billGates);
       robinHood.Friends.Add(steveJobs);
       session.Commit();
     }
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     { // Des keys are not persisted in DatabaseLocation (for safety). Instead they are stored as *.des files
       // in the users document directory of the user that created the DatabaseLocation. These files can be copied
       // to other user's document directory when acccess is desired for other users. 
       // Path to user document dir is given by C#: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
       session.BeginRead();
       var allPersonsEnum = session.AllObjects<Person>();
       foreach (Person obj in allPersonsEnum)
       {
         Person person = obj as Person;
         if (person != null)
           Console.WriteLine(person.FirstName);
       }
       session.Commit();
     }
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.ToString());
   }
 }
Exemple #35
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);
                }
            }
        }
Exemple #36
0
 public void setup()
 {
     testLocation = new DatabaseLocation
     {
         LocationId   = 1,
         AddressLine  = "333 King Edwards Dr",
         City         = "Ottawa",
         LocationName = "DMV",
         State        = "ON",
         Zip          = "M2I9R4"
     };
     testLocation2 = new DatabaseLocation
     {
         LocationId   = 2,
         AddressLine  = "334 King Edwards Dr",
         City         = "Ottawa",
         LocationName = "DMV2",
         State        = "ON",
         Zip          = "M2I9R4"
     };
 }
 protected void DoItClick(object sender, EventArgs e)
 {
   if (DoUpdatePassword != null && DoUpdatePassword.Text == "mysecret")
   {
     int step = 0;
     try
     {
       string updatedHostName = Dns.GetHostName().ToLower();
       if (HostName.Text != null && HostName.Text.Length > 0)
         updatedHostName = HostName.Text.ToLower();
       using (SessionNoServer session = new SessionNoServer(MapPath("~/Database").ToLower(), 2000, false, false))
       {
         session.BeginUpdate(false, true);
         DatabaseLocation bootLocation = session.DatabaseLocations.LocationForDb(0);
         DatabaseLocation locationNew = new DatabaseLocation(updatedHostName, MapPath("~/Database").ToLower(), bootLocation.StartDatabaseNumber, bootLocation.EndDatabaseNumber, session,
             bootLocation.CompressPages, bootLocation.PageEncryption, bootLocation.IsBackupLocation, bootLocation.BackupOfOrForLocation);
         bootLocation = session.NewLocation(locationNew);
         session.Commit(false);
         step++;
       }
       using (SessionNoServer session = new SessionNoServer(MapPath("~/IssuesDatabase").ToLower(), 2000, false, false))
       {
         session.BeginUpdate(false, true);
         DatabaseLocation bootLocation = session.DatabaseLocations.LocationForDb(0);
         DatabaseLocation locationNew = new DatabaseLocation(updatedHostName, MapPath("~/IssuesDatabase").ToLower(), bootLocation.StartDatabaseNumber, bootLocation.EndDatabaseNumber, session,
             bootLocation.CompressPages, bootLocation.PageEncryption, bootLocation.IsBackupLocation, bootLocation.BackupOfOrForLocation);
         bootLocation = session.NewLocation(locationNew);
         session.Commit(false);
         step++;
         Results.Text = locationNew.HostName + "@" + locationNew.DirectoryPath;
       }
     }
     catch (System.Exception ex)
     {
       Results.Text = "In step: " + step + " " + ex.ToString();
     }
   }
 }
    public void multipleServersInvalid()
    {
      Assert.Throws<InvalidChangeOfDefaultLocationException>(() =>
      {
        using (ServerClientSession session = new ServerClientSession(systemDir))
        {
          session.SetTraceDbActivity(2);
          try
          {
            DatabaseLocation localLocation = new DatabaseLocation(systemHost, location2Dir, 10000, 20000, session, PageInfo.compressionKind.LZ4, 0);
            Placement place = new Placement(10000, 2);
            session.BeginUpdate();
            session.NewLocation(localLocation);
            Man aMan = null;
            Woman aWoman = null;

            for (int j = 1; j <= 5; 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 % 1000 == 0)
              {
                session.FlushUpdates();
              }
            }
            localLocation = new DatabaseLocation(systemHost, systemDir, 20001, 30000, session, PageInfo.compressionKind.None, 0);
            session.NewLocation(localLocation);
            place = new Placement(20001);
            //localDatabase = session.NewDatabase(20001, localLocation);
            for (int j = 1; j <= 5; 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 % 1000 == 0)
              {
                session.FlushUpdates();
              }
            }
            DatabaseLocation serverLocation = new DatabaseLocation(systemHost2, location2Dir, 30001, 40000, session, PageInfo.compressionKind.LZ4, 0);
            session.NewLocation(serverLocation);
            place = new Placement(30001);
            for (int j = 1; j <= 5; 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 % 1000 == 0)
              {
                session.FlushUpdates();
              }
            }
            session.Commit();
          }
          finally
          {
            //session.Close();
          }
        }
      });
    }
 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 DatabaseLocationViewModel(DatabaseLocation location)
   : base(null, true)
 {
   m_databaseLocation = location;
 }
 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);
     }
   }
 }
    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);
        }
      }
    }
    public void RestoreToBackupServer()
    {
      using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost))
      {
        session.ClearServerCache(); // normally don't use this function but use it here to simulate a server going down and restarting
      }

      using (ServerClientSession session = new ServerClientSession(s_systemDir, backupHost, 1000, true, inMemoryOnly))
      {
        session.BeginUpdate();
        DatabaseLocation backupLocation = new DatabaseLocation(backupHost, backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
          PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default());
        session.RestoreFrom(backupLocation, DateTime.MaxValue);
        session.Commit(false, true);
      }
    }
Exemple #44
0
 public override bool ContainsDatabase(DatabaseLocation location, UInt32 dbNum, string extension = ".odb")
 {
   if (location != null)
   {
     if (dbNum < location.StartDatabaseNumber || dbNum > location.EndDatabaseNumber)
       return false;
     //string fullPath = location.DirectoryPath + Path.DirectorySeparatorChar + dbNum.ToString() + extension;
     string fullPath = dbNum.ToString() + extension; // handle multiple database locations later
     CloudFile cloudFile = m_databaseDir.GetFileReference(fullPath);
     return cloudFile.Exists();
   }
   return false;
 }
 public void RestoreAllViaServer()
 {
   using (ServerClientSession session = new ServerClientSession(systemDir, null, 2000, false)) // don't use optimistic locking for restore
   {
     session.BeginUpdate();
     DatabaseLocation backupLocation = new DatabaseLocation(Dns.GetHostName(), backupDir, backupLocationStartDbNum, UInt32.MaxValue, session,
       PageInfo.compressionKind.None, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default());
     session.RestoreFrom(backupLocation, DateTime.UtcNow);
     session.Commit(false, true);
   }
 }
    [Repeat(3)] // remove when propagation of optimistic locking flag is done to slave database locations TO DO (issue caused by CopyAllDatabasdesTo that uses pessimistic locking)
    public void multipleServersOK()
    {
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        session.BeginRead();
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        session.Commit();
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        session.SetTraceDbActivity(0);
        DatabaseLocation localLocation = new DatabaseLocation(systemHost, location2Dir, 10000, 20000, session, PageInfo.compressionKind.LZ4, 0);
        Placement place = new Placement(10000, 2);
        session.BeginUpdate();
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        Console.WriteLine();
        session.NewLocation(localLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        Man aMan = null;
        Woman aWoman = null;

        for (int j = 1; j <= 5; 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 % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        localLocation = new DatabaseLocation(systemHost2, systemDir, 20001, 30000, session, PageInfo.compressionKind.LZ4, 0);
        session.NewLocation(localLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        place = new Placement(20001);
        //localDatabase = session.NewDatabase(20001, localLocation);
        for (int j = 1; j <= 5; 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 % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        DatabaseLocation serverLocation = new DatabaseLocation(systemHost2, location2Dir, 30001, 40000, session, PageInfo.compressionKind.LZ4, 0);
        session.NewLocation(serverLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        place = new Placement(30001);
        for (int j = 1; j <= 5; 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 % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        localLocation = new DatabaseLocation(systemHost3, systemDir, 40001, 50000, session, PageInfo.compressionKind.None, 0);
        session.NewLocation(localLocation);
        place = new Placement(40001);
        //localDatabase = session.NewDatabase(20001, localLocation);
        for (int j = 1; j <= 5; 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 % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        session.Commit();
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        session.CopyAllDatabasesTo(copyDir);
        using (SessionNoServer copySession = new SessionNoServer(copyDir))
        {
          copySession.Verify();
        }
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 2000, false)) // TO DO, change back to use optimistic locking
      {
        //session.SetTraceDbActivity(0);
        session.BeginUpdate();
        Database db = session.OpenDatabase(10000);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(20001);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(30001);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(40001);
        session.DeleteDatabase(db);
        session.Commit();
        Directory.Delete(copyDir, true);
      }

      System.GC.Collect();
      System.GC.WaitForPendingFinalizers();

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        Assert.True(session.OptimisticLocking);
      }
    }
 public DatabaseLocationViewModel(DatabaseLocation location, bool orderDatabasesByName)
   : base(null, true)
 {
   m_databaseLocation = location;
   m_orderDatabasesByName = orderDatabasesByName;
 }