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