public override NodeQueryResult EvaluateSingle(NodeQueryDefinition query, NodeQueryEvaluationContext context)
        {
            Log(query);

            Regex           regex  = new Regex(query.query);
            NodeQueryResult output = new NodeQueryResult();

            output.ResultEvaluation = regex.IsMatch(context.documentUrl);

            Log(output);

            return(output);
        }
예제 #2
0
        public void Log(NodeQueryResult queryResult)
        {
            if (logger != null)
            {
                logger.AppendLine("Query Result: \t\t" + queryResult.ToString());
                //logger.nextTabLevel();

                //logger.AppendLine("Evaluation: " + queryResult.ResultEvaluation);

                //logger.AppendLine("Nodes: " + queryResult.ResultNodes.Count);

                //logger.prevTabLevel();
            }
        }
예제 #3
0
        public override NodeQueryResult EvaluateSingle(NodeQueryDefinition query, NodeQueryEvaluationContext context)
        {
            //var p = context.htmlDocument.DocumentNode.XPath;

            Log(query);

            var nodes = context.htmlNodes.SelectNodes(query.query);

            NodeQueryResult output = new NodeQueryResult();

            if (nodes != null)
            {
                output.ResultNodes.AddRange(nodes);
            }

            output.ResultEvaluation = output.ResultNodes.Any();

            Log(output);

            return(output);
        }
예제 #4
0
        public override NodeQueryResult EvaluateSingle(NodeQueryDefinition query, NodeQueryEvaluationContext context)
        {
            Log(query);

            var indexList = imbSCI.Core.extensions.text.imbStringCommonTools.rangeStringToIndexList(query.query, context.htmlNodes.Count);

            NodeQueryResult output = new NodeQueryResult();

            foreach (Int32 i in indexList)
            {
                if (i < context.htmlNodes.Count)
                {
                    output.ResultNodes.Add(context.htmlNodes[i]);
                }
            }


            output.ResultEvaluation = output.ResultNodes.Any();

            Log(output);

            return(output);
        }
예제 #5
0
        /* ====================================================================================================== Methods */
        private void BuildList()
        {
            //store the selected value for using it after the list is repopulated
            //(storing the index is not correct, we have to use the value)
            var selVal = this.SelectedIndex > 0 ? this.SelectedValue : null;

            //we have to clear the itemlist here to
            //refresh the item collection if changed
            this.Items.Clear();

            if (this.DropdownOptions.CommonType == DropDownCommonType.ContentTypeDropdown)
            {
                // special use-case, content type list is defined in webconfig
                NodeQueryResult contentTypeNames = GetWebContentTypeList();
                if (contentTypeNames.Count > 0)
                {
                    foreach (Node contentType in contentTypeNames.Nodes)
                    {
                        var contentTypeName = contentType.Name;
                        this.Items.Add(new ListItem(contentTypeName, contentTypeName));
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.DropdownOptions.Query))
            {
                // the list is built up from a query
                var sortinfo = new List <SortInfo>()
                {
                    new SortInfo()
                    {
                        FieldName = "Name", Reverse = false
                    }
                };
                var settings = new QuerySettings()
                {
                    EnableAutofilters = false, Sort = sortinfo
                };
                var query  = ContentQuery.CreateQuery(this.DropdownOptions.Query, settings);
                var result = query.Execute();
                if (result.Count == 0)
                {
                    this.Items.Add(new ListItem("No items available", string.Empty));
                    return;
                }
                this.Items.Add(new ListItem("Select an item...", string.Empty));
                foreach (Node node in result.Nodes)
                {
                    var nodeName = node.Name;
                    this.Items.Add(new ListItem(nodeName, nodeName));
                }
            }

            //re-select the original selected value if needed
            if (selVal != null)
            {
                var index = 0;
                foreach (ListItem item in this.Items)
                {
                    if (selVal.CompareTo(item.Value) == 0)
                    {
                        this.SelectedIndex = index;
                        break;
                    }

                    index++;
                }
            }
        }