Added logic to handle RO Database that have the same Setpoint ID value in multiple tables – this affect reporting on all RO Databases, sorting by Setoint ID

Fixed underline logic for instances where the underline ON is the first thing of text.  Added better error handling for X/Y Plots which is now display the plot language if the plot cannot be drawn.  When a problem occurs printing an image or x/y plot, the error text now prints in red.
Better handling of empty RO Database tables.  Now will print the message “—No Information Entered –“
This commit is contained in:
John Jenko 2015-05-12 20:27:47 +00:00
parent 7cb9861534
commit 5d5f84ce23
3 changed files with 67 additions and 60 deletions

View File

@ -116,8 +116,11 @@ namespace Volian.Controls.Library
{ {
rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", rodbi.dbiID.ToString("X4")); rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", rodbi.dbiID.ToString("X4"));
//ROList.Add(rtnStr); //ROList.Add(rtnStr);
foreach (ROFSTLookup.rochild roc in rodbi.children) if (rodbi.children != null)
PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc); foreach (ROFSTLookup.rochild roc in rodbi.children)
PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc);
else
ROList.Add(rtnStr);
} }
continue; continue;
} }
@ -125,8 +128,11 @@ namespace Volian.Controls.Library
{ {
//rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("X4")); //rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("X4"));
ROFSTLookup.rodbi rodbi = (ROFSTLookup.rodbi)rolkup; ROFSTLookup.rodbi rodbi = (ROFSTLookup.rodbi)rolkup;
foreach (ROFSTLookup.rochild roc in rodbi.children) if (rodbi.children != null)
PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc); foreach (ROFSTLookup.rochild roc in rodbi.children)
PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc);
else
ROList.Add(_MyRODbID.ToString() + ":"+ string.Format("{0}",rodbi.dbiID.ToString("X4")));
} }
else if (rolkup is ROFSTLookup.rochild) else if (rolkup is ROFSTLookup.rochild)
{ {
@ -157,7 +163,7 @@ namespace Volian.Controls.Library
{ {
ROFSTLookup.rochild chld = (ROFSTLookup.rochild)roObj; ROFSTLookup.rochild chld = (ROFSTLookup.rochild)roObj;
string rtnstr = rodbidPrefix;// ""; string rtnstr = rodbidPrefix;// "";
string keystr = (chld.appid == "") ? GetNextBlankKey() : chld.appid; string keystr = ((chld.appid == "") ? GetNextBlankKey() : chld.appid) + chld.roid.Substring(0,4);
if (chld.children == null) // get a single ROID if (chld.children == null) // get a single ROID
{ {
rtnstr = rodbidPrefix + string.Format("{0}", chld.roid); rtnstr = rodbidPrefix + string.Format("{0}", chld.roid);
@ -180,7 +186,7 @@ namespace Volian.Controls.Library
else if (roc.appid != null && roc.appid != "") else if (roc.appid != null && roc.appid != "")
{ {
rtnstr = rodbidPrefix + string.Format("{0}", roc.roid); rtnstr = rodbidPrefix + string.Format("{0}", roc.roid);
keystr = (roc.appid == "") ? GetNextBlankKey() : roc.appid; keystr = ((roc.appid == "") ? GetNextBlankKey() : roc.appid) + chld.roid.Substring(0, 4);
AccIDROIDdic.Add(keystr, rtnstr); AccIDROIDdic.Add(keystr, rtnstr);
} }
} }

View File

@ -194,6 +194,11 @@ namespace Volian.Print.Library
strlen -= (tstr.Length + 1); strlen -= (tstr.Length + 1);
underlineChunk = !underlineChunk; underlineChunk = !underlineChunk;
} }
else if (uidx == m1.Index)
{
uidx++;
underlineChunk = !underlineChunk;
}
} }
chk = new Chunk(instr.Substring(idx, strlen), fnt); chk = new Chunk(instr.Substring(idx, strlen), fnt);
if (underlineChunk) if (underlineChunk)
@ -241,6 +246,11 @@ namespace Volian.Print.Library
uidx += (tstr.Length+1); uidx += (tstr.Length+1);
underlineChunk = !underlineChunk; underlineChunk = !underlineChunk;
} }
else if (uidx == m1.Index)
{
uidx++;
underlineChunk = !underlineChunk;
}
} }
if (uidx < strChk.Length - 1) if (uidx < strChk.Length - 1)
{ {
@ -257,8 +267,13 @@ namespace Volian.Print.Library
return p; return p;
} }
public void AddText(string txt, Font fnt) public void AddText(string txt, Font fnt)
{
AddText(txt, fnt, Color.BLACK);
}
public void AddText(string txt, Font fnt, Color txtcolor)
{ {
// break the text up on double returns (paragraphs) and put each in their own cell // break the text up on double returns (paragraphs) and put each in their own cell
// this will allow for page breaks between paragraphs0 // this will allow for page breaks between paragraphs0
@ -266,7 +281,9 @@ namespace Volian.Print.Library
string[] strlst = txt.Split(delim,StringSplitOptions.None); string[] strlst = txt.Split(delim,StringSplitOptions.None);
foreach (string str in strlst) foreach (string str in strlst)
{ {
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, fnt)); Font f = new Font(fnt);
f.Color = txtcolor;
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, f));
cell.BorderColor = Color.WHITE; cell.BorderColor = Color.WHITE;
if (strlst.Length > 1) if (strlst.Length > 1)
cell.PaddingBottom = 6; cell.PaddingBottom = 6;
@ -310,11 +327,8 @@ namespace Volian.Print.Library
} }
catch (Exception ex2) catch (Exception ex2)
{ {
PdfPCell cell2 = new PdfPCell(new Phrase(string.Format("Bad Image File: {0}", filename))); AddText(string.Format("Bad Image File: {0}", filename), F12, Color.RED);
cell2.BorderColor = Color.WHITE;
datatable.AddCell(cell2);
GenerateErrorMessage(ex2, "Bad Image File. ", string.Format("Image File: {0}", filename)); GenerateErrorMessage(ex2, "Bad Image File. ", string.Format("Image File: {0}", filename));
//_MyErrorBookMarks.Add(filename, pdfDest);
roImage.Dispose(); roImage.Dispose();
return; return;
} }
@ -327,29 +341,37 @@ namespace Volian.Print.Library
} }
else else
{ {
PdfPCell messageCell = new PdfPCell(new Phrase(string.Format("Image File {0} is missing.", filename))); AddText(string.Format("Image File {0} is missing.", filename), F12, Color.RED);
messageCell.BorderColor = Color.WHITE;
datatable.AddCell(messageCell);
GenerateErrorMessage(null, "Image File Missing. ", string.Format("Image File: {0}", filename)); GenerateErrorMessage(null, "Image File Missing. ", string.Format("Image File: {0}", filename));
Application.DoEvents(); Application.DoEvents();
//_MyErrorBookMarks.Add(filename, pdfDest);
} }
} }
public void AddXYPlot(string plotlang) public void AddXYPlot(string plotlang)
{ {
string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png";
string rawPlotLang = plotlang;
plotlang = plotlang.Replace("`", "\xB0"); plotlang = plotlang.Replace("`", "\xB0");
plotlang = plotlang.Replace("\xF8", "\xB0"); plotlang = plotlang.Replace("\xF8", "\xB0");
System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile);
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell spaceCell = new PdfPCell(); PdfPCell spaceCell = new PdfPCell();
spaceCell.BorderColor = Color.WHITE; spaceCell.BorderColor = Color.WHITE;
datatable.AddCell(spaceCell); datatable.AddCell(spaceCell);
PdfPCell cell = new PdfPCell(it_image); try
cell.BorderColor = Color.WHITE; {
datatable.AddCell(cell); System.Drawing.RectangleF plotRect = MSWordToPDF.CreatePlot(pngFile, plotlang, 600F, MSWordToPDF.FormForPlotGraphics);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(pngFile);
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
}
catch (Exception e)
{
AddText("-- Error Processing X/Y Plot Language --",F12,Color.RED);
datatable.AddCell(spaceCell);
AddText(rawPlotLang, F10);
GenerateErrorMessage(null, "Error Processing X/Y Plot Lanuage. ", e.Message);
}
} }
private string processingRO = ""; private string processingRO = "";
@ -606,43 +628,11 @@ namespace Volian.Print.Library
Int16 iNewCnt = RO_df.ReadInteger16(); Int16 iNewCnt = RO_df.ReadInteger16();
//Console.WriteLine("Num Header Records: {0}", iNewCnt); //Console.WriteLine("Num Header Records: {0}", iNewCnt);
// Clear the existing headers
Hdrs.strHdrs.Clear();
// Loop through the headers // Loop through the headers
int iLoop = 0; int iLoop = 0;
for (; iLoop < Hdrs.HdrCnt; iLoop++)
{
if (iLoop >= iNewCnt)
// If the current header index is above the new number
// of headers, delete it.
Hdrs.strHdrs[iLoop] = null;
else
{
// Otherwise:
Int16 iTmpRpt;
// Get the repeat count for the header
iTmpRpt = RO_df.ReadInteger16();
//Console.WriteLine("repeat count for header: {0}", iTmpRpt);
// Get the text of the header
pTmp = RO_df.ReadText();
//Console.WriteLine("Header Text: {0}", pTmp);
if (!pTmp.Equals(Hdrs.strHdrs[iLoop]))
{
// if the old header does not equal the new header
// delete the old header and create a the one
Hdrs.strHdrs[iLoop] = pTmp;
Hdrs.repeatCount[iLoop] = iTmpRpt;
}
else
{
// Otherwise, delete the temperary header data.
pTmp = null;
}
}
}
// If there are any other headers left in the file,
// load those in as well.
for (; iLoop < iNewCnt; iLoop++) for (; iLoop < iNewCnt; iLoop++)
{ {
int hdrRptCnt = (int)RO_df.ReadInteger16(); int hdrRptCnt = (int)RO_df.ReadInteger16();

View File

@ -1257,8 +1257,19 @@ namespace Volian.Print.Library
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) 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); ROFSTLookup.rodbi roDBI = _ROFSTLookup.GetRODatabase(cROID);
foreach (ROFSTLookup.rochild cld in roDBI.children) if (roDBI.children != null)
ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld); foreach (ROFSTLookup.rochild cld in roDBI.children)
ProcessROChild(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cld);
else
{
ProcessROID(datatable, f2, f3, ref cell, ref lastROID, ref prevROTitleList, ref lastDBindex, cROID);
cell = new PdfPCell(new Phrase(" ", f2));
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
cell = new PdfPCell(new Phrase("-- No Information Entered --", f2));
cell.BorderColor = Color.WHITE;
datatable.AddCell(cell);
}
} }
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) 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)