Added a Library Document Usage report
added methods to create a library document usage report
This commit is contained in:
parent
dd98679139
commit
8b1498080a
@ -34,6 +34,7 @@ namespace Volian.Controls.Library
|
||||
this.groupPanelLibDocs = new DevComponents.DotNetBar.Controls.GroupPanel();
|
||||
this.listBoxLibDocs = new System.Windows.Forms.ListBox();
|
||||
this.pnlProp = new System.Windows.Forms.Panel();
|
||||
this.btnPrint = new System.Windows.Forms.Button();
|
||||
this.btnOpenLibDoc = new System.Windows.Forms.Button();
|
||||
this.btnDelLibDoc = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
@ -169,6 +170,7 @@ namespace Volian.Controls.Library
|
||||
// pnlProp
|
||||
//
|
||||
this.pnlProp.BackColor = System.Drawing.Color.Beige;
|
||||
this.pnlProp.Controls.Add(this.btnPrint);
|
||||
this.pnlProp.Controls.Add(this.btnOpenLibDoc);
|
||||
this.pnlProp.Controls.Add(this.btnDelLibDoc);
|
||||
this.pnlProp.Controls.Add(this.btnCancel);
|
||||
@ -183,12 +185,23 @@ namespace Volian.Controls.Library
|
||||
this.pnlProp.Size = new System.Drawing.Size(501, 150);
|
||||
this.pnlProp.TabIndex = 32;
|
||||
//
|
||||
// btnPrint
|
||||
//
|
||||
this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnPrint.Location = new System.Drawing.Point(401, 113);
|
||||
this.btnPrint.Name = "btnPrint";
|
||||
this.btnPrint.Size = new System.Drawing.Size(75, 30);
|
||||
this.btnPrint.TabIndex = 15;
|
||||
this.btnPrint.Text = "Print";
|
||||
this.btnPrint.UseVisualStyleBackColor = true;
|
||||
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
|
||||
//
|
||||
// btnOpenLibDoc
|
||||
//
|
||||
this.btnOpenLibDoc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnOpenLibDoc.Location = new System.Drawing.Point(360, 113);
|
||||
this.btnOpenLibDoc.Location = new System.Drawing.Point(325, 113);
|
||||
this.btnOpenLibDoc.Name = "btnOpenLibDoc";
|
||||
this.btnOpenLibDoc.Size = new System.Drawing.Size(108, 30);
|
||||
this.btnOpenLibDoc.Size = new System.Drawing.Size(70, 30);
|
||||
this.superTooltipLibDocs.SetSuperTooltip(this.btnOpenLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Open", "", "Opens, for edit, an unused library document.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
|
||||
this.btnOpenLibDoc.TabIndex = 14;
|
||||
this.btnOpenLibDoc.Text = "Open";
|
||||
@ -198,9 +211,9 @@ namespace Volian.Controls.Library
|
||||
// btnDelLibDoc
|
||||
//
|
||||
this.btnDelLibDoc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnDelLibDoc.Location = new System.Drawing.Point(247, 113);
|
||||
this.btnDelLibDoc.Location = new System.Drawing.Point(246, 113);
|
||||
this.btnDelLibDoc.Name = "btnDelLibDoc";
|
||||
this.btnDelLibDoc.Size = new System.Drawing.Size(108, 30);
|
||||
this.btnDelLibDoc.Size = new System.Drawing.Size(73, 30);
|
||||
this.superTooltipLibDocs.SetSuperTooltip(this.btnDelLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Delete", "", "Deletes an unused library document.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
|
||||
this.btnDelLibDoc.TabIndex = 13;
|
||||
this.btnDelLibDoc.Text = "Delete";
|
||||
@ -375,5 +388,6 @@ namespace Volian.Controls.Library
|
||||
private System.Windows.Forms.ListBox listBoxUsages;
|
||||
private DevComponents.DotNetBar.Controls.GroupPanel groupPanelUsages;
|
||||
private DevComponents.DotNetBar.SuperTooltip superTooltipLibDocs;
|
||||
private System.Windows.Forms.Button btnPrint;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,13 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Events
|
||||
public event DisplayLibDocEvent PrintRequest;
|
||||
private void OnPrintRequest(DisplayLibDocEventArgs args)
|
||||
{
|
||||
if (PrintRequest != null)
|
||||
PrintRequest(this, args);
|
||||
}
|
||||
|
||||
private void listBoxLibDocs_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateUsageList();
|
||||
@ -268,5 +275,50 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void btnPrint_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnPrintRequest(new DisplayLibDocEventArgs("Library Document Usage",LibDocList));
|
||||
}
|
||||
}
|
||||
public class DisplayLibDocEventArgs
|
||||
{
|
||||
private string _ReportTitle;
|
||||
public string ReportTitle
|
||||
{
|
||||
get { return _ReportTitle; }
|
||||
set { _ReportTitle = value; }
|
||||
}
|
||||
private DocumentInfoList _libDocList;
|
||||
|
||||
public DocumentInfoList LibDocList
|
||||
{
|
||||
get { return _libDocList; }
|
||||
set { _libDocList = value; }
|
||||
}
|
||||
//private string _SearchString = null;
|
||||
//public string SearchString
|
||||
//{
|
||||
// get { return _SearchString; }
|
||||
// set { _SearchString = value; }
|
||||
//}
|
||||
//private string _TypesSelected;
|
||||
//public string TypesSelected
|
||||
//{
|
||||
// get { return _TypesSelected; }
|
||||
// set { _TypesSelected = value; }
|
||||
//}
|
||||
//private ICollection<ItemInfo> _MyItemInfoList;
|
||||
//public ICollection<ItemInfo> MyItemInfoList
|
||||
//{
|
||||
// get { return _MyItemInfoList; }
|
||||
// set { _MyItemInfoList = value; }
|
||||
//}
|
||||
public DisplayLibDocEventArgs(string reportTitle, DocumentInfoList libDocList)
|
||||
{
|
||||
_ReportTitle = reportTitle;
|
||||
_libDocList = libDocList;
|
||||
}
|
||||
}
|
||||
public delegate void DisplayLibDocEvent(object sender, DisplayLibDocEventArgs args);
|
||||
}
|
||||
|
@ -120,9 +120,6 @@
|
||||
<metadata name="superTooltipLibDocs.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="superTooltipLibDocs.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="listBoxLibDocs.SuperTooltip" xml:space="preserve">
|
||||
<value>Shows list of current library documents. The number preceding each document shows how many times it is used. By selecting one that has usages, ths list of usages will be shown below. By selecting one that has NO usages, it can be deleted or opened.</value>
|
||||
</data>
|
||||
|
@ -5,14 +5,22 @@ using VEPROMS.CSLA.Library;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text;
|
||||
using System.IO;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using System.Text.RegularExpressions;
|
||||
//using Volian.Generic;
|
||||
|
||||
namespace Volian.Print.Library
|
||||
{
|
||||
|
||||
public class PDFReport
|
||||
{
|
||||
public enum ReportType
|
||||
{
|
||||
SearchResults = 0,
|
||||
LibraryDocUsage = 1,
|
||||
ReferencedObjectsUsage = 2,
|
||||
TransitionUsage = 3
|
||||
}
|
||||
|
||||
private ICollection<ItemInfo> _ResultList;
|
||||
public ICollection<ItemInfo> ResultList
|
||||
{
|
||||
@ -50,12 +58,32 @@ namespace Volian.Print.Library
|
||||
get { return _SearchString; }
|
||||
set { _SearchString = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(value); }
|
||||
}
|
||||
private DocumentInfoList _LibDocList;
|
||||
public DocumentInfoList LibDocList
|
||||
{
|
||||
get { return _LibDocList; }
|
||||
set { _LibDocList = value; }
|
||||
}
|
||||
private int _ReportType = 0;
|
||||
private string _ByLine;
|
||||
|
||||
public PDFReport(string reportTitle, string typesSelected, ICollection<ItemInfo> resultList, string fileName)
|
||||
{
|
||||
_ResultList = resultList;
|
||||
_FileName = fileName;
|
||||
_ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle);
|
||||
_TypesSelected = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(typesSelected);
|
||||
_ReportType = (int)ReportType.SearchResults;
|
||||
_ByLine = "PROMS Search Results";
|
||||
|
||||
}
|
||||
public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName)
|
||||
{
|
||||
_LibDocList = libDocList;
|
||||
_FileName = fileName;
|
||||
_ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle);
|
||||
_ReportType = (int)ReportType.LibraryDocUsage;
|
||||
_ByLine = "Generated By PROMS";
|
||||
}
|
||||
//public void Build2()
|
||||
//{
|
||||
@ -163,7 +191,7 @@ namespace Volian.Print.Library
|
||||
// cell.BackgroundColor = bgColor;
|
||||
// datatable.AddCell(cell);
|
||||
//}
|
||||
private string AddGroup(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor)
|
||||
private string AddGroup(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst)
|
||||
{
|
||||
int level = 0;
|
||||
string retval = "";
|
||||
@ -174,13 +202,14 @@ namespace Volian.Print.Library
|
||||
string sep = "";
|
||||
bool foundMisMatch = false;
|
||||
int n = NewPath.Length;
|
||||
int jstart = (skipFirst) ? 1 : 0;
|
||||
if (StripLast)
|
||||
{
|
||||
retval = NewPath[--n];
|
||||
if (retval.Contains("\x11"))
|
||||
retval = retval.Substring(0, retval.IndexOf("\x11"));
|
||||
}
|
||||
for (int j = 0; j < n; j++)
|
||||
for (int j = jstart; j < n; j++)
|
||||
{
|
||||
if (NewPath[j] != "" && (foundMisMatch || OldPath.Length < j + 1 || NewPath[j] != OldPath[j]))
|
||||
{
|
||||
@ -200,13 +229,104 @@ namespace Volian.Print.Library
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private string GetCurProcNum(string path)
|
||||
{
|
||||
string[] NewPath = path.Split("\x7".ToCharArray());
|
||||
return NewPath[1];
|
||||
}
|
||||
private int FindSpitLevel()
|
||||
{
|
||||
int level = 0;
|
||||
bool foundMisMatch = false;
|
||||
string lastPath = "";
|
||||
foreach (string p in ProcSetList)
|
||||
{
|
||||
string[] NewPath = p.Split("\x7".ToCharArray());
|
||||
if (lastPath != "")
|
||||
{
|
||||
string[] OldPath = lastPath.Split("\x7".ToCharArray());
|
||||
int n = NewPath.Length;
|
||||
int lvl = 0;
|
||||
foundMisMatch = false;
|
||||
for (int j = 0; j < n && !foundMisMatch; j++)
|
||||
{
|
||||
if (NewPath[j] != "" && (OldPath.Length < j + 1 || NewPath[j] != OldPath[j]))
|
||||
foundMisMatch = true;
|
||||
lvl++;
|
||||
}
|
||||
if (level == 0) level = lvl;
|
||||
if (foundMisMatch)
|
||||
level = Math.Min(level, lvl);
|
||||
}
|
||||
lastPath = p;
|
||||
if (ProcSetList.Count == 1)
|
||||
level = NewPath.Length + 1;
|
||||
}
|
||||
if (level > 0) level--;
|
||||
return level;
|
||||
}
|
||||
public void AddMainPathGroup(PdfPTable datatable, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan)
|
||||
{
|
||||
int level = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string[] NewPath = dvPath.Split("\x7".ToCharArray());
|
||||
string sep = "";
|
||||
int n = NewPath.Length;
|
||||
for (int j = 1; j < n && j < splitLevel; j++)
|
||||
{
|
||||
sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-");
|
||||
sep = "\r\n";
|
||||
level++;
|
||||
}
|
||||
if (sb.ToString() != "")
|
||||
{
|
||||
PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2));
|
||||
cell.Colspan = colSpan;
|
||||
cell.BackgroundColor = bgColor;
|
||||
cell.BorderWidthTop = 1;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
}
|
||||
public void AddSubPathGroup(PdfPTable datatable, string dvPath, int splitLevel, Font f2, Color bgColor, int colSpan)
|
||||
{
|
||||
int level = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string[] NewPath = dvPath.Split("\x7".ToCharArray());
|
||||
string sep = "";
|
||||
int n = NewPath.Length;
|
||||
if (splitLevel < n)
|
||||
{
|
||||
for (int j = splitLevel; j < n; j++)
|
||||
{
|
||||
sb.Append(sep + "".PadLeft(2 * level) + NewPath[j].Replace("\x11", " ")).Replace(@"\u8209?", "-");
|
||||
sep = "\r\n";
|
||||
level++;
|
||||
}
|
||||
if (sb.ToString() != "")
|
||||
{
|
||||
PdfPCell cell = new PdfPCell(new Phrase(sb.ToString(), f2));
|
||||
cell.Colspan = colSpan;
|
||||
cell.BackgroundColor = bgColor;
|
||||
cell.BorderWidthTop = 1;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Build()
|
||||
{
|
||||
iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36);
|
||||
if (!CreateResultsPDF(document)) return;
|
||||
try
|
||||
{
|
||||
BuildTable1(document);
|
||||
switch (_ReportType) // set in the PDFReport constructor
|
||||
{
|
||||
case (int)ReportType.SearchResults:
|
||||
BuildSearchResultsTable(document);
|
||||
break;
|
||||
case (int)ReportType.LibraryDocUsage:
|
||||
BuildLibDocUsageReport(document);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -247,7 +367,7 @@ namespace Volian.Print.Library
|
||||
try
|
||||
{
|
||||
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
|
||||
writer.PageEvent = new MyPageHelper(); // JSJ - 7/8/2011
|
||||
writer.PageEvent = new MyPageHelper(_ByLine); // JSJ - 7/8/2011
|
||||
document.SetMargins(36, 36, 36, 36);
|
||||
document.Open();
|
||||
_FileName = fileName;
|
||||
@ -291,11 +411,12 @@ namespace Volian.Print.Library
|
||||
/// Use Cells within Cells to see if I can limit the way Cells break from Page to Page
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private void BuildTable1(iTextSharp.text.Document document)
|
||||
private void BuildSearchResultsTable(iTextSharp.text.Document document)
|
||||
{
|
||||
float[] headerwidths = { 20, 80 };
|
||||
PdfPTable datatable = new PdfPTable(headerwidths);
|
||||
datatable.HeaderRows = 3;
|
||||
PdfPTable datatable = new PdfPTable(1);
|
||||
PdfPTable colHeader = new PdfPTable(headerwidths);
|
||||
datatable.HeaderRows = 4;
|
||||
//datatable.FooterRows = 1;
|
||||
datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
|
||||
datatable.LockedWidth = true;
|
||||
@ -309,19 +430,27 @@ namespace Volian.Print.Library
|
||||
//iTextSharp.text.Font f3 = pdf.GetFont("Prestige Elite Tall", 9, 0, Color.BLACK);
|
||||
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1));
|
||||
cell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
cell.Colspan = 2;
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0);
|
||||
datatable.AddCell(cell);
|
||||
cell = new PdfPCell(new Phrase(TypesSelected,f3));
|
||||
cell.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||
cell.Colspan = 2;
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0);
|
||||
datatable.AddCell(cell);
|
||||
|
||||
BuildSearchResultsProcSetList();
|
||||
int splitAt = FindSpitLevel(); // find the split level of the common path - for all procedure sets that use these library documents
|
||||
AddMainPathGroup(datatable, ProcSetList[0].ToString(), splitAt, f2, Color.LIGHT_GRAY, 0);
|
||||
|
||||
Color subHeaderColor = new Color(0xD0, 0xF0, 0xD0);
|
||||
datatable.DefaultCell.Padding = 4;
|
||||
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
AddCell(datatable, "Step", f2, subHeaderColor);
|
||||
AddCell(datatable, "Text", f2, subHeaderColor);
|
||||
//AddCell(datatable, "Step", f2, subHeaderColor);
|
||||
//AddCell(datatable, "Text", f2, subHeaderColor);
|
||||
AddCell(colHeader, "Step", f2, subHeaderColor);
|
||||
AddCell(colHeader, "Text", f2, subHeaderColor);
|
||||
datatable.AddCell(colHeader);
|
||||
// This puts "Step" and "Text" column headers at the bottom of the page
|
||||
//AddCell(datatable, "Step", f2, subHeaderColor);
|
||||
//AddCell(datatable, "Text", f2, subHeaderColor);
|
||||
@ -330,29 +459,47 @@ namespace Volian.Print.Library
|
||||
string lastPath = "";
|
||||
Color AnnoColor = new Color(0xFF, 0xFF, 0xC0);
|
||||
Color TextColor = Color.WHITE;
|
||||
Color SectColor = Color.LIGHT_GRAY;
|
||||
Color SectColor = new Color(0xE0, 0xFF, 0xE0);//new Color(0xC0, 0xFF, 0xC0);//Color.LIGHT_GRAY;
|
||||
PdfPTable subTable = new PdfPTable(headerwidths);
|
||||
string lastProcNum = "";
|
||||
foreach (ItemInfo item in _ResultList)
|
||||
{
|
||||
if (item.SearchDVPath != lastDvPath)
|
||||
AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, new Color(0xC0, 0xFF, 0xC0));
|
||||
string curProcNum = GetCurProcNum(item.SearchPath);
|
||||
if (lastProcNum != "" && curProcNum != lastProcNum)
|
||||
{
|
||||
datatable.AddCell(subTable);
|
||||
subTable = new PdfPTable(headerwidths);
|
||||
}
|
||||
lastProcNum = curProcNum;
|
||||
//if (item.SearchDVPath != lastDvPath)
|
||||
// AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, Color.LIGHT_GRAY, true);
|
||||
|
||||
//AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, new Color(0xC0, 0xFF, 0xC0), true);
|
||||
lastDvPath = item.SearchDVPath;
|
||||
string stepPath = AddGroup(datatable, item.SearchPath, lastPath, f2, true, new Color(0xE0, 0xFF, 0xE0));
|
||||
//string stepPath = AddGroup(datatable, item.SearchPath, lastPath, f2, true, new Color(0xE0, 0xFF, 0xE0), true);
|
||||
//string stepPath = AddGroup(datatable, item.SearchPath, lastPath, f2, true, new Color(0xC0, 0xFF, 0xC0), true);
|
||||
string stepPath = AddGroup(subTable, item.SearchPath, lastPath, f2, true, new Color(0xC0, 0xFF, 0xC0), true);
|
||||
lastPath = item.SearchPath;
|
||||
AddCell(datatable, stepPath, f2, (item.IsSection ? SectColor : TextColor));
|
||||
//AddCell(datatable, stepPath, f2, (item.IsSection ? SectColor : TextColor));
|
||||
AddCell(subTable, stepPath, f2, (item.IsSection ? SectColor : TextColor));
|
||||
// This was for the old 16-bit style of table - jsj 7/7/2011
|
||||
//if (item.DisplayText.Contains("|")) // Need a better way to determine if it is a table.
|
||||
// AddCell(datatable, item.DisplayText, f3, TextColor);
|
||||
//else
|
||||
AddCell(datatable, item.DisplayText, f2, (item.IsSection ? SectColor : TextColor));
|
||||
if (item.ItemAnnotationCount > 0)
|
||||
//AddCell(datatable, item.DisplayText, f2, (item.IsSection ? SectColor : TextColor));
|
||||
AddCell(subTable, item.DisplayText, f2, (item.IsSection ? SectColor : TextColor));
|
||||
if (item.ItemAnnotationCount > 0)
|
||||
{
|
||||
foreach (AnnotationInfo ai in item.ItemAnnotations)
|
||||
{
|
||||
AddCell(datatable, ai.MyAnnotationType.Name, f2, AnnoColor);
|
||||
AddCell(datatable, ai.SearchText, f2, AnnoColor);
|
||||
//AddCell(datatable, ai.MyAnnotationType.Name, f2, AnnoColor);
|
||||
//AddCell(datatable, ai.SearchText, f2, AnnoColor);
|
||||
AddCell(subTable, ai.MyAnnotationType.Name, f2, AnnoColor);
|
||||
AddCell(subTable, ai.SearchText, f2, AnnoColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
datatable.AddCell(subTable);
|
||||
document.Add(datatable);
|
||||
}
|
||||
private void AddCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor)
|
||||
@ -365,6 +512,18 @@ namespace Volian.Print.Library
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
|
||||
private void AddColSpanCell(PdfPTable datatable, string str, iTextSharp.text.Font fnt, Color bgColor, int span, int txtAlign)
|
||||
{
|
||||
iTextSharp.text.Font fntBold = new Font(fnt.BaseFont, fnt.Size, Font.BOLD, Color.RED);
|
||||
Phrase p = BuildPhrase2(str, fnt, fntBold);
|
||||
PdfPCell cell = new PdfPCell(p);
|
||||
cell.PaddingBottom = 4;
|
||||
cell.BackgroundColor = bgColor;
|
||||
cell.Colspan = span;
|
||||
cell.HorizontalAlignment = txtAlign;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
|
||||
private Phrase BuildPhrase(string str, Font fnt, Font fntBold)
|
||||
{
|
||||
Phrase p = new Phrase();
|
||||
@ -421,14 +580,148 @@ namespace Volian.Print.Library
|
||||
p.Add(new Phrase(str.Substring(lastIndex), fnt));
|
||||
return p;
|
||||
}
|
||||
private void BuildLibDocUsageReport(iTextSharp.text.Document document)
|
||||
{
|
||||
float[] headerwidths = { 20, 80 };
|
||||
PdfPTable datatable = new PdfPTable(1);// (headerwidths);
|
||||
PdfPTable colheader = new PdfPTable(headerwidths);
|
||||
datatable.HeaderRows = 3;
|
||||
datatable.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
|
||||
datatable.LockedWidth = true;
|
||||
iTextSharp.text.Font f1 = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK);
|
||||
iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK);
|
||||
iTextSharp.text.Font f3 = pdf.GetFont("Arial Unicode MS", 12, 0, Color.BLACK);
|
||||
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1));
|
||||
cell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0);
|
||||
datatable.AddCell(cell);
|
||||
|
||||
BuildLibDocProcSetList();
|
||||
int splitAt = FindSpitLevel(); // find the split level of the common path - for all procedure sets that use these library documents
|
||||
AddMainPathGroup(datatable, ProcSetList[0].ToString(), splitAt, f2, Color.LIGHT_GRAY, 0);//2);
|
||||
|
||||
Color subHeaderColor = new Color(0xD0, 0xF0, 0xD0);
|
||||
datatable.DefaultCell.Padding = 4;
|
||||
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
//AddCell(datatable, "Procedure", f2, subHeaderColor);
|
||||
//AddCell(datatable, "Section", f2, subHeaderColor);
|
||||
AddCell(colheader, "Procedure", f2, subHeaderColor);
|
||||
AddCell(colheader, "Section", f2, subHeaderColor);
|
||||
datatable.AddCell(colheader);
|
||||
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||
string lastDvPath = "";
|
||||
Color AnnoBackgroundColor = new Color(0xFF, 0xFF, 0xC0);
|
||||
Color TextBackgroundColor = Color.WHITE;
|
||||
Color NotUsedBackgroundColor = Color.WHITE;
|
||||
//BuildProcSetList();
|
||||
//int splitAt = FindSpitLevel(); // find the split level of the common path - for all procedure sets that use these library documents
|
||||
//bool doMainProcSetpath = true;
|
||||
foreach (DocumentInfo di in _LibDocList)
|
||||
{
|
||||
PdfPTable subtable = new PdfPTable(headerwidths);
|
||||
subtable.HeaderRows = 0;
|
||||
//if (doMainProcSetpath)
|
||||
//{
|
||||
// AddMainPathGroup(datatable, ProcSetList[0].ToString(), splitAt, f2, Color.LIGHT_GRAY, 0);//2);
|
||||
// doMainProcSetpath = false;
|
||||
//}
|
||||
//AddGroup(datatable, di.DocumentTitle, "", f2, false, new Color(0xC0, 0xFF, 0xC0)); // Library Document Title
|
||||
AddGroup(subtable, di.DocumentTitle, "", f2, false, new Color(0xC0, 0xFF, 0xC0), false); // Library Document Title
|
||||
if (di.DocumentConfig.LibDoc_Comment != null && di.DocumentConfig.LibDoc_Comment.Length > 0)
|
||||
{
|
||||
//AddCell(datatable, "Comment", f2, AnnoBackgroundColor);
|
||||
//AddCell(datatable, di.DocumentConfig.LibDoc_Comment, f2, AnnoBackgroundColor); // lib doc comment
|
||||
AddCell(subtable, "Comment", f2, AnnoBackgroundColor);
|
||||
AddCell(subtable, di.DocumentConfig.LibDoc_Comment, f2, AnnoBackgroundColor); // lib doc comment
|
||||
}
|
||||
if (di.DocumentEntries == null || di.DocumentEntries.Count == 0)
|
||||
{
|
||||
//AddColSpanCell(datatable, "*No References To This Library Document", f2, NotUsedBackgroundColor, 2, Element.ALIGN_LEFT);
|
||||
AddColSpanCell(subtable, "*No References To This Library Document", f2, NotUsedBackgroundColor, 2, Element.ALIGN_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Collections.ArrayList LibDocUsageList = GetSortedItemInfoList(di.LibraryDocumentUsageList);
|
||||
lastDvPath = "";
|
||||
foreach (ItemInfo item in LibDocUsageList)//di.LibraryDocumentUsageList)
|
||||
{
|
||||
string ProcNumber = item.MyProcedure.ProcedureConfig.Number;
|
||||
ProcNumber = ProcNumber.Replace(@"\u8209?", "-"); // repace unicode with dash char
|
||||
ProcNumber = ProcNumber.Replace(@"\u160?", " "); // replace Hard Space with normal Space
|
||||
//if (item.SearchDVPath != lastDvPath)
|
||||
// AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, Color.LIGHT_GRAY);//new Color(0xC0, 0xFF, 0xC0));
|
||||
//if (item.SearchDVPath != lastDvPath)
|
||||
// AddSubPathGroup(datatable, item.SearchDVPath,splitAt, f2, Color.LIGHT_GRAY, 2);//new Color(0xC0, 0xFF, 0xC0));
|
||||
if (item.SearchDVPath != lastDvPath)
|
||||
AddSubPathGroup(subtable, item.SearchDVPath, splitAt, f2, Color.LIGHT_GRAY, 2);//new Color(0xC0, 0xFF, 0xC0));
|
||||
lastDvPath = item.SearchDVPath;
|
||||
//AddCell(datatable, ProcNumber, f2, TextBackgroundColor);
|
||||
//AddCell(datatable, item.MyContent.Number + " - " + item.MyContent.Text, f2, TextBackgroundColor);
|
||||
AddCell(subtable, ProcNumber, f2, TextBackgroundColor);
|
||||
AddCell(subtable, item.MyContent.Number + " - " + item.MyContent.Text, f2, TextBackgroundColor);
|
||||
}
|
||||
}
|
||||
datatable.AddCell(subtable);
|
||||
}
|
||||
document.Add(datatable);
|
||||
}
|
||||
private System.Collections.ArrayList ProcSetList;
|
||||
private void BuildSearchResultsProcSetList()
|
||||
{
|
||||
ProcSetList = new System.Collections.ArrayList();
|
||||
foreach (ItemInfo item in _ResultList)
|
||||
{
|
||||
if (!ProcSetList.Contains(item.SearchDVPath))
|
||||
ProcSetList.Add(item.SearchDVPath);
|
||||
}
|
||||
}
|
||||
private void BuildLibDocProcSetList()
|
||||
{
|
||||
ProcSetList = new System.Collections.ArrayList();
|
||||
foreach (DocumentInfo di in _LibDocList)
|
||||
{
|
||||
if (di.LibraryDocumentUsageList!= null && di.LibraryDocumentUsageList.Count > 0)
|
||||
foreach (ItemInfo item in di.LibraryDocumentUsageList)
|
||||
{
|
||||
if (!ProcSetList.Contains(item.SearchDVPath))
|
||||
ProcSetList.Add(item.SearchDVPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
private System.Collections.ArrayList GetSortedItemInfoList(ItemInfoList orgIFL)
|
||||
{
|
||||
//ICollection<ItemInfo> rtnIFL;
|
||||
//get list of different procedure sets
|
||||
System.Collections.ArrayList libDocProcSetList = new System.Collections.ArrayList();
|
||||
System.Collections.ArrayList rtnIFL = new System.Collections.ArrayList();
|
||||
foreach (ItemInfo item in orgIFL)
|
||||
{
|
||||
if (!libDocProcSetList.Contains(item.SearchDVPath))
|
||||
libDocProcSetList.Add(item.SearchDVPath);
|
||||
}
|
||||
foreach (string pset in libDocProcSetList)
|
||||
{
|
||||
foreach (ItemInfo item in orgIFL)
|
||||
{
|
||||
if (item.SearchDVPath.Equals(pset))
|
||||
rtnIFL.Add(item);
|
||||
}
|
||||
}
|
||||
return rtnIFL;
|
||||
}
|
||||
}
|
||||
public class MyPageHelper : PdfPageEventHelper
|
||||
{
|
||||
protected PdfTemplate total;
|
||||
protected BaseFont helv;
|
||||
private int ptSize = 10; // text point size of page number and page total
|
||||
string _ByLine = "PROMS";
|
||||
|
||||
public MyPageHelper(string byLine)
|
||||
{
|
||||
_ByLine = byLine;
|
||||
}
|
||||
public override void OnOpenDocument(PdfWriter writer, iTextSharp.text.Document document)
|
||||
{
|
||||
total = writer.DirectContent.CreateTemplate(100, 100);
|
||||
@ -482,7 +775,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
PdfContentByte cb = writer.DirectContent;
|
||||
cb.SaveState();
|
||||
String text = "PROMS Search Results";
|
||||
String text = _ByLine;//"PROMS Search Results";
|
||||
float textBase = document.Bottom - 19;//20;
|
||||
float textSize = helv.GetWidthPoint(text, ptSize);
|
||||
cb.BeginText();
|
||||
|
Loading…
x
Reference in New Issue
Block a user