Ejemplo n.º 1
0
        /**************************************************************************/

        private void BuildWorksheetPageHeadings(
            MacroscopeJobMaster JobMaster,
            CsvWriter ws
            )
        {
            MacroscopeDocumentCollection DocCollection = JobMaster.GetDocCollection();

            {
                ws.WriteField("URL");
                ws.WriteField("Occurences");
                ws.WriteField("Order");

                for (int i = 1; i <= 6; i++)
                {
                    ws.WriteField(string.Format("H{0}", i));
                }

                ws.NextRecord();
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                bool Proceed = false;

                if (msDoc.GetIsExternal())
                {
                    continue;
                }

                if (msDoc.GetIsRedirect())
                {
                    continue;
                }

                if (msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.HTML))
                {
                    Proceed = true;
                }

                if (Proceed)
                {
                    for (ushort HeadingLevel = 1; HeadingLevel <= MacroscopePreferencesManager.GetMaxHeadingDepth(); HeadingLevel++)
                    {
                        List <string> HeadingsList = msDoc.GetHeadings(HeadingLevel);

                        for (int Order = 0; Order < HeadingsList.Count; Order++)
                        {
                            int Occurences = DocCollection.GetStatsHeadingsCount(HeadingLevel: HeadingLevel, Text: HeadingsList[Order]);

                            this.InsertAndFormatUrlCell(ws, msDoc);

                            this.InsertAndFormatContentCell(ws, Occurences.ToString());

                            this.InsertAndFormatContentCell(ws, this.FormatIfMissing((Order + 1).ToString()));

                            this.InsertAndFormatContentCell(ws, this.FormatIfMissing(HeadingsList[Order]));

                            ws.NextRecord();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /**************************************************************************/

        protected override void RenderListView(
            List <ListViewItem> ListViewItems,
            MacroscopeDocumentCollection DocCollection,
            MacroscopeDocument msDoc,
            string Url
            )
        {
            bool Proceed = false;

            if (msDoc.GetIsExternal())
            {
                return;
            }

            if (msDoc.GetIsRedirect())
            {
                return;
            }

            if (msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.HTML))
            {
                Proceed = true;
            }

            if (Proceed)
            {
                for (ushort HeadingLevel = 1; HeadingLevel <= MacroscopePreferencesManager.GetMaxHeadingDepth(); HeadingLevel++)
                {
                    List <string> HeadingsList = msDoc.GetHeadings(HeadingLevel);

                    for (int Order = 0; Order < HeadingsList.Count; Order++)
                    {
                        ListViewItem lvItem          = null;
                        string       PairKey         = string.Join(":", UrlToDigest(Url), UrlToDigest(HeadingLevel.ToString()), UrlToDigest(Order.ToString())).ToString();
                        int          HeadingColIndex = HeadingLevel + ColH1Offset;
                        string       TextLabel       = HeadingsList[Order];
                        int          Occurences      = DocCollection.GetStatsHeadingsCount(HeadingLevel: HeadingLevel, Text: TextLabel);

                        if (this.DisplayListView.Items.ContainsKey(PairKey))
                        {
                            try
                            {
                                lvItem = this.DisplayListView.Items[PairKey];
                                lvItem.SubItems[ColUrl].Text          = Url;
                                lvItem.SubItems[ColOccurences].Text   = Occurences.ToString();
                                lvItem.SubItems[ColOrder].Text        = (Order + 1).ToString();
                                lvItem.SubItems[HeadingColIndex].Text = TextLabel;
                            }
                            catch (Exception ex)
                            {
                                DebugMsg(string.Format("MacroscopeDisplayHeadings 1: {0}", ex.Message));
                            }
                        }
                        else
                        {
                            try
                            {
                                lvItem = new ListViewItem(PairKey);
                                lvItem.UseItemStyleForSubItems = false;

                                lvItem.Name = PairKey;

                                lvItem.SubItems[ColUrl].Text = Url;
                                lvItem.SubItems.Add(Occurences.ToString());
                                lvItem.SubItems.Add((Order + 1).ToString());

                                for (ushort k = 1; k <= 6; k++)
                                {
                                    lvItem.SubItems.Add("");
                                }

                                lvItem.SubItems[HeadingColIndex].Text = TextLabel;

                                ListViewItems.Add(lvItem);
                            }
                            catch (Exception ex)
                            {
                                DebugMsg(string.Format("MacroscopeDisplayHeadings 2: {0}", ex.Message));
                            }
                        }

                        if (lvItem != null)
                        {
                            lvItem.ForeColor = Color.Blue;

                            // URL -----------------------------------------------------------//

                            if (msDoc.GetIsInternal())
                            {
                                lvItem.SubItems[ColUrl].ForeColor = Color.Green;
                            }
                            else
                            {
                                lvItem.SubItems[ColUrl].ForeColor = Color.Gray;
                            }

                            // Occurences ----------------------------------------------------//

                            if ((Occurences > 1) && (msDoc.GetIsInternal()))
                            {
                                lvItem.SubItems[ColOccurences].ForeColor = Color.Orange;
                            }
                            else
                            if (msDoc.GetIsInternal())
                            {
                                lvItem.SubItems[ColOccurences].ForeColor = Color.Green;
                            }
                            else
                            {
                                lvItem.SubItems[ColOccurences].ForeColor = Color.Gray;
                            }

                            // Check Missing H1 ----------------------------------------------//

                            if ((HeadingLevel == 1) && string.IsNullOrEmpty(TextLabel))
                            {
                                lvItem.SubItems[HeadingColIndex].Text      = "MISSING";
                                lvItem.SubItems[HeadingColIndex].ForeColor = Color.Red;
                            }
                            else
                            {
                                lvItem.SubItems[HeadingColIndex].ForeColor = Color.Green;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /**************************************************************************/

        private void BuildWorksheetPageHeadings(
            MacroscopeJobMaster JobMaster,
            XLWorkbook wb,
            string WorksheetLabel
            )
        {
            var ws = wb.Worksheets.Add(WorksheetLabel);

            int iRow    = 1;
            int iCol    = 1;
            int iColMax = 1;

            MacroscopeDocumentCollection DocCollection = JobMaster.GetDocCollection();

            {
                ws.Cell(iRow, iCol).Value = "URL";
                iCol++;

                ws.Cell(iRow, iCol).Value = "Occurences";
                iCol++;

                ws.Cell(iRow, iCol).Value = "Order";

                for (int i = 1; i <= 6; i++)
                {
                    iCol++;
                    ws.Cell(iRow, iCol).Value = string.Format("H{0}", i);
                }
            }

            iColMax = iCol;

            iRow++;

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                bool Proceed = false;

                if (msDoc.GetIsExternal())
                {
                    continue;
                }

                if (msDoc.GetIsRedirect())
                {
                    continue;
                }

                if (msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.HTML))
                {
                    Proceed = true;
                }

                if (Proceed)
                {
                    for (ushort HeadingLevel = 1; HeadingLevel <= MacroscopePreferencesManager.GetMaxHeadingDepth(); HeadingLevel++)
                    {
                        List <string> HeadingsList = msDoc.GetHeadings(HeadingLevel);

                        for (int Order = 0; Order < HeadingsList.Count; Order++)
                        {
                            int Occurences = DocCollection.GetStatsHeadingsCount(HeadingLevel: HeadingLevel, Text: HeadingsList[Order]);

                            iCol = 1;

                            this.InsertAndFormatUrlCell(ws, iRow, iCol, msDoc);

                            if (msDoc.GetIsInternal())
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green);
                            }
                            else
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Gray);
                            }

                            iCol++;

                            this.InsertAndFormatContentCell(ws, iRow, iCol, Occurences);

                            if ((Occurences > 1) && (msDoc.GetIsInternal()))
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Orange);
                            }
                            else
                            if (msDoc.GetIsInternal())
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green);
                            }
                            else
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Gray);
                            }

                            iCol++;

                            this.InsertAndFormatContentCell(ws, iRow, iCol, this.FormatIfMissing((Order + 1).ToString()));

                            this.InsertAndFormatContentCell(ws, iRow, ( int )(HeadingLevel + iCol), this.FormatIfMissing(HeadingsList[Order]));

                            iRow++;
                        }
                    }
                }
            }

            {
                var rangeData  = ws.Range(1, 1, iRow - 1, iColMax);
                var excelTable = rangeData.CreateTable();
            }
        }