private TemplateNodeResultItem ReadTemplateNodeResult(TemplateNodeQueryInfo templateNodeQueryInfo, MultyQueryResultInfo result) { var queryResult = new QueryResultInfo(); List <QueryInfo> queries = MsSqlAuditor.GetQueryByTemplateNodeQueryInfo(templateNodeQueryInfo); // looking for user settings for parameter values templateNodeQueryInfo.ReadParametersFrom(Settings); string connectionsSelectId = templateNodeQueryInfo.ConnectionsSelectId; if (connectionsSelectId != null) { foreach (InstanceInfo instance in this._instances) { Int64?queryId = Storage.QueryDirectory.GetQueryId( templateNodeQueryInfo.TemplateNode, templateNodeQueryInfo, instance, DateTime.Now, false ); if (queryId.HasValue) { List <DynamicConnection> connections = new List <DynamicConnection>( Storage.DynamicConnectionDirectory.ReadConnections(queryId.Value) ); foreach (DynamicConnection connection in connections) { if (!connection.QueryId.HasValue) { continue; } Int64 dynamicQueryId = connection.QueryId.Value; QuerySource sourceType; if (!Enum.TryParse(connection.Type, true, out sourceType)) { _log.ErrorFormat( @"Unknown ConnectionType:'{0}'", connection.Type ?? "<Null>" ); sourceType = QuerySource.MSSQL; } InstanceInfo selectConnectionInstance = InstanceInfoResolver.ResolveDynamicInstance( connection.Name, sourceType, connection.IsOdbc ); selectConnectionInstance.ConnectionGroup = instance.ConnectionGroup; selectConnectionInstance.LoadServerProperties(Storage); QueryInstanceResultInfo instanceResult = GetInstanceResult( result, selectConnectionInstance, dynamicQueryId, templateNodeQueryInfo, queries ); if (instanceResult != null) { queryResult.AddInstanceResult(instanceResult); } } } } } else { foreach (InstanceInfo instance in this._instances) { Int64?queryId = Storage.QueryDirectory.GetQueryId( base.TemplateNode, templateNodeQueryInfo, instance, new DateTime(), true ); if (queryId != null) { QueryInstanceResultInfo instanceResult = GetInstanceResult( result, instance, queryId.Value, templateNodeQueryInfo, queries ); if (instanceResult != null) { queryResult.AddInstanceResult(instanceResult); } } } } Tuple <DateTime?, DateTime?> dateTimes = Storage.NodeInstances.GetTreeNodeLastUpdateAndDuration(base.TemplateNode); result.NodeLastUpdated = dateTimes.Item1; result.NodeLastUpdateDuration = dateTimes.Item2; return(new TemplateNodeResultItem(templateNodeQueryInfo, queryResult)); }