Пример #1
0
 public FilterInfo(FilterSpec filterSpec, ColumnDescriptor columnDescriptor, ColumnDescriptor collectionColumn)
 {
     FilterSpec = filterSpec;
     ColumnDescriptor = columnDescriptor;
     CollectionColumn = collectionColumn;
     try
     {
         Predicate = MakePredicate();
     }
     catch (Exception e)
     {
         Error = e.Message;
     }
 }
Пример #2
0
        //public void AddFilters(Type type, Dictionary<string, object> clauses, RouteData rd)
        //{
        //    List<string> specialQueryParams = type.GetProperties().Select(pi => pi.Name).ToList();
        //    var qb = QueryBuilderFactory.Instance.Create();
        //    rd.DataTokens
        //        .Where(dt => specialQueryParams.Any(sqp => sqp == dt.Key || dt.Key.StartsWith(sqp + ".")))
        //        .Select(dt => new KeyValuePair<string, object>(
        //}

        public List <object> GetList(Type type, RouteData rd)
        {
            var        clauses    = new Dictionary <string, object>();
            PagingSpec pagingSpec = PagingSpec.Create(rd);

            if (pagingSpec != null)
            {
                clauses.Add("@Paging", pagingSpec);
            }
            FilterSpec filterSpec = FilterSpec.Create(type, rd);

            if (filterSpec != null)
            {
                filterSpec.AddFilterClauses(clauses);
            }
            List <object> res = GetList(type, clauses);

            if (res != null && res.Count > 0 && res[0].GetType() == typeof(PagingSpec))
            {
                rd.DataTokens.Add("@Paging", res[0]);
                res.RemoveAt(0);
            }
            return(res);
        }
Пример #3
0
        public ViewableActivationResult Activate(
            AgentInstanceContext agentInstanceContext,
            bool isSubselect,
            bool isRecoveringResilient)
        {
            FilterValueSetParam[][] addendum = null;
            if (agentInstanceContext.AgentInstanceFilterProxy != null) {
                addendum = agentInstanceContext.AgentInstanceFilterProxy.GetAddendumFilters(
                    FilterSpec,
                    agentInstanceContext);
            }

            var filterValues = FilterSpec.GetValueSet(
                null,
                addendum,
                agentInstanceContext,
                agentInstanceContext.StatementContextFilterEvalEnv);

            EventStream theStream;
            if (!agentInstanceContext.AuditProvider.Activated() &&
                !agentInstanceContext.InstrumentationProvider.Activated()) {
                theStream = CanIterate
                    ? new ZeroDepthStreamIterable(FilterSpec.ResultEventType)
                    : (EventStream) new ZeroDepthStreamNoIterate(FilterSpec.ResultEventType);
            }
            else {
                var streamNum = StreamNumFromClause ?? -1;
                theStream = CanIterate
                    ? new ZeroDepthStreamIterableWAudit(
                        FilterSpec.ResultEventType,
                        agentInstanceContext,
                        FilterSpec,
                        streamNum,
                        isSubselect,
                        SubselectNumber)
                    : (EventStream) new ZeroDepthStreamNoIterateWAudit(
                        FilterSpec.ResultEventType,
                        agentInstanceContext,
                        FilterSpec,
                        streamNum,
                        isSubselect,
                        SubselectNumber);
            }

            var statementId = agentInstanceContext.StatementId;
            FilterHandleCallback filterCallback;
            if (FilterSpec.OptionalPropertyEvaluator == null) {
                filterCallback = new ProxyFilterHandleCallback {
                    ProcMatchFound = (
                        theEvent,
                        allStmtMatches) => theStream.Insert(theEvent),

                    ProcIsSubselect = () => IsSubSelect
                };
            }
            else {
                filterCallback = new ProxyFilterHandleCallback {
                    ProcMatchFound = (
                        theEvent,
                        allStmtMatches) => {
                        var result = FilterSpec.OptionalPropertyEvaluator.GetProperty(theEvent, agentInstanceContext);
                        if (result == null) {
                            return;
                        }

                        theStream.Insert(result);
                    },

                    ProcIsSubselect = () => IsSubSelect
                };
            }

            var filterHandle = new EPStatementHandleCallbackFilter(
                agentInstanceContext.EpStatementAgentInstanceHandle,
                filterCallback);
            agentInstanceContext.StatementContext.StatementContextRuntimeServices.FilterService.Add(
                FilterSpec.FilterForEventType,
                filterValues,
                filterHandle);
            var filterStopCallback = new ViewableActivatorFilterStopCallback(Container, filterHandle, FilterSpec);
            return new ViewableActivationResult(theStream, filterStopCallback, null, false, false, null, null);
        }