Exemplo n.º 1
0
        private void ProcessNestedQueries(IEnumerable <object[]> recordsReferenceValues)
        {
            if (recordsReferenceValues == null || _queryInfo == null)
            {
                if (_queryInfo != null)
                {
                    _queryInfo.FinishNestedQueriesProcess(0);
                }
                return;
            }
            var recordsCount = 0;

            int[] recordValuesPositions = GetRecordPositionsFromReferenceParameters();
            foreach (var refValues in recordsReferenceValues)
            {
                recordsCount++;
                IRecord referenceRecord = CreateRecordFromReferenceParameterValues(recordValuesPositions, refValues);
                foreach (var query in GetQueryInfos(refValues))
                {
                    IQueryResult result = null;
                    try
                    {
                        if (referenceRecord == null || query.CanExecute(referenceRecord))
                        {
                            result = _executer(query);
                        }
                        else
                        {
                            result = new QueryResult(new Record.RecordDescriptor("EmptyResult", new Record.Field[0]), new Record[0]);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (query.ExecuteObserver != null)
                        {
                            query.ExecuteObserver.Error(query, new QueryFailedInfo(QueryFailedReason.Error, ex.Message.GetFormatter(), ex));
                        }
                        return;
                    }
                    try
                    {
                        var values = new ReferenceParameterValueCollection();
                        if (_referenceParameters != null)
                        {
                            for (var i = 0; i < _referenceParameters.Length; i++)
                            {
                                values.Add(new ReferenceParameterValue(_referenceParameters[i].ColumnName, refValues[i]));
                            }
                        }
                        if (query.ExecuteObserver != null)
                        {
                            query.ExecuteObserver.Executed(query, values, result);
                        }
                    }
                    finally
                    {
                        if (result is IDisposable)
                        {
                            ((IDisposable)result).Dispose();
                        }
                        else
                        {
                            var enumerator = result.GetEnumerator();
                            while (enumerator != null && enumerator.MoveNext())
                            {
                                ;
                            }
                        }
                    }
                    _queryInfo.NotifyNestedQueryProcessed(query, recordsCount);
                }
                _queryInfo.FinishNestedQueriesRecordProcess(recordsCount);
            }
            if (_queryInfo != null)
            {
                _queryInfo.FinishNestedQueriesProcess(recordsCount);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="referenceValues"></param>
 /// <param name="result"></param>
 public SubQueryCallBackArgs(QueryInfo info, ReferenceParameterValueCollection referenceValues, IQueryResult result)
 {
     _info            = info;
     _referenceValues = referenceValues;
     _result          = result;
 }