Esempio n. 1
0
        public static EventBean[] HandleDistintAndInsert(
            EventBean[] newData,
            InfraOnSelectViewFactory parent,
            AgentInstanceContext agentInstanceContext,
            TableInstance tableInstanceInsertInto,
            bool audit)
        {
            if (parent.IsDistinct) {
                newData = EventBeanUtility.GetDistinctByProp(newData, parent.DistinctKeyGetter);
            }

            if (tableInstanceInsertInto != null) {
                if (newData != null) {
                    foreach (EventBean aNewData in newData) {
                        tableInstanceInsertInto.AddEventUnadorned(aNewData);
                    }
                }
            }
            else if (parent.IsInsertInto) {
                if (newData != null) {
                    foreach (EventBean aNewData in newData) {
                        if (audit) {
                            agentInstanceContext.AuditProvider.Insert(aNewData, agentInstanceContext);
                        }

                        agentInstanceContext.InternalEventRouter.Route(
                            aNewData,
                            agentInstanceContext,
                            parent.IsAddToFront);
                    }
                }
            }

            return newData;
        }
Esempio n. 2
0
        private void Route(
            EventBean[] events,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            foreach (var routed in events) {
                if (routed is NaturalEventBean) {
                    var natural = (NaturalEventBean) routed;
                    if (_audit) {
                        _agentInstanceContext.AuditProvider.Insert(natural.OptionalSynthetic, _agentInstanceContext);
                    }

                    if (_tableInstance != null) {
                        TableEvalLockUtil.ObtainLockUnless(
                            _tableInstance.TableLevelRWLock.WriteLock,
                            exprEvaluatorContext);
                        _tableInstance.AddEventUnadorned(natural.OptionalSynthetic);
                    }
                    else {
                        _agentInstanceContext.InternalEventRouter.Route(
                            natural.OptionalSynthetic,
                            _agentInstanceContext,
                            _parent.IsAddToFront);
                    }
                }
                else {
                    if (_audit) {
                        _agentInstanceContext.AuditProvider.Insert(routed, _agentInstanceContext);
                    }

                    if (_tableInstance != null) {
                        TableEvalLockUtil.ObtainLockUnless(
                            _tableInstance.TableLevelRWLock.WriteLock,
                            exprEvaluatorContext);
                        _tableInstance.AddEventUnadorned(routed);
                    }
                    else {
                        _agentInstanceContext.InternalEventRouter.Route(
                            routed,
                            _agentInstanceContext,
                            _parent.IsAddToFront);
                    }
                }
            }
        }