Exemplo n.º 1
0
        public void AddKqlQuery(CslParagraph para)
        {
            try
            {
                // Load any functions for use across the node
                GlobalFunctions.ReadFunctionsFromQuery(para.Query);

                // Create the KqlQuery info, and hold reference to the object to prevent GC from releasing.
                var newKqlQuery = new KqlQuery(this, para.Comment, para.Query)
                {
                    IsValid = true,
                    Message = "Success",
                    KqlQueryEngagedDateTime = DateTime.UtcNow
                };

                KqlQueryList.Add(newKqlQuery);
                SubscriptionReferenceDisposables.Add(newKqlQuery);
            }
            catch (Exception ex)
            {
                FailedKqlQueryList.Add(new KqlQuery
                {
                    Node          = this,
                    Comment       = para.Comment,
                    Query         = para.Query,
                    IsValid       = false,
                    Message       = ex.Message,
                    FailureReason = ex,
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Left in for legacy purposes.  Usage should be on the published and supported method: AddKqlQuery
        /// </summary>
        /// <param name="kqlQuery">The KqlQuery object</param>
        /// <param name="stopKqlQueries">Optionally clear out currently executing KqlQueries, or only add new ones</param>
        public void AddKqlQueryInfo(KqlQuery kqlQuery, bool stopKqlQueries = false)
        {
            if (stopKqlQueries)
            {
                InitializeKqlQueryLists();
            }

            this.AddKqlQuery(new CslParagraph
            {
                Comment = kqlQuery.Comment,
                Query   = kqlQuery.Query
            });
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Create a KqlNodeHub from an existing KQL query as a string. The string must contain only one KQL query.
        ///     The KqlNodeHub automatically creates a KqlNode and subscribes the KqlNode to the observable sequence,
        ///     observableInput.
        /// </summary>
        /// <param name="observableInput">
        ///     IObservable<IDictionary
        ///     <string, object>> - the data that the KQL queries will run against.
        /// </param>
        /// <param name="delegateOutput">Action&lt;KqlOutput&gt; - the structure of the query output as a KqlOutput instance.</param>
        /// <param name="observableName">the observable input stream name</param>
        /// <param name="kqlQuery">KqlQuery - an instance of the KqlQuery object type</param>
        /// <returns>a boolean value containing the operations success.</returns>
        public bool AddFromKqlQuery(
            IObservable <IDictionary <string, object> > observableInput,
            Action <KqlOutput> delegateOutput,
            string observableName,
            KqlQuery kqlQuery)
        {
            var kqlNodeHub = new KqlNodeHub(delegateOutput);

            kqlNodeHub._node.AddKqlQuery(kqlQuery);

            kqlNodeHub.AddInput(observableName, observableInput);

            return(KqlNodeHubs.TryAdd(observableName, kqlNodeHub));
        }
Exemplo n.º 4
0
        public bool TryAddKqlQuery(KqlQuery kqlQuery, out Exception exception)
        {
            bool result = true;

            exception = null;

            this.AddKqlQuery(kqlQuery);

            exception = this.FailedKqlQueryList
                        .Where(a => string.Equals(a.Query, kqlQuery.Query, StringComparison.OrdinalIgnoreCase))
                        .Select(a => a.FailureReason)
                        .FirstOrDefault();

            result = exception == null;

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add a single KqlQuery to the KqlNode.
        /// </summary>
        /// <param name="kqlQuery">The KqlQuery object</param>
        /// <param name="stopKqlQueries">Optionally clear out currently executing KqlQueries, or only add new ones</param>
        public void AddKqlQuery(KqlQuery kqlQuery, bool stopKqlQueries = false)
        {
            try
            {
                // Optionally clear out currently executing KqlQueries, or only add new ones
                if (stopKqlQueries)
                {
                    InitializeKqlQueryLists();
                }

                // Load any functions for use across the node
                GlobalFunctions.ReadFunctionsFromQuery(kqlQuery.Query);

                // Create the KqlQuery info, and hold reference to the object to prevent GC from releasing.
                var newKqlQuery = new KqlQuery(this, kqlQuery.Comment, kqlQuery.Query)
                {
                    IsValid = true,
                    Message = "Success",
                    KqlQueryEngagedDateTime = DateTime.UtcNow,
                    QueryGuid        = kqlQuery.QueryGuid,
                    QueryName        = kqlQuery.QueryName,
                    QueryDescription = kqlQuery.QueryDescription,
                    QueryId          = kqlQuery.QueryId,
                };

                KqlQueryList.Add(newKqlQuery);
                SubscriptionReferenceDisposables.Add(newKqlQuery);
            }
            catch (Exception ex)
            {
                FailedKqlQueryList.Add(new KqlQuery
                {
                    Node             = this,
                    Comment          = kqlQuery.Comment,
                    Query            = kqlQuery.Query,
                    IsValid          = false,
                    Message          = ex.Message,
                    QueryGuid        = kqlQuery.QueryGuid,
                    QueryName        = kqlQuery.QueryName,
                    QueryDescription = kqlQuery.QueryDescription,
                    QueryId          = kqlQuery.QueryId,
                    FailureReason    = ex,
                });
            }
        }