From 174bac97f791be953e79288015ff4effc5954b21 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 19 Dec 2014 19:46:27 +0000 Subject: [PATCH] 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 --- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 10 +- .../Config/ROFSTLookup.cs | 105 ++++++++- .../Volian.Controls.Library/DisplayReports.cs | 51 +++-- PROMS/Volian.Print.Library/PDFReport.cs | 204 +++++++++++++++--- 4 files changed, 319 insertions(+), 51 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 3798d55a..31f6a809 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -725,11 +725,17 @@ namespace VEPROMS Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.MyItemInfoList, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROUsageReport.pdf", args.SortUsageByProcedure); myReport.Build(); } - else if (args.TypesSelected == "RO Report") + else if (args.TypesSelected == "Complete RO Report") { - Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROCompleteReport.pdf", args.CompleteROReport); + Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.RODataFile, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\CompleteROReport.pdf", args.CompleteROReport); myReport.Build(); } + else if (args.TypesSelected == "RO Summary Report") + { + Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROSummaryReport.pdf", args.RofstLookup, args.ROListForReport); + myReport.Build(); + + } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index b047ad38..514c6778 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -146,10 +146,12 @@ namespace VEPROMS.CSLA.Library private int TableID; private Dictionary dicRos; private Dictionary dicRosIntIDs; + private Dictionary dicRoDBs; public void Reset() { dicRos = null; dicRosIntIDs = null; + dicRoDBs = null; } #endregion #region AppSupport @@ -160,6 +162,8 @@ namespace VEPROMS.CSLA.Library dicRosIntIDs = null; if (dicRos != null)dicRos.Clear(); dicRos = null; + if (dicRoDBs != null) dicRoDBs.Clear(); + dicRoDBs = null; } private Dictionary _dicROAPIDLookup; public string GetAccPageID(string roid) @@ -349,9 +353,39 @@ namespace VEPROMS.CSLA.Library } return ""; // no accessory page ID found } + // Get the the RO's Description + public string GetRoDescription(string ROID16) + { + string ROID = ROID16.Substring(0,12); + if (dicRos == null) ParseIntoDictionary(_ROFst!=null?_ROFst.ROLookup:_ROFstInfo.ROLookup); + // Use the ROID to get the value from the dictionary + if (dicRos.ContainsKey(ROID.ToUpper())) + { + rochild rochld = (rochild)dicRos[ROID.ToUpper()]; + if (rochld.value != null && rochld.value != string.Empty) + return rochld.title; + if (rochld.children != null) + { + foreach (rochild child in rochld.children) + if (child.roid.ToUpper() == ROID16 || (child.roid.EndsWith("0041") && ROID16.EndsWith("0000"))) + return child.title; + // if there isn't a specific match for multi-return values, default to the first child. + return rochld.children[0].title; + } + } + return ""; // no Title/Description found + } + //public string GetRoValueAccIDAndDescription(string ROID16) + //{ + // string rtnstr = GetRoValue(ROID16); + // rtnstr += " " + GetRoACID(ROID16); + // rtnstr += " " + GetRoDescription(ROID16); + // return rtnstr; + //} + public rochild GetRoChild12(string ROID16) { - string ROID = ROID16.Substring(0, 12); + string ROID = (ROID16.Length < 12)?ROID16 : ROID16.Substring(0, 12); if (dicRos == null) ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup); // Use the ROID to get the value from the dictionary if (dicRos.ContainsKey(ROID.ToUpper())) @@ -361,6 +395,8 @@ namespace VEPROMS.CSLA.Library } rochild tmp = new rochild(); tmp.ID = -1; + if (ROID16.Length == 4) + tmp.title = dicRoDBs[ROID16]; return tmp; } public rochild GetRoChild(string ROID) @@ -440,8 +476,12 @@ namespace VEPROMS.CSLA.Library { List titlePath = new List(); rochild roc = GetRoChild12(ROID); - //string tmp = roc.title.Replace(roc.appid, "").Replace(roc.value, "").Trim(); - string tmp = roc.title.Replace(roc.appid, string.Format("<{0}>",roc.appid)).Trim(); + string tmp = roc.title; + if (roc.appid != "") + if (roc.title.Contains(roc.appid)) + tmp = roc.title.Replace(roc.appid, string.Format("<{0}>", roc.appid)).Trim(); + else + tmp = string.Format("[{0}] {1}", roc.appid, roc.title); titlePath.Add(tmp); do { @@ -453,7 +493,26 @@ namespace VEPROMS.CSLA.Library titlePath.Reverse(); return titlePath; } - + public List GetROTitleAndGroupPathForSummary(string ROID) + { + List titlePath = new List(); + rochild roc = GetRoChild(ROID); + string tmp = roc.title.Replace(roc.appid, string.Format("<{0}>",roc.appid)).Trim(); + titlePath.Add(tmp); + do + { + string parent = ROID.Substring(0, 4) + string.Format("{0:X8}", roc.ParentID); + roc = GetRoChild(parent); + if (roc.ID > 0) + titlePath.Add(roc.title); + } while (roc.ID > 0); + titlePath.Reverse(); + return titlePath; + } + public DateTime GetRoFSTdts() + { + return MyDocVersionInfo.DocVersionAssociations[0].MyROFst.DTS; + } // The following Method is not correct. It needs to have a RO database id as well as an id. Without that, // the first RO with a specific id will be found regardless of the RO Database id. //public rochild GetRoChildFromID(int id) @@ -473,6 +532,42 @@ namespace VEPROMS.CSLA.Library { return myHdr.myDbs; } + public int GetRODatabaseTitleIndex(string roid) + { + rochild roc = GetRoChild12(roid); + int parentID = roc.ParentID; + return Convert.ToInt32("0x"+roid.Substring(0, 4),16); + } + public string GetRODatabaseTitle(string roid) + { + return GetRODatabaseTitle(GetRODatabaseTitleIndex(roid)); + } + public string GetRODatabaseTitle(int idx) + { + string dbtitle ="RO Database Title Not Found"; + for (int i = 0; i < myHdr.myDbs.Length; i++) + if (myHdr.myDbs[i].dbiID == idx) + { + dbtitle = myHdr.myDbs[i].dbiTitle; + break; + } + return dbtitle; + } + public rodbi GetRODatabase(int idx) + { + for (int i = 0; i < myHdr.myDbs.Length; i++) + if (myHdr.myDbs[i].dbiID == idx) + return myHdr.myDbs[i]; + return myHdr.myDbs[0]; + } + public rodbi GetRODatabase(string roid) + { + int idx = Convert.ToInt32("0x" + roid.Substring(0, 4), 16); + for (int i = 0; i < myHdr.myDbs.Length; i++) + if (myHdr.myDbs[i].dbiID == idx) + return myHdr.myDbs[i]; + return myHdr.myDbs[0]; + } //public string GetDefaultROPrefix() //{ // if (docVer != null) @@ -745,6 +840,7 @@ namespace VEPROMS.CSLA.Library { if (dicRos == null) dicRos = new Dictionary(); if (dicRosIntIDs == null) dicRosIntIDs = new Dictionary(); + if (dicRoDBs == null) dicRoDBs = new Dictionary(); myHdr.hSize = BitConverter.ToInt32(ab, 0); myHdr.hYear = BitConverter.ToInt16(ab, 4); @@ -775,6 +871,7 @@ namespace VEPROMS.CSLA.Library myHdr.myDbs[i].dbiTitle = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr)); iPtr = BitConverter.ToInt32(ab, offset + 26) + hdrOffset + 6; myHdr.myDbs[i].dbiAP = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr)); + dicRoDBs.Add(string.Format("{0:X4}",TableID), myHdr.myDbs[i].dbiTitle); } } #endregion diff --git a/PROMS/Volian.Controls.Library/DisplayReports.cs b/PROMS/Volian.Controls.Library/DisplayReports.cs index f0237d5a..0cc2e0bd 100644 --- a/PROMS/Volian.Controls.Library/DisplayReports.cs +++ b/PROMS/Volian.Controls.Library/DisplayReports.cs @@ -26,7 +26,6 @@ namespace Volian.Controls.Library } #endregion private List lstCheckedDocVersions = new List(); - //private List lstCheckedROs = new List(); private List lstCheckedROs = new List(); private List lstReportResults = new List(); private List ROList = new List(); @@ -95,9 +94,6 @@ namespace Volian.Controls.Library set { _ReportResult = value; - //if (value != null) // Don't select an item from the list when it is updated - // _ReportResult.ListChanged += new ListChangedEventHandler(_SearchResults_ListChanged); - //DisplayResults(); } } @@ -111,14 +107,12 @@ namespace Volian.Controls.Library foreach (object rolkup in lstCheckedROs) { if (rolkup is ROFSTLookup.rodbi) - { - rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("D4")); - } + rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("X4")); else if (rolkup is ROFSTLookup.rochild) { ch = (ROFSTLookup.rochild)rolkup; chld = ch.children; - rtnStr = _MyRODbID.ToString() + ":" + GetROChildren(rolkup); + rtnStr = _MyRODbID.ToString() + ":" + GetROChildren(rolkup).TrimEnd(','); } //else if (rolkup is ROFSTLookup.rogrp) // Console.WriteLine("RO Group"); @@ -135,16 +129,20 @@ namespace Volian.Controls.Library string rtnstr = ""; if (chld.children == null) // get a single ROID { - //ROFSTLookup.rochild ro = (ROFSTLookup.rochild)roObj; rtnstr += string.Format("{0}", chld.roid); if (rtnstr.Length == 12) rtnstr += "0000"; // last four digits are used for multiple return values } + else if (!cbxROUsage.Checked && chld.children[0].ParentID == 0) + { + rtnstr += string.Format("{0},", chld.roid); // doing a RO Summary or RO Complete report - don't want children that are multiple return values + } else { // spin through the child list and get the ROIDs. // if the child has children, then call this function recursivly foreach (ROFSTLookup.rochild roc in chld.children) { - if (roc.children != null) + // Don't get the children if we are doing a RO Summary or RO Complete report & children are the multiple return values + if (roc.children != null && (cbxROUsage.Checked || roc.children[0].ParentID != 0)) rtnstr += GetROChildren(roc); else rtnstr += string.Format("{0},", roc.roid); @@ -152,7 +150,7 @@ namespace Volian.Controls.Library } return rtnstr; } - private string GetListOfROs(bool keepREDbID) + private string GetListOfROs(bool keepRODbID) { string rtnStr = ""; string strRODbID = ""; @@ -163,7 +161,7 @@ namespace Volian.Controls.Library if (ndxOf > 0) { string tstr = rostr.Substring(0, ndxOf + 1); - if (tstr != strRODbID && keepREDbID) + if (tstr != strRODbID && keepRODbID) { strRODbID = tstr; rtnStr += rostr; @@ -186,7 +184,7 @@ namespace Volian.Controls.Library cmbxROUsageSort.SelectedIndex = 0; tabTransitionReports.Visible = false; cbxComplete.Enabled = false; - cbxSummary.Enabled = false; + cbxSummary.Enabled = true; } public void SelectReferencedObjectTab() @@ -234,6 +232,9 @@ namespace Volian.Controls.Library xpSetToReport.Enabled = cbxROUsage.Checked; xpSetToReport.Expanded = cbxROUsage.Checked; cmbxROUsageSort.Enabled = cbxROUsage.Checked; + // reset the RO tree and clear anything that was selected + advTreeROFillIn(true); + lstCheckedROs.Clear(); EnableOrDisablePrintButton(); } #region Procedure List @@ -602,7 +603,7 @@ namespace Volian.Controls.Library // TODO: KBR how to handle this? //Console.WriteLine("ro junk"); continue; - else if (chld[i].value == null) + else if (chld[i].value == null && (cbxROUsage.Checked || chld[i].children[0].ParentID != 0)) { tmp = new DevComponents.AdvTree.Node(); tmp.Text = chld[i].title; @@ -785,16 +786,15 @@ namespace Volian.Controls.Library Cursor = Cursors.WaitCursor; if (cbxSummary.Checked) // RO Summary Report { - //GenerateROList(); - //ROFSTLookup rofstLookup = Mydocversion.DocVersionAssociations[0].MyROFst.ROFSTLookup; - //OnPrintRequest(new DisplayReportsEventArgs("RO Summary Report", "RO Report", rofstLookup, ROList)); + GenerateROList(); + OnPrintRequest(new DisplayReportsEventArgs("RO Summary Report", "RO Summary Report", MyROFSTLookup, ROList)); } else if (cbxComplete.Checked) // Complete RO Report { GenerateROList(); string ROList = GetListOfROs(false);//don't include the RODbID in the RO list string roDataFile = BuildRODataFile(ROList); - OnPrintRequest(new DisplayReportsEventArgs("RO Complete Report", "RO Report", roDataFile, cbxComplete.Checked)); + OnPrintRequest(new DisplayReportsEventArgs("Complete RO Report", "Complete RO Report", roDataFile, cbxComplete.Checked)); } else if (cbxROUsage.Checked) { @@ -866,13 +866,19 @@ namespace Volian.Controls.Library get { return _rofstLookup; } set { _rofstLookup = value; } } + private List _ROListForReport; + + public List ROListForReport + { + get { return _ROListForReport; } + set { _ROListForReport = value; } + } public DisplayReportsEventArgs(string reportTitle, string typesSelected, ICollection myItemInfoList,/*ROFSTLookup rolkup,*/ bool sortByProcedure) { _ReportTitle = reportTitle; _TypesSelected = typesSelected; _MyItemInfoList = myItemInfoList; _SortUsageByProcedure = sortByProcedure; - //_rofstLookup = rolkup; } public DisplayReportsEventArgs(string reportTitle, string typesSelected, string roDataFile, bool completeROReport) { @@ -881,6 +887,13 @@ namespace Volian.Controls.Library _RODataFile = roDataFile; _CompleteROReport = completeROReport; } + public DisplayReportsEventArgs(string reportTitle, string typesSelected, ROFSTLookup rofstLookUp, List roListForReport) + { + _ReportTitle = reportTitle; + _TypesSelected = typesSelected; + _rofstLookup = rofstLookUp; + _ROListForReport = roListForReport; + } } public delegate void DisplayReportsEvent(object sender, DisplayReportsEventArgs args); } diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index fac0906d..8a6744f8 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -20,7 +20,7 @@ namespace Volian.Print.Library ReferencedObjectsUsage = 2, TransitionUsage = 3, ReferencedObjectSummary = 4, - ReferencedObjectComplete =5 + ReferencedObjectComplete = 5 } private ICollection _ResultList; @@ -70,6 +70,8 @@ namespace Volian.Print.Library private string _ByLine; private bool _SortUsageByProcedure = false; private string _RODataFile = ""; + private List _ROList; + private ROFSTLookup _ROFSTLookup; // Search Results Report public PDFReport(string reportTitle, string typesSelected, ICollection 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 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> roUse) + private void AddROUsages(ItemInfo item, Dictionary> 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 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> procRoUse = new SortedDictionary>(); @@ -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(ListroTitleList, List 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 AddROHeaderGroupForSummary(PdfPTable datatable, string curROID,List prevROTitleList, Font f2, Color bgColor) + { + List 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 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 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 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 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 {