public override long? GetQueryId( TemplateNodeInfo node, TemplateNodeQueryInfo templateNodeQuery, InstanceInfo instance, DateTime dateCreated, bool onlyFind ) { Int64? queryId = 0L; Debug.Assert(node.IsInstance); if (node.TemplateNodeId == null) { throw new InvalidOperationException(); } Int64? templateNodeQueryId = Storage.TemplateNodeQueryDirectory .GetId(node.ConnectionGroup, node.Template, templateNodeQuery); Int64? serverId = Storage.ServerInstanceDirectory .GetId(node.ConnectionGroup, instance); if (onlyFind) { Tuple<long, long, long> key = new Tuple<Int64, Int64, Int64>( (long) node.TemplateNodeId.Value, (long) templateNodeQueryId, (long) serverId ); return this.Cache.GetOrAdd( key, () => { ITableRow row = this.NewRow(); row.Values.Add(NodeInstanceIdFn, node.TemplateNodeId.Value); row.Values.Add(TemplateNodeQueryIdFn, templateNodeQueryId); row.Values.Add(ServerInstanceIdFn, serverId); queryId = this.GetRow(row); Log.InfoFormat("ServerId:'{0}';NodeInstanceId:'{1}';TemplateNodeQueryId:'{2}';PrimaryKey:'{3}'", serverId, node.TemplateNodeId.Value, templateNodeQueryId, queryId ); return queryId; } ); } List<Field> customFields = new List<Field> { this.CreateField(DefaultDatabaseNameFn, node.GetDefaultDatabase()), this.CreateField(TableDefinition.DateCreated, dateCreated), this.CreateField(NodeInstanceIdFn, node.TemplateNodeId.GetValueOrDefault()), this.CreateField(TemplateNodeQueryIdFn, templateNodeQueryId), this.CreateField(ServerInstanceIdFn, serverId) }; queryId = this.GetRecordIdByFields(customFields.ToArray()); Log.InfoFormat("ServerId:'{0}';NodeInstanceId:'{1}';TemplateNodeQueryId:'{2}';id:'{3}'", serverId, node.TemplateNodeId.GetValueOrDefault(), templateNodeQueryId, queryId ); return queryId; }