本文整理汇总了C#中sones.Library.Commons.Transaction.TransactionToken类的典型用法代码示例。如果您正苦于以下问题:C# TransactionToken类的具体用法?C# TransactionToken怎么用?C# TransactionToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionToken类属于sones.Library.Commons.Transaction命名空间,在下文中一共展示了TransactionToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecFunc
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
{
if (myCallingObject is IHyperEdge)
{
return new FuncParameter((UInt64)((IHyperEdge)myCallingObject).GetAllEdges().Count());
}
else if (myCallingObject is ISingleEdge)
{
UInt64 count = 1;
return new FuncParameter(count);
}
else if (myCallingObject is IncomingEdgeCollection)
{
return new FuncParameter((UInt64)(myCallingObject as IncomingEdgeCollection).LongCount());
}
else if (myCallingObject is IEnumerable<long>)
{
return new FuncParameter((UInt64)(myCallingObject as IEnumerable<long>).LongCount());
}
else if (myCallingObject is IEnumerable<IVertex>)
{
return new FuncParameter((UInt64)(myCallingObject as IEnumerable<IVertex>).LongCount());
}
else
{
throw new UnknownDBException("Unexpected input for COUNT aggregate.");
}
}
示例2: Execute
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
{
_query = myQuery;
var vertexType = myGraphDB.GetVertexType<IVertexType>(
mySecurityToken,
myTransactionToken,
new RequestGetVertexType(_typeName),
(stats, vType) => vType);
_WhereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);
var expressionGraph = _WhereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken,
myTransactionToken,
new CommonUsageGraph(myGraphDB, mySecurityToken,
myTransactionToken));
var toBeDeletedVertices =
expressionGraph.Select(
new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken),
null, true);
//TODO: do sth that is better than that: ew RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).
return myGraphDB.Delete<QueryResult>(
mySecurityToken,
myTransactionToken,
new RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).AddAttributes(_toBeDeletedAttributes),
CreateQueryResult);
}
示例3: ExecFunc
/// <summary>
/// Executes the function on myCallingObject
/// </summary>
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
{
var currentInnerEdgeType = ((IOutgoingEdgeDefinition)myAttributeDefinition).InnerEdgeType;
if (myCallingObject is IHyperEdge && currentInnerEdgeType.HasProperty("Weight"))
{
var hyperEdge = myCallingObject as IHyperEdge;
if (currentInnerEdgeType.HasProperty("Weight"))
{
var weightProperty = currentInnerEdgeType.GetPropertyDefinition("Weight");
var maxWeight = hyperEdge.InvokeHyperEdgeFunc<Double>(singleEdges =>
{
return Convert.ToDouble(
weightProperty.GetValue(
singleEdges
.OrderByDescending(edge => weightProperty.GetValue(edge))
.First()));
});
return new FuncParameter(maxWeight);
}
}
throw new InvalidTypeException(myCallingObject.GetType().ToString(), "Weighted IHyperEdge");
}
示例4: ExecFunc
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
{
if (!(myCallingObject is String))
{
throw new FunctionParameterTypeMismatchException(typeof(String), myCallingObject.GetType());
}
var pos = Convert.ToInt32(myParams[0].Value);
StringBuilder resString = new StringBuilder();
bool dontInsert = false;
if (pos > (myCallingObject as String).Length)
{
dontInsert = true;
resString.Append((myCallingObject as String).ToString());
}
else
{
resString.Append((myCallingObject as String).ToString().Substring(0, pos));
}
foreach (FuncParameter fp in myParams.Skip(1))
{
resString.Append(fp.Value as String);
}
if(!dontInsert)
resString.Append((myCallingObject as String).ToString().Substring(pos));
return new FuncParameter(resString.ToString());
}
示例5: GetResult
public override QueryResult GetResult(
GQLPluginManager myPluginManager,
IGraphDB myGraphDB,
SecurityToken mySecurityToken,
TransactionToken myTransactionToken)
{
var resultingVertices = new List<IVertexView>();
ASonesException error = null;
#region Specific index
var request = new RequestDescribeIndex(_TypeName, _IndexName, _IndexEdition);
var indices = myGraphDB.DescribeIndex<IEnumerable<IIndexDefinition>>(mySecurityToken, myTransactionToken, request, (stats, definitions) => definitions);
if (indices == null)
{
error = new IndexTypeDoesNotExistException(_TypeName, _IndexName);
}
if (String.IsNullOrEmpty(_IndexEdition))
{
//_IndexEdition = DBConstants.DEFAULTINDEX;
}
resultingVertices = new List<IVertexView>() { GenerateOutput(indices, _IndexName) };
#endregion
if(error != null)
return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Failed, resultingVertices, error);
else
return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Successful, resultingVertices);
}
示例6: Execute
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
{
Query = myQuery;
var indexDef = new IndexPredefinition(_IndexName);
indexDef.SetIndexType(_IndexType);
indexDef.SetVertexType(_DBType);
indexDef.SetEdition(_IndexEdition);
//to be indices attributes
foreach (var aIndexedProperty in _AttributeList)
{
indexDef.AddProperty(aIndexedProperty.IndexAttribute.ContentString);
}
//options for the index
if (_options != null)
{
foreach (var aKV in _options)
{
indexDef.AddOption(aKV.Key, aKV.Value);
}
}
return myGraphDB.CreateIndex<QueryResult>(mySecurityToken, myTransactionToken, new RequestCreateIndex(indexDef), GenerateResult);
}
示例7: AddVertex
public IVertex AddVertex(RequestInsertVertex myInsertDefinition, TransactionToken myTransaction, SecurityToken mySecurity)
{
IVertexType vertexType = GetVertexType(myInsertDefinition.VertexTypeName, myTransaction, mySecurity);
if (vertexType.IsAbstract)
throw new AbstractConstraintViolationException(myInsertDefinition.VertexTypeName);
ConvertUnknownProperties(myInsertDefinition, vertexType);
ConvertDefaultValues(myInsertDefinition, vertexType);
if (myInsertDefinition.OutgoingEdges != null)
CheckOutgoingEdges(myInsertDefinition.OutgoingEdges, vertexType);
if (myInsertDefinition.StructuredProperties != null)
{
CheckAddStructuredProperties(myInsertDefinition.StructuredProperties, vertexType);
}
CheckMandatoryConstraint(myInsertDefinition, vertexType);
if (myInsertDefinition.BinaryProperties != null)
CheckAddBinaryProperties(myInsertDefinition, vertexType);
return null;
}
示例8: CreateQueryPlan
/// <summary>
/// Creates a query plan using a logic expression
/// </summary>
/// <param name="myExpression">The logic expression</param>
/// <param name="myIsLongRunning">Determines whether it is anticipated that the request could take longer</param>
/// <param name="myTransaction">The current transaction token</param>
/// <param name="mySecurity">The current security token</param>
/// <returns>A query plan</returns>
public IQueryPlan CreateQueryPlan(IExpression myExpression, Boolean myIsLongRunning, TransactionToken myTransaction, SecurityToken mySecurity)
{
IQueryPlan result;
switch (myExpression.TypeOfExpression)
{
case TypeOfExpression.Binary:
result = GenerateFromBinaryExpression((BinaryExpression) myExpression, myIsLongRunning, myTransaction, mySecurity);
break;
case TypeOfExpression.Unary:
result = GenerateFromUnaryExpression((UnaryExpression)myExpression, myTransaction, mySecurity);
break;
case TypeOfExpression.Property:
result = GenerateFromPropertyExpression((PropertyExpression)myExpression, myTransaction, mySecurity);
break;
default:
throw new ArgumentOutOfRangeException();
}
return result;
}
示例9: Execute
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
{
var sw = Stopwatch.StartNew();
QueryResult result = null;
if (_DumpFormat.ToString().ToUpper().Equals("GQL"))
{
var plugin = myPluginManager.GetAndInitializePlugin<IGraphDBExport>("GQLEXPORT");
if (plugin != null)
{
result = plugin.Export(_DumpDestination, _DumpableGrammar, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, _TypesToDump, _DumpType);
}
}
sw.Stop();
if (result != null)
{
return new QueryResult(myQuery, _DumpFormat.ToString(), (ulong)sw.ElapsedMilliseconds, result.TypeOfResult, result.Vertices, result.Error);
}
else
return null;
}
示例10: CommonUsageGraph
/// <summary>
/// Constructor
/// </summary>
public CommonUsageGraph(IGraphDB myIGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
: this()
{
_iGraphDB = myIGraphDB;
_securityToken = mySecurityToken;
_transactionToken = myTransactionToken;
_Levels = new Dictionary<int, IExpressionLevel>();
}
示例11: LevelKey
public LevelKey(IEnumerable<EdgeKey> myEdgeKey, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
{
Edges = new List<EdgeKey>();
foreach (var aEdgeKey in myEdgeKey)
{
if (aEdgeKey.IsAttributeSet)
{
var vertexType = myGraphDB.GetVertexType<IVertexType>
(mySecurityToken,
myTransactionToken,
new RequestGetVertexType(aEdgeKey.VertexTypeID),
(stats, type) => type);
var attribute = vertexType.GetAttributeDefinition(aEdgeKey.AttributeID);
if (attribute != null && attribute.Kind != AttributeType.Property)
{
//so there is an edge
Edges.Add(aEdgeKey);
Level++;
AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);
}
else
{
if (Level == 0)
{
var newEdgeKey = new EdgeKey(aEdgeKey.VertexTypeID);
Edges.Add(newEdgeKey);
AddHashCodeFromSingleEdge(ref _hashcode, newEdgeKey);
break;
}
else
{
break;
}
}
}
else
{
if (Level == 0)
{
Edges.Add(aEdgeKey);
AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);
break;
}
else
{
break;
}
}
}
}
示例12: Execute
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
{
_query = myQuery;
return myGraphDB.AlterVertexType<QueryResult>(
mySecurityToken,
myTransactionToken,
CreateNewRequest(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken),
CreateOutput);
}
示例13: AddVertexTypes
public override IEnumerable<IVertexType> AddVertexTypes(IEnumerable<VertexTypePredefinition> myVertexTypeDefinitions, TransactionToken myTransaction, SecurityToken mySecurity)
{
#region check arguments
myVertexTypeDefinitions.CheckNull("myVertexTypeDefinitions");
#endregion
CheckAdd(myVertexTypeDefinitions);
return null;
}
示例14: ExecFunc
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
{
if (myCallingObject is String)
{
return new FuncParameter(((String)myCallingObject).ToLower());
}
else
{
throw new FunctionParameterTypeMismatchException(typeof(String), myCallingObject.GetType());
}
}
示例15: Import
public QueryResult Import(String myLocation, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable<string> myComments = null, UInt64? myOffset = null, UInt64? myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent)
{
ASonesException error;
Stream stream = null;
QueryResult result;
#region Read querie lines from location
try
{
#region file
if (myLocation.ToLower().StartsWith(@"file:\\"))
{
//lines = ReadFile(location.Substring(@"file:\\".Length));
stream = GetStreamFromFile(myLocation.Substring(@"file:\\".Length));
}
#endregion
#region http
else if (myLocation.ToLower().StartsWith("http://"))
{
stream = GetStreamFromHttp(myLocation);
}
#endregion
else
{
error = new InvalidImportLocationException(myLocation, @"file:\\", "http://");
result = new QueryResult("", ImportFormat, 0L, ResultType.Failed, null, error);
return result;
}
#region Start import using the AGraphDBImport implementation and return the result
return Import(stream, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, myParallelTasks, myComments, myOffset, myLimit, myVerbosityType);
#endregion
}
catch (Exception ex)
{
#region throw new exception
error = new ImportFailedException(ex);
result = new QueryResult("", ImportFormat, 0L, ResultType.Failed, null, error);
return result;
#endregion
}
finally
{
if (stream != null)
{
stream.Dispose();
}
}
#endregion
}