/// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="transactionQueueManager"></param>
        /// <param name="transactionQueueBussiness"></param>
        /// <param name="queueFilter"></param>

        public TransactionQueueController(
            ILogger <TransactionQueueController> logger,
            ITransactionQueueManager transactionQueueManager, ITransactionQueueBussiness transactionQueueBussiness, IQueueFilter queueFilter
            )
        {
            _logger = logger;
            _transactionQueueManager   = transactionQueueManager;
            _transactionQueueBussiness = transactionQueueBussiness;
            _queueFilter = queueFilter;
        }
Example #2
0
        public IQueueFilter GetFilter(XElement ep, QueueAbstract queue)
        {
            string type = ep.Name.ToString();

            IQueueFilter filter = null;

            switch (type)
            {
            case "xpexists":
                filter = new FilterXPathExists(ep);
                break;

            case "xpequals":
            case "xpmatches":
                filter = new FilterXPathEquals(ep);
                break;

            case "dateRange":
                filter = new FilterDateRange(ep);
                break;

            case "bool":
                filter = new FilterBool(ep);
                break;

            case "contains":
                filter = new FilterContains(ep);
                break;

            case "equals":
                filter = new FilterEquals(ep);
                break;

            case "matches":
                filter = new FilterMatches(ep);
                break;

            case "length":
                filter = new FilterLength(ep);
                break;

            case "contextContains":
                filter = new FilterContextContains(ep, queue);
                break;
            }

            return(filter);
        }
Example #3
0
        public Expression(XElement defn, QueueAbstract queue)
        {
            try
            {
                type = defn.Attribute("type").Value;
            }
            catch (Exception)
            {
                type = "single";
            }

            type = defn.Name.ToString();

            foreach (string fType in filterTypes)
            {
                foreach (XElement filterConfig in defn.Elements(fType))
                {
                    IQueueFilter filter = filterFact.GetFilter(filterConfig, queue);
                    if (filter != null)
                    {
                        filters.Add(filter);
                    }

                    // If it is a "single" type of expression, there will only be one filter Element
                    if (type == "single" || type == "not")
                    {
                        singleFilter = filter;
                    }
                }
            }

            // Boolean operators are all implemented in the this class

            foreach (string eType in expressionTypes)
            {
                foreach (XElement exprConfig in defn.Elements(eType))
                {
                    Expression exp = new Expression(exprConfig, queue);
                    expressions.Add(exp);
                    if (type == "single" || type == "not")
                    {
                        singleExpression = exp;
                    }
                }
            }
        }
