Commit 3a49ef7e 几米阳光

扫码增加异常捕获

1 个父辈 6cb03ded
...@@ -100,7 +100,7 @@ namespace OnlineStore.Common ...@@ -100,7 +100,7 @@ namespace OnlineStore.Common
} }
public static void error(ILog log, string errorMsg) public static void error(ILog log, string errorMsg)
{ {
if (!lasErrorLogList.Contains(errorMsg)) //if (!lasErrorLogList.Contains(errorMsg))
{ {
log.Error(log.Logger.Name + " - " + errorMsg); log.Error(log.Logger.Name + " - " + errorMsg);
if (logBox == null) if (logBox == null)
...@@ -109,11 +109,11 @@ namespace OnlineStore.Common ...@@ -109,11 +109,11 @@ namespace OnlineStore.Common
} }
AddToBox(errorMsg, Color.Red); AddToBox(errorMsg, Color.Red);
} }
lasErrorLogList.Add(errorMsg); //lasErrorLogList.Add(errorMsg);
if (lasErrorLogList.Count > errCount) //if (lasErrorLogList.Count > errCount)
{ //{
lasErrorLogList.RemoveAt(0); // lasErrorLogList.RemoveAt(0);
} //}
} }
private static void AddToBox(string msg, Color color) private static void AddToBox(string msg, Color color)
{ {
......
...@@ -217,6 +217,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -217,6 +217,8 @@ namespace OnlineStore.DeviceLibrary
#region 原点返回和复位处理 #region 原点返回和复位处理
private void ReturnHome() private void ReturnHome()
{ {
isNoAirCheck = false;
isInSuddenDown = false;
WarnMsg = ""; WarnMsg = "";
CurrInOutACount = 0; CurrInOutACount = 0;
CurrInOutCount = 0; CurrInOutCount = 0;
......
...@@ -6,6 +6,7 @@ using System.Collections.Generic; ...@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -91,6 +92,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -91,6 +92,7 @@ namespace OnlineStore.DeviceLibrary
return bitm; return bitm;
} }
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan( ) public static List<string> CameraScan( )
{ {
List<string> codeList = new List<string>(); List<string> codeList = new List<string>();
...@@ -123,8 +125,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -123,8 +125,14 @@ namespace OnlineStore.DeviceLibrary
} }
allCodeList.AddRange(cc); allCodeList.AddRange(cc);
} }
bitmap.Dispose();
} }
} }
catch (AccessViolationException e)
{
LogUtil.error("扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
}
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("扫码出错:" + ex.ToString()); LogUtil.error("扫码出错:" + ex.ToString());
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!