/// <summary> /// The execute query simple. /// </summary> /// <param name="query">The query.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="version">The version.</param> /// <param name="progress">The progress.</param> /// <param name="groups">The groups.</param> /// <returns> /// The <see cref="QueryInstanceResultInfo" />. /// </returns> public QueryInstanceResultInfo ExecuteQuerySimple( QueryInfo query, QueryExecutionParams parameters, InstanceVersion version, ProgressItem progress, params GroupDefinition[] groups ) { // Log.InfoFormat("73:query:'{0}'", // query // ); QueryInstanceResultInfo result = new QueryInstanceResultInfo(this.Instance); QueryItemInfo queryItem = query.Items.GetQueryItemForVersion(version); this.PrepareProgress(progress, groups); this.ExecuteQuery( query, parameters, progress, groups, result, queryItem ); return result; }
/// <summary> /// The execute query simple. /// </summary> /// <param name="query">The query.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="version">The version.</param> /// <param name="progress">The progress.</param> /// <param name="groups">The groups.</param> /// <returns> /// The <see cref="QueryInstanceResultInfo" />. /// </returns> public QueryInstanceResultInfo ExecuteQuerySimple( QueryInfo query, QueryExecutionParams parameters, InstanceVersion version, ProgressItem progress, params GroupDefinition[] groups ) { // Log.InfoFormat("73:query:'{0}'", // query // ); QueryInstanceResultInfo result = new QueryInstanceResultInfo(this.Instance); QueryItemInfo queryItem = query.Items.GetQueryItemForVersion(version); this.PrepareProgress(progress, groups); this.ExecuteQuery( query, parameters, progress, groups, result, queryItem ); return(result); }
/// <summary> /// The process group. /// </summary> /// <param name="query">The query.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="result">The result.</param> /// <param name="queryItem">The query item.</param> /// <param name="group">The group.</param> /// <param name="subProgress">The sub progress.</param> protected virtual void ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, QueryInstanceResultInfo result, QueryItemInfo queryItem, GroupDefinition group, ProgressItem subProgress ) { // Log.InfoFormat("146:query:'{0}'", // query // ); var qr = this.ExecuteQueryItemFunction.Invoke( this.Instance, queryItem, string.IsNullOrWhiteSpace(group.Name) ? parameters.DefaultDatabase : group.Name, //group.Name, group.Id, query.Parameters, parameters.Values.ToList(), subProgress ); // костыль. Наверное, прибъется вообще после убиения "групп" qr.Database = group.Name; result.AddDatabaseResult(qr); }
/// <summary> /// The execute query. /// </summary> /// <param name="query">The query info.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="version">The version.</param> /// <param name="progress">The progress.</param> /// <returns> /// The <see cref="QueryInstanceResultInfo" />. /// </returns> public QueryInstanceResultInfo ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, InstanceVersion version, ProgressItem progress ) { // Log.InfoFormat("107:query:'{0}'", // query // ); var groups = this .GetGroupsResolver() .GetGroups(query, parameters.Values, version); return(this.ExecuteQuerySimple( query, parameters, version, progress, groups.ToArray() )); }
/// <inheritdoc /> protected override void ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, QueryInstanceResultInfo result, QueryItemInfo queryItem, GroupDefinition group, ProgressItem subProgress ) { var tempValues = new List <ParameterValue>(parameters.Values); foreach (var parameter in group.GroupParameters) { tempValues.Add(new ParameterValue { Name = "@" + parameter.Key, StringValue = parameter.Value } ); } QueryDatabaseResultInfo databaseResult = this.ExecuteQueryItemFunction.Invoke( this.Instance, queryItem, null, null, query.Parameters, tempValues, subProgress ); databaseResult.Database = group.Name; databaseResult.DatabaseId = group.Id; result.AddDatabaseResult(databaseResult); }
/// <inheritdoc /> protected override void ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, QueryInstanceResultInfo result, QueryItemInfo queryItem, GroupDefinition group, ProgressItem subProgress ) { var tempValues = new List<ParameterValue>(parameters.Values); foreach (var parameter in group.GroupParameters) { tempValues.Add(new ParameterValue { Name = "@" + parameter.Key, StringValue = parameter.Value } ); } QueryDatabaseResultInfo databaseResult = this.ExecuteQueryItemFunction.Invoke( this.Instance, queryItem, null, null, query.Parameters, tempValues, subProgress ); databaseResult.Database = group.Name; databaseResult.DatabaseId = group.Id; result.AddDatabaseResult(databaseResult); }
/// <summary> /// The execute query. /// </summary> /// <param name="query">The query.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="progress">The progress.</param> /// <param name="groups">The groups.</param> /// <param name="result">The result.</param> /// <param name="queryItem">The query item.</param> private void ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, ProgressItem progress, GroupDefinition[] groups, QueryInstanceResultInfo result, QueryItemInfo queryItem ) { // Log.InfoFormat("query:'{0}'", // query // ); Debug.Assert(groups.Length <= 1); if (groups.Length == 0) { this.ExecuteQuery( query, parameters, result, queryItem, new GroupDefinition( this.Instance, string.Empty, string.Empty ), progress ); ProgressComplete(progress); } else { foreach (var group in groups) { if (group.ChildGroups.Count > 0) { var tempParams = parameters.Clone(); tempParams.AddValues( this.GetGroupsResolver().GetParametersFromDefinition(group) ); this.ExecuteQuery( query, tempParams, progress, group.ChildGroups.ToArray(), result, queryItem ); } ProgressItem subProgress = null; if (progress != null) { try { subProgress = progress.GetChild(); } catch (Exception) { } } this.ExecuteQuery( query, parameters, result, queryItem, @group, subProgress ); ProgressComplete(subProgress); } } }
/// <summary> /// The execute query. /// </summary> /// <param name="query">The query info.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="version">The version.</param> /// <param name="progress">The progress.</param> /// <returns> /// The <see cref="QueryInstanceResultInfo" />. /// </returns> public QueryInstanceResultInfo ExecuteQuery( QueryInfo query, QueryExecutionParams parameters, InstanceVersion version, ProgressItem progress ) { // Log.InfoFormat("107:query:'{0}'", // query // ); var groups = this .GetGroupsResolver() .GetGroups(query, parameters.Values, version); return this.ExecuteQuerySimple( query, parameters, version, progress, groups.ToArray() ); }
/// <summary> /// The execute query. /// </summary> /// <param name="instance">The instance.</param> /// <param name="query">The query.</param> /// <param name="parameterValues">The parameter values.</param> /// <param name="progress">The progress.</param> /// <returns> /// The <see cref="QueryInstanceResultInfo" />. /// </returns> private QueryInstanceResultInfo ExecuteQuery( InstanceInfo instance, QueryInfo query, QueryExecutionParams parameters, ProgressItem progress = null ) { try { var factory = new QueryExecutorFactory(instance, this.ExecuteQueryItem, this.ExecuteSql); CurrentStorage storage = this._model.GetVaultProcessor( instance.ConnectionGroup).CurrentStorage; ServerProperties props = instance.InitServerProperties(storage); return factory .GetExecutor(query.Scope) .ExecuteQuery(query, parameters, props.Version, progress); } catch (OperationCanceledException ex) { return new QueryInstanceResultInfo(new ErrorInfo(ex), instance); } catch (Exception ex) { if (instance.IsEnabled && !ex.Data.Contains("IgnoreLog")) { log.Error(query.ToString(), ex); } if (progress != null) { progress.SetProgressCanceled(); } return new QueryInstanceResultInfo(new ErrorInfo(ex), instance); } }
private QueryResultInfo ExecuteQuery( ConnectionGroupInfo connectionGroupInfo, List<QueryInfo> queries, QueryExecutionParams parameters, int maxthreadCount, ProgressItem progress = null ) { var result = new QueryResultInfo(); List<InstanceInfo> connections = connectionGroupInfo.Connections; if (progress != null) { progress.SetPromisedChildCount(connections.Count); } ParallelOptions op = new ParallelOptions { MaxDegreeOfParallelism = (maxthreadCount == 0 ? Int32.MaxValue : maxthreadCount) }; Parallel.ForEach(connections, op, (connection) => { var query = queries.FirstOrDefault(x => x.Source == (connection.Type) || x.Source == QuerySource.SQLite); if (query != null) { ProgressItem subProgress = null; if (progress != null) { subProgress = progress.GetChild(); } result.AddInstanceResult(ExecuteQuery(connection, query, parameters, subProgress)); } }); return result; }
private QueryResultInfo ExecuteQuery( GroupDefinition groupDefinition, QueryInfo query, QueryExecutionParams parameters, ProgressItem progress = null ) { QueryResultInfo queryResult = new QueryResultInfo(); InstanceInfo instance = groupDefinition.Instance; QueryExecutorFactory factory = new QueryExecutorFactory( instance, this.ExecuteQueryItem, this.ExecuteSql ); BaseQueryExecutor executor = factory.GetExecutor( query.Scope ); CurrentStorage storage = this._model.GetVaultProcessor( instance.ConnectionGroup).CurrentStorage; ServerProperties props = instance.InitServerProperties(storage); QueryInstanceResultInfo instanceResult = executor.ExecuteQuerySimple( query, parameters, props.Version, progress, groupDefinition ); queryResult.AddInstanceResult(instanceResult); return queryResult; }