Example #4
0
        public Expression(XmlNode defn)
        {
            try {
                type = defn.Attributes["type"].Value;
            } catch (Exception) {
                type = "single";
            }

            type = defn.Name.ToString();

            foreach (string fType in filterTypes)
            {
                foreach (XmlNode filterConfig in defn.SelectNodes($"./{fType}"))
                {
                    IQueueFilter filter = filterFact.GetFilter(filterConfig);
                    if (filter != null)
                    {
                        filters.Add(filter);
                    }

                    // If it is a "single" type of expression, there will only be one filter Element
                    if (type == "single" || type == "not")
                    {
                        singleFilter = filter;
                    }
                }
            }

            // Boolean operators are all implemented in the this class

            foreach (string eType in expressionTypes)
            {
                foreach (XmlNode exprConfig in defn.SelectNodes($"/{eType}"))
                {
                    Expression exp = new Expression(exprConfig);
                    expressions.Add(exp);
                    if (type == "single" || type == "not")
                    {
                        singleExpression = exp;
                    }
                }
            }
        }
        protected SourceControllerAbstract(XmlNode node, int chainDepth, List <string> triggersInUse, int serverOffset, NgExecutionController executionController)
        {
            this.node                = node;
            this.triggersInUse       = triggersInUse;
            this.clientHub           = executionController?.clientHub;
            eventDistributor         = executionController?.eventDistributor;
            this.executionController = executionController;
            this.serverOffset        = serverOffset;
            name = node.Attributes["name"]?.Value;
            id   = node.Attributes["ID"]?.Value;

            dataSourceType   = node.Attributes["dataSource"]?.Value;
            flightSourceType = node.Attributes["flttype"]?.Value;

            executionNodeID = node.Attributes["executionNodeUuid"]?.Value;
            uuid            = node.Attributes["uuid"]?.Value;

            if ((flightSourceType != null && flightSourceType != "none") || node.Name == "amsdatadriven")
            {
                if (flightSourceType == "arr")
                {
                    flttype = FlightType.Arrival;
                }
                else if (flightSourceType == "dep")
                {
                    flttype = FlightType.Departure;
                }
                else
                {
                    flttype = FlightType.Both;
                }

                try {
                    if (node.Attributes["flightSetFrom"] != null)
                    {
                        flightSetFrom = int.Parse(node.Attributes["flightSetFrom"]?.Value);
                    }
                    else
                    {
                        flightSetFrom = -180;
                    }
                } catch (Exception) {
                    flightSetFrom = -180;
                }
                try {
                    if (node.Attributes["flightSetTo"] != null)
                    {
                        flightSetTo = int.Parse(node.Attributes["flightSetTo"]?.Value);
                    }
                    else
                    {
                        flightSetTo = 180;
                    }
                } catch (Exception) {
                    flightSetTo = 180;
                }
                try {
                    if (node.Attributes["refreshFlight"] != null)
                    {
                        refreshFlight = bool.Parse(node.Attributes["refreshFlight"]?.Value);
                    }
                    else
                    {
                        refreshFlight = false;
                    }
                } catch (Exception) {
                    refreshFlight = false;
                }
            }
            else
            {
                flttype = FlightType.None;
            }

            switch (dataSourceType)
            {
            case "CSV":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                break;

            case "Excel":
                dataFile      = node.Attributes["dataFile"]?.Value;
                excelSheet    = node.Attributes["excelSheet"]?.Value;
                excelRowStart = node.Attributes["excelRowStart"]?.Value;
                excelRowEnd   = node.Attributes["excelRowEnd"]?.Value;
                break;

            case "XML":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                repeatingElement    = node.Attributes["repeatingElement"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                try {
                    xmlToString = bool.Parse(node.Attributes["xmlToString"]?.Value);
                } catch (Exception) {
                    xmlToString = false;
                }
                break;

            case "JSON":
                dataFile            = node.Attributes["dataFile"]?.Value;
                dataRestURL         = node.Attributes["dataRestURL"]?.Value;
                dataSourceFileOrURL = node.Attributes["sourceType"]?.Value;
                repeatingElement    = node.Attributes["repeatingElement"]?.Value;
                break;

            case "DATABASE":
            case "MSSQL":
            case "MySQL":
            case "ORACLE":
                connStr = node.Attributes["connStr"]?.Value;
                sql     = node.Attributes["sql"]?.Value;
                dbType  = node.Attributes["sourceType"]?.Value;
                break;
            }

            dataSourceFileOrURL = dataSourceFileOrURL ?? "file";

            XmlNode filtersDefn = node.SelectSingleNode("./filter");

            if (filtersDefn != null)
            {
                /*
                 * At the top level, there is only one Expresssion, which it self can be a compound
                 * expression or a single data filter
                 *
                 * When the Expression itself is constucted, it recurssive creates all the Expression o
                 * filters configured under it
                 */

                // Cycle through the expressions types (and, or, not, xor) to see if any exist
                foreach (string eType in Expression.expressionTypes)
                {
                    XmlNode exprDefn = filtersDefn.SelectSingleNode($"./{eType}");
                    if (exprDefn != null)
                    {
                        expression = new Expression(exprDefn);
                    }
                }

                FilterFactory fact = new FilterFactory();
                // Cycle through the data filter types (and, or, not, xor) to see if any exist
                foreach (string fType in Expression.filterTypes)
                {
                    XmlNode filtDefn = filtersDefn.SelectSingleNode($"./{fType}");
                    if (filtDefn != null)
                    {
                        topLevelFilter = fact.GetFilter(filtDefn);
                    }
                }

                try {
                    filterTime = filtersDefn.Attributes["filterTime"]?.Value;
                } catch (Exception) {
                    filterTime = "post";
                }

                if (filterTime == null)
                {
                    filterTime = "post";
                }
            }

            // Add the chained controllers
            foreach (XmlNode chained in node.SelectNodes("./chained"))
            {
                chainedController.Add(new RateDrivenSourceController(chained, chainDepth++, triggersInUse, serverOffset, executionController));
            }
        }
Example #6
0
 public Pipe(ILogWriter writer, IQueueFilter filter)
 {
     _writer = writer;
     _filter = filter;
 }
        public QueueAbstract(XElement defn, IProgress <QueueMonitorMessage> monitorMessageProgress)
        {
            this.monitorMessageProgress = monitorMessageProgress;
            this.definition             = defn;

            try {
                var stylesheet = definition.Attribute("stylesheet").Value;
                this.styleSheets = stylesheet.Split(',').ToList <string>();
                this.bTransform  = true;
            }
            catch (Exception) {
                this.styleSheets = new List <string>();
                this.bTransform  = false;
            }

            try {
                this.queueName = definition.Attribute("queue").Value;
            }
            catch (Exception) {
                this.queueName = "undefined";
            }

            try {
                this.id = definition.Attribute("id").Value;
            }
            catch (Exception) {
                this.id = Guid.NewGuid().ToString();
            }

            try {
                this.name = definition.Attribute("name").Value;
            }
            catch (Exception) {
                this.name = this.queueName;
            }

            try {
                this.createQueue = bool.Parse(definition.Attribute("createQueue").Value);
            }
            catch (Exception) {
                this.createQueue = false;
            }

            try {
                this.xslVersion = definition.Attribute("xslVersion").Value;
            }
            catch (Exception) {
                this.xslVersion = "1.0";
            }

            try {
                this.maxRetry = Convert.ToInt32(definition.Attribute("maxRetry").Value);
            }
            catch (Exception) {
                this.maxRetry = 10;
            }
            try {
                this.priority = Convert.ToInt32(definition.Attribute("priority").Value);

                switch (priority)
                {
                case 0:
                    mqPriority = MessagePriority.Lowest;
                    break;

                case 1:
                    mqPriority = MessagePriority.VeryLow;
                    break;

                case 2:
                    mqPriority = MessagePriority.Low;
                    break;

                case 3:
                    mqPriority = MessagePriority.Normal;
                    break;

                case 4:
                    mqPriority = MessagePriority.AboveNormal;
                    break;

                case 5:
                    mqPriority = MessagePriority.High;
                    break;

                case 6:
                    mqPriority = MessagePriority.VeryHigh;
                    break;

                case 7:
                    mqPriority = MessagePriority.Highest;
                    break;
                }
            }
            catch (Exception) {
                this.priority = 2;
                mqPriority    = MessagePriority.Normal;
            }

            try {
                undeliverableQueue = defn.Attribute("undeliverableQueue").Value;
                CreateQueue(undeliverableQueue);
            }
            catch (Exception) {
                undeliverableQueue = null;
            }

            try {
                bufferQueueName = definition.Attribute("bufferQueueName").Value;
                CreateQueue(bufferQueueName, true);
            }
            catch (Exception) {
                bufferQueueName = null;
            }


            try {
                xpathDestination = definition.Attribute("xpathDestination").Value;
            }
            catch (Exception) {
                xpathDestination = null;
            }
            try {
                xpathContentDestination = definition.Attribute("xpathContentDestination").Value;
            }
            catch (Exception) {
                xpathContentDestination = null;
            }

            // Add any filter expresion
            XElement filtersDefn = defn.Element("filter");

            if (filtersDefn != null)
            {
                // Add the alternate queue to send to if the expression fails (optional)
                try {
                    altQueue = fact.GetQueue(filtersDefn.Element("altqueue"), this.monitorMessageProgress);
                }
                catch (Exception) {
                    altQueue = null;
                }

                /*
                 * At the top level, there is only one Expresssion, which it self can be a compound
                 * expression or a single data filter
                 *
                 * When the Expression itself is constucted, it recurssive creates all the Expression o
                 * filters configured under it
                 */

                // Cycle through the expressions types (and, or, not, xor) to see if any exist
                foreach (string eType in Expression.expressionTypes)
                {
                    XElement exprDefn = filtersDefn.Element(eType);
                    if (exprDefn != null)
                    {
                        expression = new Expression(exprDefn, this);
                    }
                }

                // Cycle through the data filter types (and, or, not, xor) to see if any exist
                foreach (string fType in Expression.filterTypes)
                {
                    XElement filtDefn = filtersDefn.Element(fType);
                    if (filtDefn != null)
                    {
                        topLevelFilter = fact.GetFilter(filtDefn, this);
                    }
                }
            }
            // Call the instance specific setup
            this.isValid = this.SetUp();
        }