C2018-035 Added error Handling to provide more useful information when a plot fails

This commit is contained in:
Rich
2019-08-22 15:26:51 +00:00
parent 17f24b7100
commit ee241103c6
3 changed files with 94 additions and 29 deletions

View File

@@ -908,29 +908,37 @@ namespace VEPROMS.CSLA.Library
pngFile = VlnSettings.TemporaryFolder + @"\XYPlot" + filecount.ToString() + @".png"; //@"C:\Temp\XYPlot1.png";
filecount++;
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)
try // C2018-035 if an error occurs make the error message more specific
{
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;// .wdRelativeHorizontalPositionMargin;
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;
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;
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
// C2018-035 Don't use a messagebox if in automatic(Baseline) testing mode.
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 = FindXyPlot();
}
@@ -1136,6 +1144,15 @@ namespace VEPROMS.CSLA.Library
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
{
_MyLog.WarnFormat("\r\n==> {0}\r\n" +