Beispiel #1
0
        public void StoreRecord(RecordTemplateItemTakeCollection takes)
        {
            switch (takes.Template.Role)
            {
            case RecordTemplateRole.GeneralContextProvider:
                ColumnContextTakes.RecordXPath = takes.RecordNode.XPath;
                foreach (var take in takes.items)
                {
                    ColumnContextTakes.Cells.AddCell(take, false);
                }
                break;

            case RecordTemplateRole.RowDataAndContextProvider:
            case RecordTemplateRole.RowDataProvider:
                RecordTemplateTableRow row = null;
                if (!Rows.Any(x => x.RecordXPath == takes.RecordNode.XPath))
                {
                    RecordTemplateTableRow newRow = new RecordTemplateTableRow()
                    {
                        RecordXPath = takes.RecordNode.XPath
                    };
                    Rows.Add(newRow);
                    row = newRow;
                }
                else
                {
                    row = Rows.First(x => x.RecordXPath == takes.RecordNode.XPath);
                }

                if (row.OriginalTake == null)
                {
                    row.Populated    = 1;
                    row.OriginalTake = takes;
                }
                else
                {
                    row.Populated++;
                    row.OriginalTake.items.AddRange(takes.items);
                }


                break;
            }
        }
Beispiel #2
0
        public RecordTemplateItemTakeCollection SelectTakes(HtmlNode recordNode)
        {
            RecordTemplateItemTakeCollection output = new RecordTemplateItemTakeCollection()
            {
                Template   = this,
                RecordNode = recordNode
            };

            foreach (RecordTemplateItem item in items)
            {
                var itemNode = recordNode.SelectSingleNode(item.SubXPath);
                if (itemNode != null)
                {
                    output.AddCell(new RecordTemplateItemTake()
                    {
                        TemplateItem = item,
                        SelectedNode = itemNode,
                        SubXPath     = item.SubXPath
                    });
                }
            }

            return(output);
        }