/**************************************************************************/ private void BuildWorksheetPageRedirectChains( MacroscopeJobMaster JobMaster, CsvWriter ws ) { MacroscopeDocumentCollection DocCollection = JobMaster.GetDocCollection(); List <List <MacroscopeRedirectChainDocStruct> > RedirectChains = DocCollection.GetMacroscopeRedirectChains(); int MaxHops = 1; foreach (List <MacroscopeRedirectChainDocStruct> DocList in RedirectChains) { int iHop = 1; foreach (MacroscopeRedirectChainDocStruct RedirectChainDocStruct in DocList) { iHop++; } if (iHop > MaxHops) { MaxHops = iHop; } } for (int iHop = 1; iHop < MaxHops; iHop++) { ws.WriteField(string.Format("Hop {0} URL", iHop)); ws.WriteField(string.Format("Hop {0} Status", iHop)); } ws.NextRecord(); foreach (List <MacroscopeRedirectChainDocStruct> DocList in RedirectChains) { foreach (MacroscopeRedirectChainDocStruct RedirectChainDocStruct in DocList) { string Url = RedirectChainDocStruct.Url; string StatusCode = RedirectChainDocStruct.StatusCode.ToString(); this.InsertAndFormatUrlCell(ws, Url); this.InsertAndFormatContentCell(ws, StatusCode); } ws.NextRecord(); } }
/**************************************************************************/ private void BuildWorksheetPageRedirectChains( 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(); List <List <MacroscopeRedirectChainDocStruct> > RedirectChains = DocCollection.GetMacroscopeRedirectChains(); { ws.Cell(iRow, iCol).Value = "Hop"; iCol++; ws.Cell(iRow, iCol).Value = "Status"; } iRow++; foreach (List <MacroscopeRedirectChainDocStruct> DocList in RedirectChains) { int iHop = 1; iCol = 1; foreach (MacroscopeRedirectChainDocStruct RedirectChainDocStruct in DocList) { string Url = RedirectChainDocStruct.Url; string StatusCode = RedirectChainDocStruct.StatusCode.ToString(); ws.Cell(1, iCol).Value = string.Format("Hop {0} URL", iHop); this.InsertAndFormatUrlCell(ws, iRow, iCol, Url); iCol++; if (AllowedHosts.IsInternalUrl(Url: Url)) { ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Green); } else { ws.Cell(iRow, iCol).Style.Font.SetFontColor(XLColor.Gray); } ws.Cell(1, iCol).Value = string.Format("Hop {0} Status", iHop); this.InsertAndFormatContentCell(ws, iRow, iCol, StatusCode); iCol++; iHop++; } if (iCol > iColMax) { iColMax = iCol; } iRow++; } if ((iRow > 1) && (iColMax > 2)) { var rangeData = ws.Range(1, 1, iRow - 1, iColMax - 1); var excelTable = rangeData.CreateTable(); } }
/**************************************************************************/ private void RenderListViewRedirectChains(MacroscopeDocumentCollection DocCollection) { List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments()); List <List <MacroscopeRedirectChainDocStruct> > RedirectChains = DocCollection.GetMacroscopeRedirectChains(); MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm); decimal Count = 0; decimal TotalDocs = (decimal)DocCollection.CountDocuments(); decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count; if (MacroscopePreferencesManager.GetShowProgressDialogues()) { ProgressForm.ControlBox = false; ProgressForm.UpdatePercentages( Title: "Preparing Display", Message: "Processing document collection for display:", MajorPercentage: MajorPercentage, ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs) ); } foreach (List <MacroscopeRedirectChainDocStruct> DocList in RedirectChains) { Application.DoEvents(); if (DocList.Count > 0) { try { this.RenderListViewRedirectChains( ListViewItems: ListViewItems, DocCollection: DocCollection, DocList: DocList ); } catch (Exception ex) { this.DebugMsg(string.Format("RenderListViewRedirectChains 1: {0}", ex.Message)); } } if (MacroscopePreferencesManager.GetShowProgressDialogues()) { Count++; MajorPercentage = ((decimal)100 / TotalDocs) * Count; ProgressForm.UpdatePercentages( Title: null, Message: null, MajorPercentage: MajorPercentage, ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs) ); } } this.DisplayListView.Items.AddRange(ListViewItems.ToArray()); this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); if (MacroscopePreferencesManager.GetShowProgressDialogues()) { ProgressForm.DoClose(); } ProgressForm.Dispose(); }