From 5d5f84ce2308b0fa1ef90c508e8ec1c50b343b80 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 12 May 2015 20:27:47 +0000 Subject: [PATCH] =?UTF-8?q?Added=20logic=20to=20handle=20RO=20Database=20t?= =?UTF-8?q?hat=20have=20the=20same=20Setpoint=20ID=20value=20in=20multiple?= =?UTF-8?q?=20tables=20=E2=80=93=20this=20affect=20reporting=20on=20all=20?= =?UTF-8?q?RO=20Databases,=20sorting=20by=20Setoint=20ID=20Fixed=20underli?= =?UTF-8?q?ne=20logic=20for=20instances=20where=20the=20underline=20ON=20i?= =?UTF-8?q?s=20the=20first=20thing=20of=20text.=20=20Added=20better=20erro?= =?UTF-8?q?r=20handling=20for=20X/Y=20Plots=20which=20is=20now=20display?= =?UTF-8?q?=20the=20plot=20language=20if=20the=20plot=20cannot=20be=20draw?= =?UTF-8?q?n.=20=20When=20a=20problem=20occurs=20printing=20an=20image=20o?= =?UTF-8?q?r=20x/y=20plot,=20the=20error=20text=20now=20prints=20in=20red.?= =?UTF-8?q?=20Better=20handling=20of=20empty=20RO=20Database=20tables.=20?= =?UTF-8?q?=20Now=20will=20print=20the=20message=20=E2=80=9C=E2=80=94No=20?= =?UTF-8?q?Information=20Entered=20=E2=80=93=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Volian.Controls.Library/DisplayReports.cs | 18 ++-- PROMS/Volian.Print.Library/CompleteRORpt.cs | 94 +++++++++---------- PROMS/Volian.Print.Library/PDFReport.cs | 15 ++- 3 files changed, 67 insertions(+), 60 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayReports.cs b/PROMS/Volian.Controls.Library/DisplayReports.cs index e034d99f..1925137d 100644 --- a/PROMS/Volian.Controls.Library/DisplayReports.cs +++ b/PROMS/Volian.Controls.Library/DisplayReports.cs @@ -116,8 +116,11 @@ namespace Volian.Controls.Library { rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", rodbi.dbiID.ToString("X4")); //ROList.Add(rtnStr); - foreach (ROFSTLookup.rochild roc in rodbi.children) - PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc); + if (rodbi.children != null) + foreach (ROFSTLookup.rochild roc in rodbi.children) + PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc); + else + ROList.Add(rtnStr); } continue; } @@ -125,8 +128,11 @@ namespace Volian.Controls.Library { //rtnStr = _MyRODbID.ToString() + ":" + string.Format("{0}", ((ROFSTLookup.rodbi)rolkup).dbiID.ToString("X4")); ROFSTLookup.rodbi rodbi = (ROFSTLookup.rodbi)rolkup; - foreach (ROFSTLookup.rochild roc in rodbi.children) - PutROChildrenInDictionary(_MyRODbID.ToString() + ":", roc); + if (rodbi.children != null) + 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) { @@ -157,7 +163,7 @@ namespace Volian.Controls.Library { ROFSTLookup.rochild chld = (ROFSTLookup.rochild)roObj; 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 { rtnstr = rodbidPrefix + string.Format("{0}", chld.roid); @@ -180,7 +186,7 @@ namespace Volian.Controls.Library else if (roc.appid != null && roc.appid != "") { 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); } } diff --git a/PROMS/Volian.Print.Library/CompleteRORpt.cs b/PROMS/Volian.Print.Library/CompleteRORpt.cs index 43a819b7..f771dbee 100644 --- a/PROMS/Volian.Print.Library/CompleteRORpt.cs +++ b/PROMS/Volian.Print.Library/CompleteRORpt.cs @@ -194,6 +194,11 @@ namespace Volian.Print.Library strlen -= (tstr.Length + 1); underlineChunk = !underlineChunk; } + else if (uidx == m1.Index) + { + uidx++; + underlineChunk = !underlineChunk; + } } chk = new Chunk(instr.Substring(idx, strlen), fnt); if (underlineChunk) @@ -241,6 +246,11 @@ namespace Volian.Print.Library uidx += (tstr.Length+1); underlineChunk = !underlineChunk; } + else if (uidx == m1.Index) + { + uidx++; + underlineChunk = !underlineChunk; + } } if (uidx < strChk.Length - 1) { @@ -257,8 +267,13 @@ namespace Volian.Print.Library return p; } - + 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 // this will allow for page breaks between paragraphs0 @@ -266,7 +281,9 @@ namespace Volian.Print.Library string[] strlst = txt.Split(delim,StringSplitOptions.None); 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; if (strlst.Length > 1) cell.PaddingBottom = 6; @@ -310,11 +327,8 @@ namespace Volian.Print.Library } catch (Exception ex2) { - PdfPCell cell2 = new PdfPCell(new Phrase(string.Format("Bad Image File: {0}", filename))); - cell2.BorderColor = Color.WHITE; - datatable.AddCell(cell2); + AddText(string.Format("Bad Image File: {0}", filename), F12, Color.RED); GenerateErrorMessage(ex2, "Bad Image File. ", string.Format("Image File: {0}", filename)); - //_MyErrorBookMarks.Add(filename, pdfDest); roImage.Dispose(); return; } @@ -327,29 +341,37 @@ namespace Volian.Print.Library } else { - PdfPCell messageCell = new PdfPCell(new Phrase(string.Format("Image File {0} is missing.", filename))); - messageCell.BorderColor = Color.WHITE; - datatable.AddCell(messageCell); + AddText(string.Format("Image File {0} is missing.", filename), F12, Color.RED); GenerateErrorMessage(null, "Image File Missing. ", string.Format("Image File: {0}", filename)); Application.DoEvents(); - //_MyErrorBookMarks.Add(filename, pdfDest); } } 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("\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(); spaceCell.BorderColor = Color.WHITE; datatable.AddCell(spaceCell); - PdfPCell cell = new PdfPCell(it_image); - cell.BorderColor = Color.WHITE; - datatable.AddCell(cell); + try + { + 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 = ""; @@ -606,43 +628,11 @@ namespace Volian.Print.Library Int16 iNewCnt = RO_df.ReadInteger16(); //Console.WriteLine("Num Header Records: {0}", iNewCnt); - + + // Clear the existing headers + Hdrs.strHdrs.Clear(); // Loop through the headers 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++) { int hdrRptCnt = (int)RO_df.ReadInteger16(); diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index 26c3e8b9..63a76906 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -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 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); + if (roDBI.children != null) + 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 prevROTitleList, ref int lastDBindex,ROFSTLookup.rochild cld)