/**************************************************************************/

        private void BuildWorksheetSitemapErrors(
            MacroscopeJobMaster JobMaster,
            CsvWriter ws
            )
        {
            MacroscopeDocumentCollection DocCollection = JobMaster.GetDocCollection();
            MacroscopeAllowedHosts       AllowedHosts  = JobMaster.GetAllowedHosts();

            {
                ws.WriteField("Sitemap URL");
                ws.WriteField("Status Code");
                ws.WriteField("Robots");
                ws.WriteField("URL");

                ws.NextRecord();
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                if (msDoc.GetIsInternal() && msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.SITEMAPXML))
                {
                    foreach (MacroscopeLink Outlink in msDoc.IterateOutlinks())
                    {
                        string             TargetUrl   = Outlink.GetTargetUrl();
                        MacroscopeDocument msDocLinked = DocCollection.GetDocumentByUrl(Url: TargetUrl);
                        bool InsertRow = false;

                        if (msDocLinked.GetIsInternal())
                        {
                            int StatusCode = (int)msDocLinked.GetStatusCode();
                            if ((StatusCode >= 400) && (StatusCode <= 599))
                            {
                                InsertRow = true;
                            }
                            if (!msDocLinked.GetAllowedByRobots())
                            {
                                InsertRow = true;
                            }
                        }

                        if (InsertRow)
                        {
                            this.InsertAndFormatUrlCell(ws, msDoc);

                            this.InsertAndFormatStatusCodeCell(ws, msDoc);

                            this.InsertAndFormatRobotsCell(ws, msDoc);

                            this.InsertAndFormatUrlCell(ws, TargetUrl);

                            ws.NextRecord();
                        }
                    }
                }
            }
        }
예제 #2
0
        /**************************************************************************/

        public void InsertAndFormatRobotsCell(
            IXLWorksheet ws,
            int Row,
            int Col,
            MacroscopeDocument msDoc
            )
        {
            bool Value = msDoc.GetAllowedByRobots();

            ws.Cell(Row, Col).Value = msDoc.GetAllowedByRobotsAsString();

            if (Value)
            {
                ws.Cell(Row, Col).Style.Font.SetFontColor(XLColor.Green);
            }
            else
            {
                ws.Cell(Row, Col).Style.Font.SetFontColor(XLColor.Red);
            }
        }
예제 #3
0
        /**************************************************************************/

        private void BuildWorksheetSitemapXmlErrors(
            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();
            MacroscopeAllowedHosts       AllowedHosts  = JobMaster.GetAllowedHosts();

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

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

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

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

            iColMax = iCol;

            iRow++;

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                if (msDoc.GetIsInternal() && msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.SITEMAPXML))
                {
                    foreach (MacroscopeLink Outlink in msDoc.IterateOutlinks())
                    {
                        string             TargetUrl   = Outlink.GetTargetUrl();
                        MacroscopeDocument msDocLinked = DocCollection.GetDocumentByUrl(Url: TargetUrl);
                        bool InsertRow = false;

                        if (msDocLinked.GetIsInternal())
                        {
                            int StatusCode = (int)msDocLinked.GetStatusCode();
                            if ((StatusCode >= 400) && (StatusCode <= 599))
                            {
                                InsertRow = true;
                            }
                            if (!msDocLinked.GetAllowedByRobots())
                            {
                                InsertRow = true;
                            }
                        }

                        if (InsertRow)
                        {
                            iCol = 1;

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

                            if (AllowedHosts.IsInternalUrl(Url: msDoc.GetUrl()))
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green);
                            }
                            else
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Gray);
                            }

                            iCol++;

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

                            iCol++;

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

                            iCol++;

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

                            if (AllowedHosts.IsInternalUrl(Url: TargetUrl))
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green);
                            }
                            else
                            {
                                ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Gray);
                            }

                            iRow++;
                        }
                    }
                }
            }

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

        private void RenderListViewSitemapErrors(MacroscopeDocumentCollection DocCollection)
        {
            List <ListViewItem> ListViewItems = new List <ListViewItem>(1);
            List <Dictionary <string, string> > CompiledTable = DocCollection.GetSitemapErrorsAsTable();

            foreach (Dictionary <string, string> Entry in CompiledTable)
            {
                string SitemapUrl = Entry["sitemap_url"];
                string StatusCode = Entry["status_code"];
                string Robots     = Entry["robots"];
                string TargetUrl  = Entry["target_url"];

                string PairKey = string.Join("::::::::", SitemapUrl, TargetUrl);

                MacroscopeDocument msDoc       = DocCollection.GetDocumentByUrl(Url: SitemapUrl);
                MacroscopeDocument msDocLinked = DocCollection.GetDocumentByUrl(Url: TargetUrl);

                ListViewItem lvItem = null;

                if (this.DisplayListView.Items.ContainsKey(PairKey))
                {
                    try
                    {
                        lvItem = this.DisplayListView.Items[PairKey];
                        lvItem.SubItems[0].Text = SitemapUrl;
                        lvItem.SubItems[1].Text = StatusCode;
                        lvItem.SubItems[2].Text = Robots;
                        lvItem.SubItems[3].Text = TargetUrl;
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("RenderListViewSitemapErrors 1: {0}", ex.Message));
                    }
                }
                else
                {
                    try
                    {
                        lvItem = new ListViewItem(PairKey);
                        lvItem.UseItemStyleForSubItems = false;
                        lvItem.Name = PairKey;

                        lvItem.SubItems[0].Text = SitemapUrl;
                        lvItem.SubItems.Add(StatusCode);
                        lvItem.SubItems.Add(Robots);
                        lvItem.SubItems.Add(TargetUrl);

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

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

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


                    if (!msDocLinked.GetAllowedByRobots())
                    {
                        lvItem.SubItems[2].ForeColor = Color.Red;
                    }
                    else
                    {
                        lvItem.SubItems[2].ForeColor = Color.Green;
                    }

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

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            return;
        }