本文整理汇总了C#中NeoDatis.GetBaseIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C# NeoDatis.GetBaseIdentifier方法的具体用法?C# NeoDatis.GetBaseIdentifier怎么用?C# NeoDatis.GetBaseIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeoDatis
的用法示例。
在下文中一共展示了NeoDatis.GetBaseIdentifier方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: ManageStoreCommand
/// <summary>manage the store command.</summary>
/// <remarks>
/// manage the store command. The store command can be an insert(oid==null)
/// or an update(oid!=null)
/// If insert get the base mutex IF update, first get the mutex of the oid to
/// update then get the base mutex, to avoid dead lock in case of concurrent
/// update.
/// </remarks>
/// <param name="message"></param>
/// <returns></returns>
private NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Message ManageStoreCommand(
NeoDatis.Odb.Core.Server.Message.StoreMessage message)
{
// Gets the base identifier
string baseIdentifier = message.GetBaseIdentifier();
NeoDatis.Odb.Core.Server.Connection.ConnectionManager connectionManager = null;
NeoDatis.Odb.Core.Server.Connection.IConnection connection = null;
NeoDatis.Tool.Mutex.Mutex mutex = null;
NeoDatis.Odb.OID oid = message.GetNnoi().GetOid();
try
{
// 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.StoreMessageResponse(baseIdentifier,
message.GetConnectionId(), buffer.ToString());
}
connection = connectionManager.GetConnection(message.GetConnectionId());
NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
)sessionManager.GetSession(baseIdentifier, true);
NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connection.GetStorageEngine
();
session.SetClientIds(message.GetClientIds());
bool objectIsNew = oid == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.NullObjectId;
if (objectIsNew)
{
connection.SetCurrentAction(NeoDatis.Odb.Core.Server.Connection.ConnectionAction.
ActionInsert);
mutex = NeoDatis.Tool.Mutex.MutexFactory.Get(baseIdentifier).Acquire("store");
oid = engine.WriteObjectInfo(NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.NullObjectId, message.GetNnoi(), NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
.PositionNotInitialized, false);
}
else
{
connection.SetCurrentAction(NeoDatis.Odb.Core.Server.Connection.ConnectionAction.
ActionUpdate);
// If object is not new, ODB is going to execute an Update.
// Here we must lock the object with the oid to avoid a
// concurrent update
// This is done by creating a special mutex with the base
// identifier and the oid.
// This mutex will be kept in the connection and only released
// when committing
// or rollbacking the connection
connection.LockObjectWithOid(oid);
// If object lock is ok, then get the mutex of the database
mutex = NeoDatis.Tool.Mutex.MutexFactory.Get(baseIdentifier).Acquire("store");
// If oid is not -1, the object already exist, we must update
oid = engine.UpdateObject(message.GetNnoi(), false);
}
return new NeoDatis.Odb.Core.Server.Message.StoreMessageResponse(baseIdentifier,
message.GetConnectionId(), oid, objectIsNew, message.GetClientIds(), session.GetServerIds
());
}
catch (System.Exception e)
{
if (oid != null)
{
try
{
connection.UnlockObjectWithOid(message.GetNnoi().GetOid());
}
catch (System.Exception e1)
{
NeoDatis.Tool.DLogger.Error("Error while unlocking object with oid " + oid + " : "
+ NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e1, true));
}
}
string se = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false);
string msg = baseIdentifier + ":Error while storing object " + message.GetNnoi();
NeoDatis.Tool.DLogger.Error(msg, e);
return new NeoDatis.Odb.Core.Server.Message.StoreMessageResponse(baseIdentifier,
message.GetConnectionId(), msg + ":\n" + se);
}
finally
{
if (mutex != null)
{
mutex.Release("store");
}
connection.EndCurrentAction();
}
}
示例3: ManageCheckMetaModelCompatibilityCommand
ManageCheckMetaModelCompatibilityCommand(NeoDatis.Odb.Core.Server.Message.CheckMetaModelCompatibilityMessage
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;
try
{
// 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.CheckMetaModelCompatibilityMessageResponse
(baseIdentifier, message.GetConnectionId(), buffer.ToString());
}
connection = connectionManager.GetConnection(message.GetConnectionId());
NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
)sessionManager.GetSession(baseIdentifier, true);
NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connection.GetStorageEngine
();
System.Collections.Generic.IDictionary<string, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
> currentCIs = message.GetCurrentCIs();
NeoDatis.Odb.Core.Layers.Layer3.Engine.CheckMetaModelResult result = engine.CheckMetaModelCompatibility
(currentCIs);
NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel updatedMetaModel = null;
if (result.IsModelHasBeenUpdated())
{
updatedMetaModel = session.GetMetaModel().Duplicate();
}
// If meta model has been updated, returns it to clients
return new NeoDatis.Odb.Core.Server.Message.CheckMetaModelCompatibilityMessageResponse
(baseIdentifier, message.GetConnectionId(), result, updatedMetaModel);
}
catch (System.Exception e)
{
NeoDatis.Tool.DLogger.Error(baseIdentifier + ":Server error while closing", e);
return new NeoDatis.Odb.Core.Server.Message.CheckMetaModelCompatibilityMessageResponse
(baseIdentifier, message.GetConnectionId(), NeoDatis.Tool.Wrappers.OdbString.ExceptionToString
(e, false));
}
}
示例4: ManageCountCommand
private NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Message ManageCountCommand(
NeoDatis.Odb.Core.Server.Message.CountMessage 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.Tool.Mutex.Mutex mutex = null;
try
{
mutex = NeoDatis.Tool.Mutex.MutexFactory.Get(baseIdentifier).Acquire("count");
// 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());
NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connection.GetStorageEngine
();
NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = message.GetCriteriaQuery
();
long nbObjects = engine.Count(query);
return new NeoDatis.Odb.Core.Server.Message.CountMessageResponse(baseIdentifier,
message.GetConnectionId(), nbObjects);
}
catch (System.Exception e)
{
string se = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false);
string msg = baseIdentifier + ":Error while counting objects for " + message.GetCriteriaQuery
();
NeoDatis.Tool.DLogger.Error(msg, e);
return new NeoDatis.Odb.Core.Server.Message.CountMessageResponse(baseIdentifier,
message.GetConnectionId(), msg + ":\n" + se);
}
finally
{
if (mutex != null)
{
mutex.Release("count");
}
}
}