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


C# NeoDatis.GetOid方法代码示例

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


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

示例1: UpdateNonNativeObjectInfo

		public override NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi, bool forceUpdate)
		{
			// To enable object auto-reconnect on the server side
			if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && nnoi.GetHeader()
				.GetOid() != null)
			{
				NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
					)sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
					(), true);
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
					(nnoi.GetOid(), false);
				// only add in th cache if object does not exist in the cache
				if (oih == null)
				{
					session.GetCache().AddObjectInfo(nnoi.GetHeader());
				}
			}
			NeoDatis.Odb.OID roid = base.UpdateNonNativeObjectInfo(nnoi, forceUpdate);
			if (nnoi is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
			{
				NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
					)nnoi;
				NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
					)GetSession();
				session.AssociateIds(cnnoi.GetOid(), cnnoi.GetLocalOid());
			}
			return roid;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:29,代码来源:ServerObjectWriter.cs

示例2: WriteNonNativeObjectInfo

		public override NeoDatis.Odb.OID WriteNonNativeObjectInfo(NeoDatis.Odb.OID existingOid
			, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo objectInfo, long position
			, bool writeDataInTransaction, bool isNewObject)
		{
			// To enable object auto-reconnect on the server side
			if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && objectInfo.GetHeader
				().GetOid() != null)
			{
				NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
					)sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
					(), true);
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
					(objectInfo.GetOid(), false);
				// only add in th cache if object does not exist in the cache
				if (oih == null)
				{
					session.GetCache().AddObjectInfo(objectInfo.GetHeader());
				}
			}
			NeoDatis.Odb.OID roid = base.WriteNonNativeObjectInfo(existingOid, objectInfo, position
				, writeDataInTransaction, isNewObject);
			if (objectInfo is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
			{
				NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
					)objectInfo;
				NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
					)GetSession();
				session.AssociateIds(roid, cnnoi.GetLocalOid());
				// Adds the abstract Objectinfo in the cache
				session.GetCache().AddObjectInfo(cnnoi.GetHeader());
			}
			return roid;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:33,代码来源:ServerObjectWriter.cs

