Logic to call the function to create the RO Summary Report
Added functions to for use in generating the RO Summary Report Enabled the RO Summary Report and added logic to support the gathering of information for the report Added logic to generate the RO Summary Report
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Volian.Print.Library
|
||||
ReferencedObjectsUsage = 2,
|
||||
TransitionUsage = 3,
|
||||
ReferencedObjectSummary = 4,
|
||||
ReferencedObjectComplete =5
|
||||
ReferencedObjectComplete = 5
|
||||
}
|
||||
|
||||
private ICollection<ItemInfo> _ResultList;
|
||||
@@ -70,6 +70,8 @@ namespace Volian.Print.Library
|
||||
private string _ByLine;
|
||||
private bool _SortUsageByProcedure = false;
|
||||
private string _RODataFile = "";
|
||||
private List<string> _ROList;
|
||||
private ROFSTLookup _ROFSTLookup;
|
||||
|
||||
// Search Results Report
|
||||
public PDFReport(string reportTitle, string typesSelected, ICollection<ItemInfo> resultList, string fileName)
|
||||
@@ -82,7 +84,7 @@ namespace Volian.Print.Library
|
||||
_ByLine = "PROMS Search Results";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Library Document Report
|
||||
public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName)
|
||||
{
|
||||
@@ -104,16 +106,27 @@ namespace Volian.Print.Library
|
||||
_SortUsageByProcedure = sortUsageByProcedure;
|
||||
}
|
||||
|
||||
// RO Coomplete and Summary Reports
|
||||
// RO Complete Report
|
||||
public PDFReport(string reportTitle, string roDataFile, string outfile, bool completeReport)
|
||||
{
|
||||
_FileName = outfile;
|
||||
_ReportTitle = reportTitle;
|
||||
_ReportType = (completeReport) ? (int)ReportType.ReferencedObjectComplete : (int)ReportType.ReferencedObjectSummary;
|
||||
_ByLine = (completeReport) ? "Complete RO Report" : "Summary RO Report";
|
||||
_ReportType = (int)ReportType.ReferencedObjectComplete;
|
||||
_ByLine = "Complete RO Report";
|
||||
_RODataFile = roDataFile;
|
||||
}
|
||||
|
||||
// RO Summary Report
|
||||
public PDFReport(string reportTitle, string outfile, ROFSTLookup fstlookup, List<string> roList)
|
||||
{
|
||||
_FileName = outfile;
|
||||
_ReportTitle = reportTitle;
|
||||
_ReportType = (int)ReportType.ReferencedObjectSummary;
|
||||
_ByLine = "RO Summary Report";
|
||||
_ROFSTLookup = fstlookup;
|
||||
_ROList = roList;
|
||||
}
|
||||
|
||||
//public void Build2()
|
||||
//{
|
||||
// iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36);
|
||||
@@ -343,11 +356,12 @@ namespace Volian.Print.Library
|
||||
}
|
||||
lastPath = p;
|
||||
if (ProcSetList.Count == 1)
|
||||
level = NewPath.Length-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;
|
||||
@@ -418,6 +432,9 @@ namespace Volian.Print.Library
|
||||
case (int)ReportType.ReferencedObjectComplete:
|
||||
BuildCompleteROReport(document);
|
||||
break;
|
||||
case (int)ReportType.ReferencedObjectSummary:
|
||||
BuildROSummaryReport(document);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -468,7 +485,7 @@ namespace Volian.Print.Library
|
||||
catch (System.IO.IOException exIO)
|
||||
{
|
||||
|
||||
if (exIO.Message.Contains("because it is being used by another process"))
|
||||
if (exIO.Message.Contains("because it is being used by another process"))
|
||||
suffix = string.Format("_{0}", ++i);// If this file is in use, increment the suffix and try again
|
||||
else // If some other error, display a message and don't print the results
|
||||
{
|
||||
@@ -524,14 +541,14 @@ namespace Volian.Print.Library
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0);
|
||||
datatable.AddCell(cell);
|
||||
cell = new PdfPCell(new Phrase(TypesSelected,f3));
|
||||
cell = new PdfPCell(new Phrase(TypesSelected, f3));
|
||||
cell.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = new Color(0xD0, 0xF0, 0xF0);
|
||||
datatable.AddCell(cell);
|
||||
|
||||
BuildSearchResultsProcSetList();
|
||||
datatable.HeaderRows = 3 + (ProcSetList.Count ==1 ? 1 : 0);
|
||||
datatable.HeaderRows = 3 + (ProcSetList.Count == 1 ? 1 : 0);
|
||||
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);
|
||||
|
||||
@@ -589,9 +606,9 @@ namespace Volian.Print.Library
|
||||
//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));
|
||||
//AddCell(datatable, item.DisplayText, f2, (item.IsSection ? SectColor : TextColor));
|
||||
AddCell(subTable, item.DisplayText, f2, (item.IsSection ? SectColor : TextColor));
|
||||
if (item.ItemAnnotationCount > 0)
|
||||
if (item.ItemAnnotationCount > 0)
|
||||
{
|
||||
foreach (AnnotationInfo ai in item.ItemAnnotations)
|
||||
{
|
||||
@@ -658,9 +675,9 @@ namespace Volian.Print.Library
|
||||
if (_RegexSearchString.StartsWith(".*?"))
|
||||
_RegexSearchString = "^" + _RegexSearchString;
|
||||
// If search string ends with a wildcard use the end of line token ($)
|
||||
if(_RegexSearchString.EndsWith(".*?"))
|
||||
_RegexSearchString = _RegexSearchString+"$";
|
||||
_RegexSearchString = _RegexSearchString.Replace("[", @"\[");
|
||||
if (_RegexSearchString.EndsWith(".*?"))
|
||||
_RegexSearchString = _RegexSearchString + "$";
|
||||
_RegexSearchString = _RegexSearchString.Replace("[", @"\[");
|
||||
_RegexSearchString = _RegexSearchString.Replace("]", @"\]");
|
||||
}
|
||||
return _RegexSearchString;
|
||||
@@ -774,7 +791,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
document.Add(datatable);
|
||||
}
|
||||
private void AddROUsages(ItemInfo item, Dictionary<string,List<ItemInfo>> roUse)
|
||||
private void AddROUsages(ItemInfo item, Dictionary<string, List<ItemInfo>> roUse)
|
||||
{
|
||||
//string lastROid = "";
|
||||
if (item.FoundROID != null && item.FoundROID != "")
|
||||
@@ -826,7 +843,7 @@ namespace Volian.Print.Library
|
||||
stepnum = itm.MyActiveSection.DisplayNumber;
|
||||
else
|
||||
stepnum = BuildStepTab(itm);//GetStepNumberFromSearchPath(itm.SearchPath);//stepnum.Substring(itm.SearchPath.LastIndexOf(sectitle) + sectitle.Length +1);
|
||||
// stepnum = stepnum.Substring(stepnum.LastIndexOf("\a") + 1);
|
||||
// stepnum = stepnum.Substring(stepnum.LastIndexOf("\a") + 1);
|
||||
//AddCell(curTable, stepnum, f2, Color.WHITE);
|
||||
//AddCell(curTable, itm.DisplayText, f2, Color.WHITE);
|
||||
AddCell(rotable, stepnum, f2, Color.WHITE);
|
||||
@@ -868,7 +885,7 @@ namespace Volian.Print.Library
|
||||
string stpdelms = item.ActiveFormat.PlantFormat.FormatData.TransData.StepSubstepDelimeter;
|
||||
foreach (char c in stpdelms)
|
||||
{
|
||||
if (!DelimList.Contains(c.ToString()))
|
||||
if (!DelimList.Contains(c.ToString()))
|
||||
DelimList.Add(c.ToString());
|
||||
}
|
||||
}
|
||||
@@ -910,7 +927,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// add the Caution or Note count to the tab (ex "Caution 1", "Note 2")
|
||||
if (thisTab == "")
|
||||
sret = "{" + typeName + " " + pitem.Ordinal.ToString() + "}";
|
||||
sret = "{" + typeName + " " + pitem.Ordinal.ToString() + "}";
|
||||
else
|
||||
{
|
||||
thisTab = thisTab.Trim(" ".ToCharArray());
|
||||
@@ -938,16 +955,16 @@ namespace Volian.Print.Library
|
||||
if (pitem.IsHigh)
|
||||
{
|
||||
StepInfo stpinfo = StepInfo.Get(pitem.ItemID);
|
||||
|
||||
|
||||
string hlsTab = stpinfo.MyTab.CleanTextNoSymbols; //StepInfo.Get(pitem.ItemID).MyTab.CleanTextNoSymbols;
|
||||
//string thisTab = stpinfo.MyTab.CleanText; //StepInfo.Get(pitem.ItemID).MyTab.CleanText;
|
||||
string typeName = stpinfo.FormatStepData.StepEditData.TypeMenu.MenuItem;//stpinfo.FormatStepData.GetPDDisplayName(); //.ToString();
|
||||
if (hlsTab == null || hlsTab == "")
|
||||
hlsTab = "{" + typeName + " "+ pitem.Ordinal.ToString()+"}.";
|
||||
hlsTab = "{" + typeName + " " + pitem.Ordinal.ToString() + "}.";
|
||||
else if (!sret.StartsWith(hlsTab.Trim(" ".ToCharArray())))
|
||||
{
|
||||
//if (!hasDelim)
|
||||
foreach (string rmvDelim in DelimList) hlsTab = hlsTab.Replace(rmvDelim, "");
|
||||
foreach (string rmvDelim in DelimList) hlsTab = hlsTab.Replace(rmvDelim, "");
|
||||
hlsTab = hlsTab.Trim(" ".ToCharArray());
|
||||
//if (hasDelim && !hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) hlsTab = hlsTab + ".";
|
||||
if (!hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) hlsTab = hlsTab + ".";
|
||||
@@ -1124,10 +1141,11 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetROTitleAndGroup(string roid, ItemInfo itm)
|
||||
//private static string GetROTitleAndGroup(string roid, ItemInfo itm)
|
||||
private string GetROTitleAndGroup(string roid, ItemInfo itm)
|
||||
{
|
||||
string rotitle = "";
|
||||
ROFSTLookup myrofstlookup = itm.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(itm.MyDocVersion);
|
||||
ROFSTLookup myrofstlookup = (itm == null)? _ROFSTLookup : itm.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(itm.MyDocVersion);
|
||||
List<string> roTitleList = myrofstlookup.GetROTitleAndGroupPath(roid);
|
||||
for (int cnt = 0; cnt < roTitleList.Count; cnt++)
|
||||
{
|
||||
@@ -1152,6 +1170,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BuildROUsageTableByRO(iTextSharp.text.Document document)
|
||||
{
|
||||
SortedDictionary<string, List<ItemInfo>> procRoUse = new SortedDictionary<string, List<ItemInfo>>();
|
||||
@@ -1200,9 +1219,9 @@ namespace Volian.Print.Library
|
||||
}
|
||||
lastDVPath = item.SearchDVPath;
|
||||
|
||||
// Chec for different ROID
|
||||
// Check for different ROID
|
||||
string curROID = item.FoundROID;
|
||||
if (lastROID == "" || curROID.Substring(0,12) != lastROID.Substring(0,12))
|
||||
if (lastROID == "" || curROID.Substring(0, 12) != lastROID.Substring(0, 12))
|
||||
{
|
||||
if (lastROID != "" && procRoUse.Count > 0)
|
||||
{
|
||||
@@ -1233,7 +1252,7 @@ namespace Volian.Print.Library
|
||||
ProcSetList = new System.Collections.ArrayList();
|
||||
foreach (DocumentInfo di in _LibDocList)
|
||||
{
|
||||
if (di.LibraryDocumentUsageList!= null && di.LibraryDocumentUsageList.Count > 0)
|
||||
if (di.LibraryDocumentUsageList != null && di.LibraryDocumentUsageList.Count > 0)
|
||||
foreach (ItemInfo item in di.LibraryDocumentUsageList)
|
||||
{
|
||||
if (!ProcSetList.Contains(item.SearchDVPath))
|
||||
@@ -1278,6 +1297,139 @@ namespace Volian.Print.Library
|
||||
//document.Add(prgh);
|
||||
document.Add(phrs);
|
||||
}
|
||||
private string GetROTitleAndGroupsForSummary(List<string>roTitleList, List<string> prevROTitleList)
|
||||
{
|
||||
string rotitle = "";
|
||||
string indent = "";
|
||||
for (int icnt = 0; icnt < roTitleList.Count; icnt++)
|
||||
{
|
||||
indent += " ";
|
||||
if (icnt == roTitleList.Count - 1)
|
||||
{
|
||||
rotitle += indent + roTitleList[icnt]; // this should be the ro description
|
||||
break; //break out of for loop
|
||||
}
|
||||
if (prevROTitleList == null || (icnt < roTitleList.Count && icnt < prevROTitleList.Count && prevROTitleList[icnt] != roTitleList[icnt]))
|
||||
{
|
||||
if (rotitle == "" && prevROTitleList != null)
|
||||
rotitle = "\n";
|
||||
rotitle += indent + roTitleList[icnt] + "\n";
|
||||
}
|
||||
}
|
||||
return rotitle;
|
||||
}
|
||||
private List<string> AddROHeaderGroupForSummary(PdfPTable datatable, string curROID,List<string> prevROTitleList, Font f2, Color bgColor)
|
||||
{
|
||||
List<string> roTitleList = _ROFSTLookup.GetROTitleAndGroupPath(curROID);
|
||||
string headerText = GetROTitleAndGroupsForSummary(roTitleList, prevROTitleList);
|
||||
if (headerText.Length > 0)
|
||||
{
|
||||
Paragraph pgh = new Paragraph(headerText, f2);
|
||||
PdfPCell cell = new PdfPCell(pgh);
|
||||
cell.FollowingIndent = 72;
|
||||
cell.Colspan = 2;
|
||||
cell.BorderColor = Color.WHITE;
|
||||
cell.BackgroundColor = Color.WHITE;//bgColor;
|
||||
cell.BorderWidthTop = 1;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
return roTitleList;
|
||||
}
|
||||
public void AddMainRODatabaseTitle(PdfPTable datatable, int dbTitleIndex, Font f2, Color bgColor)
|
||||
{
|
||||
string dbTitle = _ROFSTLookup.GetRODatabaseTitle(dbTitleIndex);
|
||||
PdfPCell cell = new PdfPCell(new Phrase(dbTitle, f2));
|
||||
cell.BorderColor = Color.WHITE;
|
||||
cell.Colspan = 2;
|
||||
cell.BackgroundColor = bgColor;
|
||||
//cell.BorderWidthTop = 1;
|
||||
datatable.AddCell(cell);
|
||||
return;
|
||||
}
|
||||
|
||||
private void BuildROSummaryReport(iTextSharp.text.Document document)
|
||||
{
|
||||
float[] headerwidths = { 10, 20, 80 };
|
||||
PdfPTable datatable = new PdfPTable(1);
|
||||
PdfPTable colHeader = new PdfPTable(headerwidths);
|
||||
PdfPTable databaseTitle = new PdfPTable(1);
|
||||
//datatable.FooterRows = 1;
|
||||
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, 1, Color.BLACK);
|
||||
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, f1));
|
||||
cell.HorizontalAlignment = Element.ALIGN_CENTER;
|
||||
//cell.Colspan = 2;
|
||||
cell.BackgroundColor = Color.WHITE;//new Color(0xD0, 0xF0, 0xF0); // light blue
|
||||
cell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(cell);
|
||||
|
||||
string roFSTDateTime = "RO.FST Created: " + _ROFSTLookup.GetRoFSTdts().ToLongDateString() + " @ " + _ROFSTLookup.GetRoFSTdts().ToShortTimeString() + "\n ";
|
||||
cell = new PdfPCell(new Phrase(roFSTDateTime, f2));
|
||||
cell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(cell);
|
||||
|
||||
datatable.HeaderRows = 2;//3 + (ProcSetList.Count == 1 ? 1 : 0);
|
||||
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
|
||||
string lastROID = "";
|
||||
List<string> prevROTitleList = null;
|
||||
int lastDBindex = -1;
|
||||
foreach (string curROID in _ROList)
|
||||
{
|
||||
string[] tmp = curROID.TrimEnd(',').Split(':'); //curROID.Split(':');// this is the RO FST id number (for plants with multiple RO FSTs)
|
||||
string rolst = (tmp.Length == 2)? tmp[1] : tmp[0];
|
||||
string[] roIdslst = rolst.Split(',');
|
||||
foreach (string cROID in roIdslst)
|
||||
{
|
||||
if (cROID == "") break;
|
||||
if (cROID.Length == 4)
|
||||
ProcessROdb(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID);
|
||||
else
|
||||
ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID);
|
||||
}
|
||||
}
|
||||
document.Add(datatable);
|
||||
}
|
||||
|
||||
private void ProcessROdb(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List<string> prevROTitleList, ref int lastDBindex, string cROID)
|
||||
{
|
||||
ROFSTLookup.rodbi roDBI = _ROFSTLookup.GetRODatabase(cROID);
|
||||
foreach (ROFSTLookup.rochild cld in roDBI.children)
|
||||
ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld);
|
||||
}
|
||||
|
||||
private void ProcessROChild(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List<string> prevROTitleList, ref int lastDBindex,ROFSTLookup.rochild cld)
|
||||
{
|
||||
if (cld.children == null) // leaf node
|
||||
ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid);
|
||||
else if (cld.children[0].ParentID == 0) // multiple return value
|
||||
ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld.roid);
|
||||
else
|
||||
foreach (ROFSTLookup.rochild gcld in cld.children)
|
||||
ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, gcld);
|
||||
}
|
||||
|
||||
private void ProcessROID(PdfPTable datatable, iTextSharp.text.Font f2, iTextSharp.text.Font f3, ref PdfPCell cell, ref string lastROID, ref List<string> prevROTitleList, ref int lastDBindex, string cROID)
|
||||
{
|
||||
int curDBindex = _ROFSTLookup.GetRODatabaseTitleIndex(cROID);// Convert.ToInt32(cROID.Substring(0, 4));
|
||||
if (lastDBindex == -1 || curDBindex != lastDBindex)
|
||||
{
|
||||
if (prevROTitleList != null)
|
||||
{
|
||||
// add blank line to separate groups on the report
|
||||
cell = new PdfPCell(new Phrase(" ", f2));
|
||||
cell.BorderColor = Color.WHITE;
|
||||
datatable.AddCell(cell);
|
||||
}
|
||||
AddMainRODatabaseTitle(datatable, curDBindex, f3, Color.WHITE);
|
||||
lastDBindex = curDBindex;
|
||||
}
|
||||
if (lastROID == "" || cROID != lastROID)
|
||||
prevROTitleList = AddROHeaderGroupForSummary(datatable, cROID, prevROTitleList, f2, new Color(0xC0, 0xFF, 0xC0));
|
||||
lastROID = cROID;
|
||||
}
|
||||
}
|
||||
public class MyPageHelper : PdfPageEventHelper
|
||||
{
|
||||
|
Reference in New Issue
Block a user