Added checkbox to sort Complete or Summary RO report on setpoint id and logic to sort by setpoint ID

Added status message for report generation.  Added logic to handle underline on/off (using the _ character).
This commit is contained in:
2015-04-17 16:54:21 +00:00
parent f9992cd299
commit f50e7d11b4
3 changed files with 464 additions and 115 deletions

View File

@@ -8,6 +8,7 @@ using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using VlnStatus;
namespace Volian.Print.Library
@@ -161,6 +162,7 @@ namespace Volian.Print.Library
int idx = 0;
Chunk chk;
Phrase p = new Phrase();
bool underlineChunk = false;
instr = instr.Replace("`", "\u00B0"); //degree
if (ConvertCaretToDelta)
instr = instr.Replace("^", "\u0394"); // delta
@@ -172,7 +174,30 @@ namespace Volian.Print.Library
if (idx < m.Index)
{
int strlen = m.Index - idx;
int uidx = 0;
string strChk = instr.Substring(idx, strlen);
MatchCollection mc1 = Regex.Matches(strChk, "[_](.*?)"); // look ofr Underline on/off
foreach (Match m1 in mc1)
{
if (uidx < m1.Index)
{
string tstr = (instr.Substring(idx+uidx, m1.Index - uidx));
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(0);
p.Add(chk);
uidx += (tstr.Length + 1);
idx += (tstr.Length + 1);
strlen -= (tstr.Length + 1);
underlineChunk = !underlineChunk;
}
}
chk = new Chunk(instr.Substring(idx, strlen), fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(0);
p.Add(chk);
}
@@ -180,12 +205,16 @@ namespace Volian.Print.Library
{
case '#':
chk = new Chunk(m.Value.Substring(1, m.Length-2), fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(.25F * chk.Font.Size);
p.Add(chk);
idx = m.Index + m.Length;
break;
case '~':
chk = new Chunk(m.Value.Substring(1, m.Length-2), fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(-.25F * chk.Font.Size);
p.Add(chk);
idx = m.Index + m.Length;
@@ -194,9 +223,36 @@ namespace Volian.Print.Library
}
if (idx < instr.Length - 1)
{
chk = new Chunk(instr.Substring(idx), fnt);
chk.SetTextRise(0);
p.Add(chk);
int uidx = 0;
string strChk = (instr.Substring(idx));
MatchCollection mc1 = Regex.Matches(strChk, "[_](.*?)"); // look for underline on/off
foreach (Match m1 in mc1)
{
if (uidx < m1.Index)
{
string tstr = (strChk.Substring(uidx, m1.Index - uidx));
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(0);
p.Add(chk);
uidx += (tstr.Length+1);
underlineChunk = !underlineChunk;
}
}
if (uidx < strChk.Length - 1)
{
string tstr = strChk.Substring(uidx);
if (tstr.EndsWith(" "))
tstr = tstr.Substring(0, tstr.Length - 1) + "\xA0";
chk = new Chunk(tstr, fnt);
if (underlineChunk)
chk.SetUnderline(Color.BLACK, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND);
chk.SetTextRise(0);
p.Add(chk);
}
}
return p;
@@ -212,6 +268,8 @@ namespace Volian.Print.Library
{
PdfPCell cell = new PdfPCell(ConvertDOSSuperAndSubScripts(str, fnt));
cell.BorderColor = Color.WHITE;
if (strlst.Length > 1)
cell.PaddingBottom = 6;
datatable.AddCell(cell);
}
}
@@ -298,10 +356,13 @@ namespace Volian.Print.Library
bool StopPrinting = false;
bool UserTerminate = false;
Int16 iRecType = 0;
VlnStatusBar showStatBar = new VlnStatusBar("Complete RO Report");
try
{
if (RO_df.GetFileLength() > 0)
{
showStatBar.BarMax = (int)RO_df.GetFileLength();
showStatBar.StatMsg = "Creating Report";
// Loop until either printing is aborted or end of file.
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{
@@ -352,6 +413,7 @@ namespace Volian.Print.Library
_pdfReportDoc.Add(datatable);
_pdfReportDoc.NewPage();
StartNewDataTable();
showStatBar.BarValue = (int)RO_df.GetFilePointerPosition();
//Console.WriteLine("Record Type: {0} No Operation", iRecType);
//Console.WriteLine("----------------------------------------------");
break;
@@ -372,12 +434,15 @@ namespace Volian.Print.Library
}
//Console.WriteLine("Record Type: {0}\n** Done **", iRecType);
_pdfReportDoc.Add(datatable);
showStatBar.Dispose();
}
catch (Exception e)
{
Console.WriteLine("Exception : {0}", e.Message);
RO_df.close();
_pdfReportDoc.Add(datatable);
showStatBar.Dispose();
GenerateErrorMessage(e, "Error Processing Complete RO Report. ", null);
}
AddErrorBookmarks();
@@ -931,6 +996,10 @@ namespace Volian.Print.Library
{
return fs.Length;
}
public long GetFilePointerPosition()
{
return fs.Position;
}
// Read an integer value from the data file
public Int16 ReadInteger16()
{