C2018-035 Added error Handling to provide more useful information when a plot fails
This commit is contained in:
parent
17f24b7100
commit
ee241103c6
@ -2412,6 +2412,7 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
if(parameter.StartsWith("/P="))
|
if(parameter.StartsWith("/P="))
|
||||||
{
|
{
|
||||||
|
MSWordToPDF.Automatic = true;
|
||||||
PromsPrinter.BaselineTesting = true;// Set Baseline Testing property for PROMsPrinter
|
PromsPrinter.BaselineTesting = true;// Set Baseline Testing property for PROMsPrinter
|
||||||
string[] dvstrs = parameter.Substring(3).Split(",".ToCharArray());
|
string[] dvstrs = parameter.Substring(3).Split(",".ToCharArray());
|
||||||
foreach (string dvstr in dvstrs)
|
foreach (string dvstr in dvstrs)
|
||||||
|
@ -908,29 +908,37 @@ namespace VEPROMS.CSLA.Library
|
|||||||
|
|
||||||
pngFile = VlnSettings.TemporaryFolder + @"\XYPlot" + filecount.ToString() + @".png"; //@"C:\Temp\XYPlot1.png";
|
pngFile = VlnSettings.TemporaryFolder + @"\XYPlot" + filecount.ToString() + @".png"; //@"C:\Temp\XYPlot1.png";
|
||||||
filecount++;
|
filecount++;
|
||||||
|
try // C2018-035 if an error occurs make the error message more specific
|
||||||
RectangleF plotRect = CreatePlot(pngFile, xyplot, 600F, FormForPlotGraphics);
|
|
||||||
float yAdjust = selxy.Font.Size;
|
|
||||||
float xxx = pt.X + plotRect.X;
|
|
||||||
if (xxx < 0 && xxx > -.5)
|
|
||||||
xxx = 0;
|
|
||||||
float yyy = yAdjust + y + plotRect.Y;
|
|
||||||
LBShape shape = myDoc.Shapes.AddPicture(pngFile, xxx, yyy, selxy.Range);
|
|
||||||
File.Delete(pngFile);
|
|
||||||
if (adjustMargins)
|
|
||||||
{
|
{
|
||||||
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
|
RectangleF plotRect = CreatePlot(pngFile, xyplot, 600F, FormForPlotGraphics);
|
||||||
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;// .wdRelativeHorizontalPositionMargin;
|
float yAdjust = selxy.Font.Size;
|
||||||
|
float xxx = pt.X + plotRect.X;
|
||||||
|
if (xxx < 0 && xxx > -.5)
|
||||||
|
xxx = 0;
|
||||||
|
float yyy = yAdjust + y + plotRect.Y;
|
||||||
|
LBShape shape = myDoc.Shapes.AddPicture(pngFile, xxx, yyy, selxy.Range);
|
||||||
|
File.Delete(pngFile);
|
||||||
|
if (adjustMargins)
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
|
shape.LockAspectRatio = LBMsoTriState.msoTrue;
|
||||||
|
shape.Width = plotRect.Width;
|
||||||
|
shape.Left = xxx;
|
||||||
|
shape.Top = pt.Y;
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)// C2018-035 if an error occurs make the error message more specific
|
||||||
{
|
{
|
||||||
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
|
// C2018-035 Don't use a messagebox if in automatic(Baseline) testing mode.
|
||||||
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
|
if (!Automatic) System.Windows.Forms.MessageBox.Show(ex.Message, "X/Y Plot Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
|
||||||
|
_MyLog.WarnFormat("Problem with XYPlot {0} - {1}", ex.GetType().Name, ex.Message);
|
||||||
}
|
}
|
||||||
shape.LockAspectRatio = LBMsoTriState.msoTrue;
|
|
||||||
shape.Width = plotRect.Width;
|
|
||||||
shape.Left = xxx;
|
|
||||||
shape.Top = pt.Y;
|
|
||||||
selxy.WholeStory();
|
selxy.WholeStory();
|
||||||
selxy = FindXyPlot();
|
selxy = FindXyPlot();
|
||||||
}
|
}
|
||||||
@ -1136,6 +1144,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static bool _Automatic = false;
|
||||||
|
/// <summary>
|
||||||
|
/// C2018-035 Don't use a messagebox if in automatic(Baseline) testing mode.
|
||||||
|
/// </summary>
|
||||||
|
public static bool Automatic
|
||||||
|
{
|
||||||
|
get { return MSWordToPDF._Automatic; }
|
||||||
|
set { MSWordToPDF._Automatic = value; }
|
||||||
|
}
|
||||||
private static void AddErrorLogInfoMarginNotFixed(ItemInfo sect,string msg)// B2018-089 - Made error log output more useful
|
private static void AddErrorLogInfoMarginNotFixed(ItemInfo sect,string msg)// B2018-089 - Made error log output more useful
|
||||||
{
|
{
|
||||||
_MyLog.WarnFormat("\r\n==> {0}\r\n" +
|
_MyLog.WarnFormat("\r\n==> {0}\r\n" +
|
||||||
|
@ -15,6 +15,10 @@ namespace XYPlots
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class XYPlot
|
public class XYPlot
|
||||||
{
|
{
|
||||||
|
#region Log4Net
|
||||||
|
// C2018-035 Added error Handling to provide more useful information when a plot fails
|
||||||
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
#endregion
|
||||||
static string _MyFontFamily = "Letter Gothic Tall";
|
static string _MyFontFamily = "Letter Gothic Tall";
|
||||||
public static string MyFontFamily
|
public static string MyFontFamily
|
||||||
{
|
{
|
||||||
@ -158,6 +162,10 @@ namespace XYPlots
|
|||||||
private XyBoxes ActiveBoxes = new XyBoxes();
|
private XyBoxes ActiveBoxes = new XyBoxes();
|
||||||
public class DataPoint
|
public class DataPoint
|
||||||
{
|
{
|
||||||
|
public override string ToString() // Make it easier to Debug
|
||||||
|
{
|
||||||
|
return string.Format("{0},{1}", APoint.xyValue[X],APoint.xyValue[Y]);
|
||||||
|
}
|
||||||
private point m_APoint;
|
private point m_APoint;
|
||||||
public point APoint
|
public point APoint
|
||||||
{
|
{
|
||||||
@ -170,7 +178,7 @@ namespace XYPlots
|
|||||||
get { return m_slope; }
|
get { return m_slope; }
|
||||||
set { m_slope = value; }
|
set { m_slope = value; }
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
public class DataPoints : List<DataPoint>
|
public class DataPoints : List<DataPoint>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -385,14 +393,27 @@ namespace XYPlots
|
|||||||
else
|
else
|
||||||
return nxtstring[0];
|
return nxtstring[0];
|
||||||
}
|
}
|
||||||
|
// C2018-035 Added error Handling to provide more useful information when a plot fails
|
||||||
|
private string _XYPlotIssue;
|
||||||
|
public string XYPlotIssue
|
||||||
|
{
|
||||||
|
get { return _XYPlotIssue; }
|
||||||
|
set { _XYPlotIssue = value; }
|
||||||
|
}
|
||||||
private point GetPair(int flag)
|
private point GetPair(int flag)
|
||||||
{
|
{
|
||||||
point retval = new point();
|
point retval = new point();
|
||||||
retval.xyValue = new int[Dimensions];
|
retval.xyValue = new int[Dimensions];
|
||||||
double x, y;
|
double x, y;
|
||||||
char[] sepchar = { ',' };
|
char[] sepchar = { ',' };
|
||||||
string[] xystr = NextPiece().Split(sepchar);
|
string nextPiece = NextPiece(); // Plot Definition
|
||||||
x = double.Parse(xystr[0]);
|
string[] xystr = nextPiece.Split(sepchar);
|
||||||
|
// C2018-035 Added error Handling to provide more useful information when a plot fails
|
||||||
|
if (xystr.Length != 2)
|
||||||
|
XYPlotIssue = String.Format("Invalid Pair {0}", nextPiece);
|
||||||
|
if (xystr.Length == 1)
|
||||||
|
throw new Exception(XYPlotIssue);
|
||||||
|
x = double.Parse(xystr[0]);
|
||||||
char[] trimEndDot = { '.' }; // Wolf Creek OFN SB-008, figure 3 had a string like 50.0. so trim the ending '.'
|
char[] trimEndDot = { '.' }; // Wolf Creek OFN SB-008, figure 3 had a string like 50.0. so trim the ending '.'
|
||||||
string ystr = xystr[1];
|
string ystr = xystr[1];
|
||||||
if (ystr.EndsWith(".0")) // bug fix B2012-169, the Trim converted a ".75" value to a "75.0" value
|
if (ystr.EndsWith(".0")) // bug fix B2012-169, the Trim converted a ".75" value to a "75.0" value
|
||||||
@ -1128,12 +1149,29 @@ namespace XYPlots
|
|||||||
}
|
}
|
||||||
private void DrawCurve(PlotLine linestart, VG.Page pg, IVGOutput vgOutput)
|
private void DrawCurve(PlotLine linestart, VG.Page pg, IVGOutput vgOutput)
|
||||||
{
|
{
|
||||||
|
CheckDataPoints(linestart);
|
||||||
int pltptListIdx = -1;
|
int pltptListIdx = -1;
|
||||||
while (++pltptListIdx < linestart.PlotDataPoints.Count - 1)
|
while (++pltptListIdx < linestart.PlotDataPoints.Count - 1)
|
||||||
{
|
{
|
||||||
DoSubArcs(linestart.PlotDataPoints, pltptListIdx, pg, vgOutput);
|
DoSubArcs(linestart.PlotDataPoints, pltptListIdx, pg, vgOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckDataPoints(PlotLine linestart)
|
||||||
|
{
|
||||||
|
for(int i = 0;i<linestart.PlotDataPoints.Count-1;i++)
|
||||||
|
{
|
||||||
|
DataPoint dp0 = linestart.PlotDataPoints[i];
|
||||||
|
DataPoint dp1 = linestart.PlotDataPoints[i+1];
|
||||||
|
double x0 = dp0.APoint.xyValue[X];
|
||||||
|
double x1 = dp1.APoint.xyValue[X];
|
||||||
|
if (x0 > x1)
|
||||||
|
{
|
||||||
|
XYPlotIssue = "X Values should be Increasing";
|
||||||
|
throw new Exception("Curve has Invalid Values");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private double GetAngle(double s1)
|
private double GetAngle(double s1)
|
||||||
{
|
{
|
||||||
double t1;
|
double t1;
|
||||||
@ -1962,13 +2000,22 @@ namespace XYPlots
|
|||||||
public void Process(IVGOutput vgOutput)
|
public void Process(IVGOutput vgOutput)
|
||||||
{
|
{
|
||||||
VG.Page pg = new Page(true, _LeftMargin, _TopMargin, _RightMargin, _BottomMargin);
|
VG.Page pg = new Page(true, _LeftMargin, _TopMargin, _RightMargin, _BottomMargin);
|
||||||
GenerateGrid(pg, vgOutput);
|
string step = "Process";
|
||||||
DoAxisTitles(pg, vgOutput);
|
try // C2018-035 Added error Handling to Process to provide more useful information when a plot fails
|
||||||
DrawLines(pg, vgOutput);
|
{
|
||||||
DoBoxes(pg, vgOutput);
|
step = "GenerateGrid";GenerateGrid(pg, vgOutput);
|
||||||
FreeBoxList();
|
step = "DoAxisTitles";DoAxisTitles(pg, vgOutput);
|
||||||
FreeLineList();
|
step = "DrawLines";DrawLines(pg, vgOutput);
|
||||||
CloseGraph();
|
step = "DoBoxes";DoBoxes(pg, vgOutput);
|
||||||
|
step = "FreeBoxList";FreeBoxList();
|
||||||
|
step = "FreeLineList";FreeLineList();
|
||||||
|
step = "CloseGraph";CloseGraph();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_MyLog.WarnFormat("X/Y Plot Error - {0} - {1} - {2}", step, XYPlotIssue ?? "Unknown Issue");
|
||||||
|
throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void ShowPoints(DataPoints dataPoints)
|
private void ShowPoints(DataPoints dataPoints)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user