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


C# SessionBase.AllObjects方法代码示例

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


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

示例1: SearchGeoHashIndex

 public static HashSet<GeoObj> SearchGeoHashIndex(SessionBase session, double lat, double lon, double radius)
 {
   HashSet<GeoObj> resultSet = new HashSet<GeoObj>();
   WGS84Point center = new WGS84Point(lat, lon);
   GeoHashCircleQuery query = new GeoHashCircleQuery(center, radius); // radius in meters
   BoundingBox bbox = query.BoundingBox;
   var btreeSet = session.AllObjects<BTreeSet<GeoObj>>().FirstOrDefault();
   foreach (GeoHash hash in query.SearchHashes)
   {
     var itr = btreeSet.Iterator();
     itr.GoTo(new GeoObj(hash.LongValue));
     var current = itr.Current();
     while (current != null)
     {
       GeoHash geoHash = GeoHash.FromLongValue(current.GeoHash);
       if ((geoHash.SignificantBits >= hash.SignificantBits && geoHash.Within(hash)) || (geoHash.SignificantBits < hash.SignificantBits && hash.Within(geoHash)))
       {
         if (!(current.Latitude < bbox.MinLat || current.Latitude > bbox.MaxLat || current.Longitude < bbox.MinLon || current.Longitude > bbox.MaxLon))
           resultSet.Add(current);
         current = itr.Next();
       }
       else
         break;
     }
   }
   return resultSet;
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:27,代码来源:GeoHashQuery.cs

示例2: Initialize

 void Initialize()
 {
   SessionBase.BaseDatabasePath = Properties.Settings.Default.BaseDatabasePath;
   m_session = new SessionNoServer(Properties.Settings.Default.DatabaseManagerDirectory);
   try
   {
     m_session.BeginUpdate();
     List<FederationViewModel> federationInfos = new List<FederationViewModel>();
     List<FederationInfo> federationInfosToRemove = new List<FederationInfo>();
     foreach (FederationInfo info in m_session.AllObjects<FederationInfo>())
     {
       try
       {
         federationInfos.Add(new FederationViewModel(info));
       }
       catch (Exception ex)
       {
         if (MessageBox.Show(ex.Message + " for " + info.HostName + " " + info.SystemDbsPath + " Remove this Database?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
           federationInfosToRemove.Add(info);
       }
     }
     foreach (FederationInfo info in federationInfosToRemove)
       info.Unpersist(m_session);
     if (federationInfos.Count() == 0)
     {
       string host = Properties.Settings.Default.DatabaseManagerHost;
       if (host == null || host.Length == 0)
         host = Dns.GetHostName();
       FederationInfo info = new FederationInfo(host,
         Properties.Settings.Default.DatabaseManagerDirectory,
         Properties.Settings.Default.TcpIpPortNumber,
         Properties.Settings.Default.DoWindowsAuthentication,
         null,
         Properties.Settings.Default.WaitForLockMilliseconds,
         Properties.Settings.Default.UseClientServer,
         "Database Manager");
       m_session.Persist(info);
       m_session.Commit();
       federationInfos.Add(new FederationViewModel(info));
     }
     if (m_session.InTransaction)
       m_session.Commit();
     m_federationViews = federationInfos;
   }
   catch (Exception ex)
   {
     if (m_session.InTransaction)
       m_session.Abort();
     if (MessageBox.Show(ex.Message + " for " + SessionBase.LocalHost + " " + Properties.Settings.Default.DatabaseManagerDirectory + " Remove this Database?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
       DirectoryInfo dir = new DirectoryInfo(Properties.Settings.Default.DatabaseManagerDirectory);
       dir.Delete(true);
       Initialize();
     }
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:56,代码来源:AllFederationsViewModel+.cs

示例3: verifyDatabaseLocations

 public void verifyDatabaseLocations(SessionBase session)
 {
   session.BeginRead();
   foreach (Person person in session.AllObjects<Person>())
   {
     Console.WriteLine(person.ToString());
     Assert.AreEqual(person.FirstName, "Mats");
   }
   session.Commit();
   session.Verify();
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:11,代码来源:MoveDatabaseLocations.cs

示例4: AllFederationsViewModel

 public AllFederationsViewModel()
 {
   SessionBase.BaseDatabasePath = Properties.Settings.Default.BaseDatabasePath;
   m_session = new SessionNoServer(Properties.Settings.Default.DatabaseManagerDirectory);
   m_session.BeginUpdate();
   List<FederationViewModel> federationInfos = new List<FederationViewModel>();
   foreach (FederationInfo info in m_session.AllObjects<FederationInfo>())
   {
     try
     {
       federationInfos.Add(new FederationViewModel(info));
     }
     catch (Exception ex)
     {
       MessageBox.Show(ex.Message);
     }
   }
   if (federationInfos.Count() == 0)
   {
     string host = Properties.Settings.Default.DatabaseManagerHost;
     if (host == null || host.Length == 0)
       host = Dns.GetHostName();
     FederationInfo info = new FederationInfo(host,
       Properties.Settings.Default.DatabaseManagerDirectory,
       Properties.Settings.Default.TcpIpPortNumber,
       Properties.Settings.Default.DoWindowsAuthentication,
       null,
       Properties.Settings.Default.UseClientServer,
       "Database Manager");
     m_session.Persist(info);
     m_session.Commit();
     federationInfos.Add(new FederationViewModel(info));
   }
   if (m_session.InTransaction)
     m_session.Commit();
   m_federationViews = new ReadOnlyCollection<FederationViewModel>(federationInfos);
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:37,代码来源:AllFederationsViewModel+.cs

示例5: LockConflict

 void LockConflict(SessionBase sharedReadSession)
 {
   string host = null;
   Random r = new Random(5);
   SessionPool sessionPool = new SessionPool(3, () => new ServerClientSession(systemDir, host, 2000, false));
   try
   {
     int iCounter = 0;
     int sessionId1 = -1;
     SessionBase session1 = null;
     for (int i = 0; i < 50; i++)
     {
       try
       {
         session1 = sessionPool.GetSession(out sessionId1);
         session1.BeginUpdate();
         Dokument Doc_A = new Dokument();
         Doc_A.Name = "Test A";
         session1.Persist(Doc_A);
         Console.WriteLine(Doc_A.ToString());
         int sessionId2 = -1;
         SessionBase session2 = null;
         try
         {
           session2 = sessionPool.GetSession(out sessionId2);
           session2.BeginUpdate();
           Dokument Doc_B = new Dokument();
           Doc_B.Name = "Test_B";
           session2.Persist(Doc_B);
           Console.WriteLine(Doc_B.ToString());
           session2.Commit();
         }
         finally
         {
           sessionPool.FreeSession(sessionId2, session2);
         }
         session1.Commit();
         sharedReadSession.ForceDatabaseCacheValidation();
         session1.BeginRead();
         ulong ct = session1.AllObjects<Dokument>(false).Count;
         Console.WriteLine("Number of Dokument found by normal session: " + ct);
         session1.Commit();
         ct = sharedReadSession.AllObjects<Dokument>(false).Count;
         Console.WriteLine("Number of Dokument found by shared read session: " + ct);
       }
       finally
       {
         sessionPool.FreeSession(sessionId1, session1);
       }
       iCounter++;
       Console.WriteLine(" -> " + iCounter.ToString());
     }
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.Message);
     throw;
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:59,代码来源:MultipleUpdaters.cs


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