/**************************************************************************/ protected override void RenderListView( List <ListViewItem> ListViewItems, MacroscopeDocumentCollection DocCollection, MacroscopeDocument msDoc, string Url ) { List <KeyValuePair <string, MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS> > KeywordPresence; bool Proceed = false; if (msDoc.GetIsExternal()) { return; } if (msDoc.GetIsRedirect()) { return; } switch (msDoc.GetDocumentType()) { case MacroscopeConstants.DocumentType.HTML: Proceed = true; break; default: break; } if (Proceed) { ListViewItem lvItem = null; KeywordPresence = DocCollection.GetKeywordPresenceAnalysis(msDoc: msDoc); foreach (KeyValuePair <string, MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS> Pair in KeywordPresence) { MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS Present = Pair.Value; string Keyword = Pair.Key; string PairKey = string.Join("", UrlToDigest(Url: Url).ToString(), Keyword); if (this.DisplayListView.Items.ContainsKey(PairKey)) { try { lvItem = this.DisplayListView.Items[PairKey]; lvItem.SubItems[COL_URL].Text = Url; lvItem.SubItems[COL_KEYWORD].Text = Keyword; lvItem.SubItems[COL_PRESENCE].Text = Present.ToString(); } catch (Exception ex) { DebugMsg(string.Format("MacroscopeDisplayKeywordsPresence 1: {0}", ex.Message)); } } else { try { lvItem = new ListViewItem(PairKey); lvItem.UseItemStyleForSubItems = false; lvItem.Name = PairKey; lvItem.SubItems[COL_URL].Text = Url; lvItem.SubItems.Add(Keyword); lvItem.SubItems.Add(Present.ToString()); ListViewItems.Add(lvItem); } catch (Exception ex) { DebugMsg(string.Format("MacroscopeDisplayKeywordsPresence 2: {0}", ex.Message)); } } if (lvItem != null) { lvItem.ForeColor = Color.Blue; // URL -------------------------------------------------------------// if (msDoc.GetIsInternal()) { lvItem.SubItems[COL_URL].ForeColor = Color.Green; } else { lvItem.SubItems[COL_URL].ForeColor = Color.Gray; } // Check Missing Text ----------------------------------------------// if (msDoc.GetIsInternal()) { switch (Present) { case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.KEYWORDS_METATAG_EMPTY: lvItem.SubItems[COL_URL].ForeColor = Color.Red; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Red; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Red; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MALFORMED_KEYWORDS_METATAG: lvItem.SubItems[COL_URL].ForeColor = Color.Red; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Red; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Red; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_TITLE: lvItem.SubItems[COL_URL].ForeColor = Color.Green; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Green; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Green; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_TITLE: lvItem.SubItems[COL_URL].ForeColor = Color.Red; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Red; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Red; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_DESCRIPTION: lvItem.SubItems[COL_URL].ForeColor = Color.Green; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Green; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Green; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_DESCRIPTION: lvItem.SubItems[COL_URL].ForeColor = Color.Orange; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Orange; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Orange; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_BODY: lvItem.SubItems[COL_URL].ForeColor = Color.Green; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Green; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Green; break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_BODY: lvItem.SubItems[COL_URL].ForeColor = Color.Red; lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Red; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Red; break; default: break; } } else { lvItem.SubItems[COL_KEYWORD].ForeColor = Color.Gray; lvItem.SubItems[COL_PRESENCE].ForeColor = Color.Gray; } } } } }
/**************************************************************************/ private void BuildWorksheetKeywordsPresence( MacroscopeJobMaster JobMaster, XLWorkbook wb, string WorksheetLabel, MacroscopeDocumentCollection DocCollection ) { var ws = wb.Worksheets.Add(WorksheetLabel); int iRow = 1; int iCol = 1; int iColMax = 1; decimal DocCount = 0; decimal DocTotal = (decimal)DocCollection.CountDocuments(); { ws.Cell(iRow, iCol).Value = "Presence"; iCol++; ws.Cell(iRow, iCol).Value = "Keyword"; iCol++; ws.Cell(iRow, iCol).Value = "URL"; } iColMax = iCol; iRow++; foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments()) { List <KeyValuePair <string, MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS> > KeywordPresence; KeywordPresence = DocCollection.GetKeywordPresenceAnalysis(msDoc: msDoc); if (DocCount > 0) { this.ProgressForm.UpdatePercentages( Title: null, Message: null, MajorPercentage: -1, ProgressLabelMajor: null, MinorPercentage: ((decimal)100 / DocTotal) * (decimal)DocCount, ProgressLabelMinor: "Documents Processed" ); } if (KeywordPresence != null) { foreach (KeyValuePair <string, MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS> Pair in KeywordPresence) { MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS Present = Pair.Value; string Keyword = Pair.Key; iCol = 1; this.InsertAndFormatContentCell(ws, iRow, iCol, Pair.Value.ToString()); switch (Pair.Value) { case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.KEYWORDS_METATAG_EMPTY: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Red); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MALFORMED_KEYWORDS_METATAG: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Red); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_TITLE: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_TITLE: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Red); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_DESCRIPTION: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_DESCRIPTION: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Orange); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.PRESENT_IN_BODY: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green); break; case MacroscopeKeywordPresenceAnalysis.KEYWORD_STATUS.MISSING_IN_BODY: ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Red); break; default: break; } iCol++; this.InsertAndFormatContentCell(ws, iRow, iCol, Keyword); iCol++; this.InsertAndFormatUrlCell(ws, iRow, iCol, msDoc.GetUrl()); iRow++; } } DocCount++; } { var rangeData = ws.Range(1, 1, iRow - 1, iColMax); var excelTable = rangeData.CreateTable(); } }