Add error support if incorrect phone.lst format (writes to error log)

This commit is contained in:
Kathy Ruffing 2014-05-15 12:43:16 +00:00
parent 5023c30710
commit 50a5787b32

View File

@ -224,36 +224,49 @@ namespace Volian.Print.Library
plist = plist.Replace("\r", "");
string[] lines = plist.Split("\n".ToCharArray());
DocStyle docstyle = MySection.MyDocStyle;
foreach (string cline in lines)
try
{
if (cline != "")
foreach (string clinex in lines)
{
// xoff handles the columns. The separator between phone items is a double space. A phone
// item may have a single space within it (this comes from 16bit implementation)
float xoff = (float)docstyle.Layout.LeftMargin;
int stLineindx = 0;
int endLineindx = cline.IndexOf(" ");
bool endOfLine = false;
while (!endOfLine)
string cline = clinex.TrimEnd();
if (cline != "")
{
string phone = cline.Substring(stLineindx, endLineindx - stLineindx);
float tmp = 0;
vlnText vt = new vlnText(pdfContentByte, null, phone, phone, xoff, lyoff, MySection.ActiveFormat.PlantFormat.FormatData.Font);
vt.ToPdf(pdfContentByte, 0, ref tmp, ref tmp);
xoff += 132; // columns in 16bit were a little more than 1 3/4 inches.
stLineindx = endLineindx;
if (stLineindx >= cline.Length) break;
while (cline[stLineindx] == ' ' && stLineindx < cline.Length) stLineindx++;
if (stLineindx >= cline.Length - 1) endOfLine = true;
else
// xoff handles the columns. The separator between phone items is a double space. A phone
// item may have a single space within it (this comes from 16bit implementation)
float xoff = (float)docstyle.Layout.LeftMargin;
int stLineindx = 0;
int endLineindx = cline.IndexOf(" ");
bool endOfLine = false;
while (!endOfLine)
{
endLineindx = cline.IndexOf(" ", stLineindx);
if (endLineindx == -1) endLineindx = cline.Length;
if (endLineindx - stLineindx > 0)
{
string phone = cline.Substring(stLineindx, endLineindx - stLineindx);
float tmp = 0;
vlnText vt = new vlnText(pdfContentByte, null, phone, phone, xoff, lyoff, MySection.ActiveFormat.PlantFormat.FormatData.Font);
vt.ToPdf(pdfContentByte, 0, ref tmp, ref tmp);
xoff += 132; // columns in 16bit were a little more than 1 3/4 inches.
stLineindx = endLineindx;
if (stLineindx >= cline.Length) break;
while (cline[stLineindx] == ' ' && stLineindx < cline.Length) stLineindx++;
if (stLineindx >= cline.Length - 1) endOfLine = true;
else
{
endLineindx = cline.IndexOf(" ", stLineindx);
if (endLineindx == -1) endLineindx = cline.Length;
}
}
else
endOfLine = true;
}
lyoff = lyoff - vlnPrintObject.SixLinesPerInch;
}
lyoff = lyoff - vlnPrintObject.SixLinesPerInch;
}
}
catch (Exception ex)
{
_MyLog.Error("Error processing phone list.", ex);
}
if (PageListLayer != null) pdfContentByte.EndLayer();
pdfContentByte.RestoreState();
}