示例3: GetConnectionManager

		private NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Message ManageGetObjectFromIdCommand
			(NeoDatis.Odb.Core.Server.Message.GetObjectFromIdMessage message)
		{
			// Gets the base identifier
			string baseIdentifier = message.GetBaseIdentifier();
			// Gets the connection manager for this base identifier
			NeoDatis.Odb.Core.Server.Connection.ConnectionManager connectionManager = null;
			NeoDatis.Odb.Core.Server.Connection.IConnection connection = null;
			NeoDatis.Odb.OID oid = null;
			NeoDatis.Tool.Mutex.Mutex mutex = null;
			try
			{
				mutex = NeoDatis.Tool.Mutex.MutexFactory.Get(baseIdentifier).Acquire("getObjectFromId"
					);
				// Gets the connection manager for this base identifier
				connectionManager = GetConnectionManager(baseIdentifier);
				if (connectionManager == null)
				{
					System.Text.StringBuilder buffer = new System.Text.StringBuilder();
					buffer.Append("ODBServer.ConnectionThread:Base ").Append(baseIdentifier).Append(" is not registered on this server!"
						);
					return new NeoDatis.Odb.Core.Server.Message.GetObjectFromIdMessageResponse(baseIdentifier
						, message.GetConnectionId(), buffer.ToString());
				}
				connection = connectionManager.GetConnection(message.GetConnectionId());
				connection.SetCurrentAction(NeoDatis.Odb.Core.Server.Connection.ConnectionAction.
					ActionSelect);
				NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connection.GetStorageEngine
					();
				oid = message.GetOid();
				NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = engine.GetMetaObjectFromOid
					(oid);
				return new NeoDatis.Odb.Core.Server.Message.GetObjectFromIdMessageResponse(baseIdentifier
					, message.GetConnectionId(), nnoi);
			}
			catch (System.Exception e)
			{
				string se = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false);
				string msg = baseIdentifier + ":Error while getting object of id " + oid;
				NeoDatis.Tool.DLogger.Error(msg, e);
				return new NeoDatis.Odb.Core.Server.Message.GetObjectFromIdMessageResponse(baseIdentifier
					, message.GetConnectionId(), msg + ":\n" + se);
			}
			finally
			{
				if (mutex != null)
				{
					mutex.Release("getObjectFromId");
				}
				connection.EndCurrentAction();
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:52,代码来源:ClientServerConnection.cs

示例4: Delete

		public virtual NeoDatis.Odb.OID Delete(NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
			 header)
		{
			NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
			NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
			long objectPosition = header.GetPosition();
			NeoDatis.Odb.OID classInfoId = header.GetClassInfoId();
			NeoDatis.Odb.OID oid = header.GetOid();
			// gets class info from in memory meta model
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = GetSession().GetMetaModel().GetClassInfoFromId
				(classInfoId);
			bool withIndex = !ci.GetIndexes().IsEmpty();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = null;
			// When there is index,we must *always* load the old meta representation
			// to compute index keys
			if (withIndex)
			{
				nnoi = objectReader.ReadNonNativeObjectInfoFromPosition(ci, header.GetOid(), objectPosition
					, true, false);
			}
			// a boolean value to indicate if object is in connected zone or not
			// This will be used to know if work can be done out of transaction
			// for unconnected object,changes can be written directly, else we must
			// use Transaction (using WriteAction)
			bool objectIsInConnectedZone = cache.ObjectWithIdIsInCommitedZone(header.GetOid()
				);
			// triggers
			// FIXME
			triggerManager.ManageDeleteTriggerBefore(ci.GetFullClassName(), null, header.GetOid
				());
			long nbObjects = ci.GetNumberOfObjects();
			NeoDatis.Odb.OID previousObjectOID = header.GetPreviousObjectOID();
			NeoDatis.Odb.OID nextObjectOID = header.GetNextObjectOID();
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
			{
				NeoDatis.Tool.DLogger.Debug("Deleting object with id " + header.GetOid() + " - In connected zone ="
					 + objectIsInConnectedZone + " -  with index =" + withIndex);
				NeoDatis.Tool.DLogger.Debug("position =  " + objectPosition + " | prev oid = " + 
					previousObjectOID + " | next oid = " + nextObjectOID);
			}
			bool isFirstObject = previousObjectOID == null;
			bool isLastObject = nextObjectOID == null;
			bool mustUpdatePreviousObjectPointers = false;
			bool mustUpdateNextObjectPointers = false;
			bool mustUpdateLastObjectOfCI = false;
			if (isFirstObject || isLastObject)
			{
				if (isFirstObject)
				{
					// The deleted object is the first, must update first instance
					// OID field of the class
					if (objectIsInConnectedZone)
					{
						// update first object oid of the class info in memory
						ci.GetCommitedZoneInfo().first = nextObjectOID;
					}
					else
					{
						// update first object oid of the class info in memory
						ci.GetUncommittedZoneInfo().first = nextObjectOID;
					}
					if (nextObjectOID != null)
					{
						// Update next object 'previous object oid' to null
						UpdatePreviousObjectFieldOfObjectInfo(nextObjectOID, null, objectIsInConnectedZone
							);
						mustUpdateNextObjectPointers = true;
					}
				}
				// It can be first and last
				if (isLastObject)
				{
					// The deleted object is the last, must update last instance
					// OID field of the class
					// update last object position of the class info in memory
					if (objectIsInConnectedZone)
					{
						// the object is a committed object
						ci.GetCommitedZoneInfo().last = previousObjectOID;
					}
					else
					{
						// The object is not committed and it is the last and is
						// being deleted
						ci.GetUncommittedZoneInfo().last = previousObjectOID;
					}
					if (previousObjectOID != null)
					{
						// Update 'next object oid' of previous object to null
						// if we are in unconnected zone, change can be done
						// directly,else it must be done in transaction
						UpdateNextObjectFieldOfObjectInfo(previousObjectOID, null, objectIsInConnectedZone
							);
						// Now update data of the cache
						mustUpdatePreviousObjectPointers = true;
						mustUpdateLastObjectOfCI = true;
					}
				}
			}
			else
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例5: UpdateNonNativeObjectInfo

		/// <summary>Updates an object.</summary>
		/// <remarks>
		/// Updates an object.
		/// <pre>
		/// Try to update in place. Only change what has changed. This is restricted to particular types (fixed size types). If in place update is
		/// not possible, then deletes the current object and creates a new at the end of the database file and updates
		/// OID object position.
		/// &#064;param object The object to be updated
		/// &#064;param forceUpdate when true, no verification is done to check if update must be done.
		/// &#064;return The oid of the object, as a negative number
		/// &#064;
		/// </remarks>
		public virtual NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi, bool forceUpdate)
		{
			nbCallsToUpdate++;
			bool hasObject = true;
			string message = null;
			object @object = nnoi.GetObject();
			NeoDatis.Odb.OID oid = nnoi.GetOid();
			if (@object == null)
			{
				hasObject = false;
			}
			// When there is index,we must *always* load the old meta representation
			// to compute index keys
			bool withIndex = !nnoi.GetClassInfo().GetIndexes().IsEmpty();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oldMetaRepresentation = 
				null;
			// Used to check consistency, at the end, the number of
			// nbConnectedObjects must and nbUnconnected must remain unchanged
			long nbConnectedObjects = nnoi.GetClassInfo().GetCommitedZoneInfo().GetNbObjects(
				);
			long nbNonConnectedObjects = nnoi.GetClassInfo().GetUncommittedZoneInfo().GetNbObjects
				();
			bool objectHasChanged = false;
			try
			{
				NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
				long positionBeforeWrite = fsi.GetPosition();
				NeoDatis.Odb.Core.Transaction.ITmpCache tmpCache = lsession.GetTmpCache();
				NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
				// Get header of the object (position, previous object position,
				// next
				// object position and class info position)
				// The header must be in the cache.
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader lastHeader = cache.GetObjectInfoHeaderFromOid
					(oid, true);
				if (lastHeader == null)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.UnexpectedSituation
						.AddParameter("Header is null in update"));
				}
				if (lastHeader.GetOid() == null)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
						.AddParameter("Header oid is null for oid " + oid));
				}
				bool objectIsInConnectedZone = cache.ObjectWithIdIsInCommitedZone(oid);
				long currentPosition = lastHeader.GetPosition();
				// When using client server mode, we must re-read the position of
				// the object with oid. Because, another session may
				// have updated the object, and in this case, the position of the
				// object in the cache may be invalid
				// TODO It should be done only when the object has been deleted or
				// updated by another session. Should check this
				// Doing this with new objects (created in the current session, the
				// last committed
				// object position will be negative, in this case we must use the
				// currentPosition
				if (!isLocalMode)
				{
					long lastCommitedObjectPosition = idManager.GetObjectPositionWithOid(oid, false);
					if (lastCommitedObjectPosition > 0)
					{
						currentPosition = lastCommitedObjectPosition;
					}
					// Some infos that come from the client are not set
					// So we overwrite them here : example : object version. Update
					// date is not important here
					// Because, as we are updating the object, the update date will
					// be updated too
					nnoi.GetHeader().SetObjectVersion(lastHeader.GetObjectVersion());
					nnoi.GetHeader().SetUpdateDate(lastHeader.GetUpdateDate());
				}
				// for client server
				if (nnoi.GetPosition() == -1)
				{
					nnoi.GetHeader().SetPosition(currentPosition);
				}
				if (currentPosition == -1)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InstancePositionIsNegative
						.AddParameter(currentPosition).AddParameter(oid).AddParameter("In Object Info Header"
						));
				}
				if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
				{
					message = DepthToSpaces() + "start updating object at " + currentPosition + ", oid="
						 + oid + " : " + (nnoi != null ? nnoi.ToString() : "null");
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例6: StoreObject

		/// <summary>
		/// Store a meta representation of an object(already as meta
		/// representation)in ODBFactory database.
		/// </summary>
		/// <remarks>
		/// Store a meta representation of an object(already as meta
		/// representation)in ODBFactory database.
		/// To detect if object must be updated or insert, we use the cache. To
		/// update an object, it must be first selected from the database. When an
		/// object is to be stored, if it exist in the cache, then it will be
		/// updated, else it will be inserted as a new object. If the object is null,
		/// the cache will be used to check if the meta representation is in the
		/// cache
		/// </remarks>
		/// <param name="oid">The oid of the object to be inserted/updates</param>
		/// <param name="nnoi">The meta representation of an object</param>
		/// <returns>The object position</returns>
		public virtual NeoDatis.Odb.OID StoreObject(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi)
		{
			// first detects if we must perform an insert or an update
			// If object is in the cache, we must perform an update, else an insert
			object @object = nnoi.GetObject();
			bool mustUpdate = false;
			NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
			if (@object != null)
			{
				NeoDatis.Odb.OID cacheOid = cache.IdOfInsertingObject(@object);
				if (cacheOid != null)
				{
					return cacheOid;
				}
				// throw new ODBRuntimeException("Inserting meta representation of
				// an object without the object itself is not yet supported");
				mustUpdate = cache.ExistObject(@object);
			}
			if (!mustUpdate)
			{
				mustUpdate = nnoi.GetOid() != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
					.NullObjectId;
			}
			// To enable auto - reconnect object loaded from previous sessions
			// auto reconnect is on
			if (!mustUpdate && NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession())
			{
				NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
					.GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
				if (crossSessionCache.ExistObject(@object))
				{
					storageEngine.Reconnect(@object);
					mustUpdate = true;
				}
			}
			if (mustUpdate)
			{
				return UpdateNonNativeObjectInfo(nnoi, false);
			}
			return InsertNonNativeObject(oid, nnoi, true);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:59,代码来源:AbstractObjectWriter.cs

示例7: ManageNewObjectPointers

		/// <summary>Updates pointers of objects, Only changes uncommitted info pointers</summary>
		/// <param name="objectInfo">The meta representation of the object being inserted</param>
		/// <param name="classInfo">The class of the object being inserted</param>
		/// <param name="position">The position where the object is being inserted @</param>
		private void ManageNewObjectPointers(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 objectInfo, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo classInfo, long position
			, NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel)
		{
			NeoDatis.Odb.Core.Transaction.ICache cache = storageEngine.GetSession(true).GetCache
				();
			bool isFirstUncommitedObject = !classInfo.GetUncommittedZoneInfo().HasObjects();
			// if it is the first uncommitted object
			if (isFirstUncommitedObject)
			{
				classInfo.GetUncommittedZoneInfo().first = objectInfo.GetOid();
				NeoDatis.Odb.OID lastCommittedObjectOid = classInfo.GetCommitedZoneInfo().last;
				if (lastCommittedObjectOid != null)
				{
					// Also updates the last committed object next object oid in
					// memory to connect the committed
					// zone with unconnected for THIS transaction (only in memory)
					NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = cache.GetObjectInfoHeaderFromOid
						(lastCommittedObjectOid, true);
					oih.SetNextObjectOID(objectInfo.GetOid());
					// And sets the previous oid of the current object with the last
					// committed oid
					objectInfo.SetPreviousInstanceOID(lastCommittedObjectOid);
				}
			}
			else
			{
				// Gets the last object, updates its (next object)
				// pointer to the new object and updates the class info 'last
				// uncommitted object
				// oid' field
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oip = classInfo.GetLastObjectInfoHeader
					();
				if (oip == null)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
						.AddParameter("last OIP is null in manageNewObjectPointers oid=" + objectInfo.GetOid
						()));
				}
				if (oip.GetNextObjectOID() != objectInfo.GetOid())
				{
					oip.SetNextObjectOID(objectInfo.GetOid());
					// Here we are working in unconnected zone, so this
					// can be done without transaction: actually
					// write in database file
					UpdateNextObjectFieldOfObjectInfo(oip.GetOid(), oip.GetNextObjectOID(), false);
					objectInfo.SetPreviousInstanceOID(oip.GetOid());
					// Resets the class info oid: In some case,
					// (client // server) it may be -1.
					oip.SetClassInfoId(classInfo.GetId());
					// object info oip has been changed, we must put it
					// in the cache to turn this change available for current
					// transaction until the commit
					storageEngine.GetSession(true).GetCache().AddObjectInfo(oip);
				}
			}
			// always set the new last object oid and the number of objects
			classInfo.GetUncommittedZoneInfo().last = objectInfo.GetOid();
			classInfo.GetUncommittedZoneInfo().IncreaseNbObjects();
			// Then updates the last info pointers of the class info
			// with this new created object
			// At this moment, the objectInfo.getHeader() do not have the
			// attribute ids.
			// but later in this code, the attributes will be set, so the class
			// info also will have them
			classInfo.SetLastObjectInfoHeader(objectInfo.GetHeader());
			// // Saves the fact that something has changed in the class (number of
			// objects and/or last object oid)
			storageEngine.GetSession(true).GetMetaModel().AddChangedClass(classInfo);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:74,代码来源:AbstractObjectWriter.cs


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