当前位置: 首页>>代码示例>>C#>>正文


C# SessionNoServer.NewLocation方法代码示例

本文整理汇总了C#中SessionNoServer.NewLocation方法的典型用法代码示例。如果您正苦于以下问题:C# SessionNoServer.NewLocation方法的具体用法?C# SessionNoServer.NewLocation怎么用?C# SessionNoServer.NewLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionNoServer的用法示例。


在下文中一共展示了SessionNoServer.NewLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateLocationSameHost

 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();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:30,代码来源:DatabaseLocationTest.cs

示例2: Main

 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());
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:43,代码来源:DesEncrypted.cs

示例3: DoItClick

 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();
     }
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:38,代码来源:InstallDatabases.aspx.cs


注:本文中的SessionNoServer.NewLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。