public void CreateLocationSameHost()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     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 (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     Database database = session.OpenDatabase(locationStartDbNum, false);
     Assert.NotNull(database);
     session.DeleteDatabase(database);
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     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();
   }
 }
 public void CreateLocationSameHost()
 {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         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 (SessionNoServer session = new SessionNoServer(systemDir))
     {
         session.BeginUpdate();
         Database database = session.OpenDatabase(locationStartDbNum, false);
         Assert.NotNull(database);
         session.DeleteDatabase(database);
         session.Commit();
     }
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
         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();
     }
 }
Example #3
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());
     }
 }
Example #4
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());
   }
 }
 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);
                 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);
                 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();
         }
     }
 }
 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();
     }
   }
 }