Пример #1
0
		/// <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);
			}
		}
Пример #2
0
		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;
		}