Logic to include places where there are missing RO on the RO Usage Report, Fix to a Key already in dictionary error, changed the RO.FST created title line to read “RO.FST Last Created:”

This commit is contained in:
John Jenko 2015-01-13 16:32:46 +00:00
parent 112bd6dcc3
commit 2f26c7a5fb

View File

@ -6,7 +6,6 @@ using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
//using Volian.Generic;
namespace Volian.Print.Library namespace Volian.Print.Library
{ {
@ -72,6 +71,7 @@ namespace Volian.Print.Library
private string _RODataFile = ""; private string _RODataFile = "";
private List<string> _ROList; private List<string> _ROList;
private ROFSTLookup _ROFSTLookup; private ROFSTLookup _ROFSTLookup;
private bool _IncludeMissingROs = false;
// Search Results Report // Search Results Report
public PDFReport(string reportTitle, string typesSelected, ICollection<ItemInfo> resultList, string fileName) public PDFReport(string reportTitle, string typesSelected, ICollection<ItemInfo> resultList, string fileName)
@ -96,7 +96,7 @@ namespace Volian.Print.Library
} }
// Transition and RO Usage // Transition and RO Usage
public PDFReport(string reportTitle, ICollection<ItemInfo> resultList, string fileName, bool sortUsageByProcedure) public PDFReport(string reportTitle, ICollection<ItemInfo> resultList, string fileName, bool sortUsageByProcedure, bool includeMissingROs)
{ {
_ResultList = resultList; _ResultList = resultList;
_FileName = fileName; _FileName = fileName;
@ -104,6 +104,7 @@ namespace Volian.Print.Library
_ReportType = (int)ReportType.ReferencedObjectsUsage; _ReportType = (int)ReportType.ReferencedObjectsUsage;
_ByLine = "Generated By PROMS"; _ByLine = "Generated By PROMS";
_SortUsageByProcedure = sortUsageByProcedure; _SortUsageByProcedure = sortUsageByProcedure;
_IncludeMissingROs = includeMissingROs;
} }
// RO Complete Report // RO Complete Report
@ -830,12 +831,18 @@ namespace Volian.Print.Library
// rotitle += roTitleList[cnt] + "\n "; // rotitle += roTitleList[cnt] + "\n ";
//} //}
rotitle = GetROTitleAndGroup(roKey, itm); rotitle = GetROTitleAndGroup(roKey, itm);
PdfPCell ROTitleCell = new PdfPCell(new Phrase(rotitle, f2)); if (rotitle != null && rotitle != "")
ROTitleCell.Colspan = 2; {
ROTitleCell.HorizontalAlignment = Element.ALIGN_LEFT; PdfPCell ROTitleCell = new PdfPCell(new Phrase(rotitle, f2));
ROTitleCell.BackgroundColor = new Color(0xDC, 0xE7, 0xC9); //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0); ROTitleCell.Colspan = 2;
//curTable.AddCell(ROTitleCell); // put RO value and description ROTitleCell.HorizontalAlignment = Element.ALIGN_LEFT;
rotable.AddCell(ROTitleCell); // put RO value and description if (rotitle.StartsWith("Missing RO"))
ROTitleCell.BackgroundColor = Color.PINK;
else
ROTitleCell.BackgroundColor = new Color(0xDC, 0xE7, 0xC9); //new Color(0xD0, 0xF0, 0xD0);//ligt green //new Color(0xC8, 0xC8, 0x91);//(0xAF, 0xD8, 0xD8);//(0xF5, 0xE4, 0xA0);
//curTable.AddCell(ROTitleCell); // put RO value and description
rotable.AddCell(ROTitleCell); // put RO value and description
}
} }
string stepnum = ""; string stepnum = "";
string sectitle = itm.ActiveSection.DisplayText; string sectitle = itm.ActiveSection.DisplayText;
@ -1082,20 +1089,20 @@ namespace Volian.Print.Library
} }
} }
private void PutStepListForProcedure(PdfPTable rotable, SortedDictionary<string, string> sortedStepList) private void PutStepListForProcedure(PdfPTable rotable, SortedDictionary<string, ItemInfo> sortedStepList)
{ {
iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK); iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK);
foreach (string stepnum in sortedStepList.Keys) foreach (ItemInfo itm in sortedStepList.Values)
{ {
string stepnum = (itm.IsSection)? itm.MyActiveSection.DisplayNumber:stepnum = BuildStepTab(itm);
AddCell(rotable, stepnum, f2, Color.WHITE); AddCell(rotable, stepnum, f2, Color.WHITE);
AddCell(rotable, sortedStepList[stepnum], f2, Color.WHITE); AddCell(rotable, itm.DisplayText, f2, Color.WHITE);
} }
sortedStepList.Clear(); sortedStepList.Clear();
} }
private void PutROusageForROID(PdfPTable curTable, SortedDictionary<string, List<ItemInfo>> procRoUse, float[] headerwidths) private void PutROusageForROID(PdfPTable curTable, SortedDictionary<string, List<ItemInfo>> procRoUse, float[] headerwidths)
{ {
SortedDictionary<string, string> sortedStepList = new SortedDictionary<string, string>(); SortedDictionary<string, ItemInfo> sortedStepList = new SortedDictionary<string, ItemInfo>();
//if (rosused.Count == 0) return; // nothing to process
iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK); iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK);
string lastProcKey = ""; string lastProcKey = "";
string lastProcNumTitle = ""; string lastProcNumTitle = "";
@ -1108,7 +1115,6 @@ namespace Volian.Print.Library
if (procKey != lastProcKey) if (procKey != lastProcKey)
{ {
if (sortedStepList.Count > 0) PutStepListForProcedure(rotable, sortedStepList); if (sortedStepList.Count > 0) PutStepListForProcedure(rotable, sortedStepList);
//string procNumTitleSect = GetCurProcNum(itm.SearchPath) + "\r\n " + GetCurSectionNumTitle(itm);
string procNumTitleSect = ""; string procNumTitleSect = "";
curProcNumTitle = GetCurProcNum(itm.SearchPath); curProcNumTitle = GetCurProcNum(itm.SearchPath);
if (lastProcNumTitle == "" || lastProcNumTitle != curProcNumTitle) if (lastProcNumTitle == "" || lastProcNumTitle != curProcNumTitle)
@ -1126,15 +1132,10 @@ namespace Volian.Print.Library
rotable.AddCell(ProcTitleCell); // put RO value and description rotable.AddCell(ProcTitleCell); // put RO value and description
lastProcKey = procKey; lastProcKey = procKey;
} }
string stepnum = ""; string stepnum = (itm.IsSection)?itm.MyActiveSection.DisplayNumber:BuildStepTab(itm);
string sectitle = itm.ActiveSection.DisplayText; string itemkey = stepnum + " " + itm.ItemID.ToString(); // add ItemId to stepnum, sometimes we have idential stepnum text for different steps (ex: blank section numbers)
if (itm.IsSection) if (!sortedStepList.ContainsKey(itemkey))
stepnum = itm.MyActiveSection.DisplayNumber; sortedStepList.Add(itemkey, itm);
else
stepnum = BuildStepTab(itm);//GetStepNumberFromSearchPath(itm.SearchPath);//stepnum.Substring(itm.SearchPath.LastIndexOf(sectitle) + sectitle.Length +1);
sortedStepList.Add(stepnum, itm.DisplayText);
//AddCell(rotable, stepnum, f2, Color.WHITE);
//AddCell(rotable, itm.DisplayText, f2, Color.WHITE);
} }
if (sortedStepList.Count > 0) PutStepListForProcedure(rotable, sortedStepList); if (sortedStepList.Count > 0) PutStepListForProcedure(rotable, sortedStepList);
curTable.AddCell(rotable); curTable.AddCell(rotable);
@ -1146,25 +1147,29 @@ namespace Volian.Print.Library
{ {
string rotitle = ""; string rotitle = "";
ROFSTLookup myrofstlookup = (itm == null)? _ROFSTLookup : 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); List<string> roTitleList = myrofstlookup.GetROTitleAndGroupPath(roid,_IncludeMissingROs);
for (int cnt = 0; cnt < roTitleList.Count; cnt++) if (roTitleList != null && roTitleList.Count > 0)
{ for (int cnt = 0; cnt < roTitleList.Count; cnt++)
if (cnt == roTitleList.Count - 1) {
rotitle += roTitleList[cnt]; if (cnt == roTitleList.Count - 1)
else rotitle += roTitleList[cnt];
rotitle += roTitleList[cnt] + "\n "; else
} rotitle += roTitleList[cnt] + "\n ";
}
return rotitle; return rotitle;
} }
private void AddROHeaderGroup(PdfPTable datatable, string curROID, ItemInfo itm, Font f2, Color bgColor) private void AddROHeaderGroup(PdfPTable datatable, string curROID, ItemInfo itm, Font f2, Color bgColor)
{ {
string headerText = GetROTitleAndGroup(curROID, itm); string headerText = GetROTitleAndGroup(curROID, itm);
if (headerText.Length > 0) if (headerText != null && headerText.Length > 0)
{ {
PdfPCell cell = new PdfPCell(new Phrase(headerText, f2)); PdfPCell cell = new PdfPCell(new Phrase(headerText, f2));
cell.Colspan = 2; cell.Colspan = 2;
cell.BackgroundColor = bgColor; if (headerText.StartsWith("Missing RO"))
cell.BackgroundColor = Color.PINK;
else
cell.BackgroundColor = bgColor;
cell.BorderWidthTop = 1; cell.BorderWidthTop = 1;
datatable.AddCell(cell); datatable.AddCell(cell);
} }
@ -1201,7 +1206,6 @@ namespace Volian.Print.Library
AddCell(colHeader, "Text", f2, subHeaderColor); AddCell(colHeader, "Text", f2, subHeaderColor);
datatable.AddCell(colHeader); datatable.AddCell(colHeader);
datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
string lastPath = "";
Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); Color AnnoColor = new Color(0xFF, 0xFF, 0xC0);
Color TextColor = Color.WHITE; Color TextColor = Color.WHITE;
Color SectColor = new Color(0xE0, 0xFF, 0xE0);//new Color(0xC0, 0xFF, 0xC0);//Color.LIGHT_GRAY; Color SectColor = new Color(0xE0, 0xFF, 0xE0);//new Color(0xC0, 0xFF, 0xC0);//Color.LIGHT_GRAY;
@ -1320,7 +1324,7 @@ namespace Volian.Print.Library
} }
private List<string> AddROHeaderGroupForSummary(PdfPTable datatable, string curROID,List<string> prevROTitleList, Font f2, Color bgColor) private List<string> AddROHeaderGroupForSummary(PdfPTable datatable, string curROID,List<string> prevROTitleList, Font f2, Color bgColor)
{ {
List<string> roTitleList = _ROFSTLookup.GetROTitleAndGroupPath(curROID); List<string> roTitleList = _ROFSTLookup.GetROTitleAndGroupPath(curROID,_IncludeMissingROs);
string headerText = GetROTitleAndGroupsForSummary(roTitleList, prevROTitleList); string headerText = GetROTitleAndGroupsForSummary(roTitleList, prevROTitleList);
if (headerText.Length > 0) if (headerText.Length > 0)
{ {
@ -1366,7 +1370,7 @@ namespace Volian.Print.Library
cell.BorderColor = Color.WHITE; cell.BorderColor = Color.WHITE;
datatable.AddCell(cell); datatable.AddCell(cell);
string roFSTDateTime = "RO.FST Created: " + _ROFSTLookup.GetRoFSTdts().ToLongDateString() + " @ " + _ROFSTLookup.GetRoFSTdts().ToShortTimeString() + "\n "; string roFSTDateTime = "RO.FST Last Created: " + _ROFSTLookup.GetRoFSTdts().ToLongDateString() + " @ " + _ROFSTLookup.GetRoFSTdts().ToShortTimeString() + "\n ";
cell = new PdfPCell(new Phrase(roFSTDateTime, f2)); cell = new PdfPCell(new Phrase(roFSTDateTime, f2));
cell.BorderColor = Color.WHITE; cell.BorderColor = Color.WHITE;
datatable.AddCell(cell); datatable.AddCell(cell);