From 987241c46c5f76996cc3c77e570d795fdc984113 Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期五, 09 一月 2026 10:10:36 +0800
Subject: [PATCH] 增强相机管理和日志记录功能
---
LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs | 257 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 211 insertions(+), 46 deletions(-)
diff --git a/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs b/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
index 685b06d..2d4067b 100644
--- a/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
+++ b/LB_VisionProcesses/Cameras/HRCameras/HRCamera.cs
@@ -1,4 +1,6 @@
-锘縰sing MVSDK_Net;
+锘縰sing HalconDotNet;
+using LB_SmartVisionCommon;
+using MVSDK_Net;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -26,6 +28,16 @@
private Thread _callbackThread; // 鍥炶皟澶勭悊绾跨▼
private List<IMVDefine.IMV_Frame> _frameList; // 鍥惧儚缂撳瓨鍒楄〃
private readonly object _frameLock = new object(); // 甯х紦瀛橀攣
+ private IMVDefine.IMV_EPixelType type = IMVDefine.IMV_EPixelType.gvspPixelMono8;
+ private IMVDefine.IMV_PixelConvertParam stPixelConvertParam = new IMVDefine.IMV_PixelConvertParam();
+
+ HObject Hobj = new HObject();
+ IntPtr pTemp = IntPtr.Zero;
+ IntPtr pConvertDstBuffer = IntPtr.Zero;
+ int nConvertBufSize = 0;
+
+
+ private IMVDefine.IMV_FrameCallBack frameCallBack;
// CopyMemory API澹版槑
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory")]
@@ -92,13 +104,15 @@
{
// 璁板綍鏃ュ織鎴栨姏鍑哄紓甯�
//throw new Exception($"鏋氫妇璁惧澶辫触锛岄敊璇爜锛歿result}");
- Debug.WriteLine("鏋氫妇璁惧澶辫触锛�");
+ AsyncLogHelper.Error("鏋氫妇璁惧澶辫触锛�");
+ System.Diagnostics.Debug.WriteLine("鏋氫妇璁惧澶辫触锛�");
}
}
catch (Exception ex)
{
// 璁板綍閿欒鏃ュ織
System.Diagnostics.Debug.WriteLine($"鑾峰彇鐩告満鍒楄〃澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error($"鑾峰彇鐩告満鍒楄〃澶辫触锛歿ex.Message}");
throw;
}
@@ -145,6 +159,7 @@
if (cameraIndex == -1)
{
+ AsyncLogHelper.Error($"鏈壘鍒板簭鍒楀彿涓� {SN} 鐨勭浉鏈�");
throw new Exception($"鏈壘鍒板簭鍒楀彿涓� {SN} 鐨勭浉鏈�");
}
@@ -152,6 +167,7 @@
int result = _camera.IMV_CreateHandle(IMVDefine.IMV_ECreateHandleMode.modeByIndex, cameraIndex);
if (result != IMVDefine.IMV_OK)
{
+ AsyncLogHelper.Error($"鍒涘缓璁惧鍙ユ焺澶辫触锛岄敊璇爜锛歿result}");
throw new Exception($"鍒涘缓璁惧鍙ユ焺澶辫触锛岄敊璇爜锛歿result}");
}
_handleCreated = true;
@@ -160,6 +176,7 @@
result = _camera.IMV_Open();
if (result != IMVDefine.IMV_OK)
{
+ AsyncLogHelper.Error($"鎵撳紑鐩告満澶辫触锛岄敊璇爜锛歿result}");
throw new Exception($"鎵撳紑鐩告満澶辫触锛岄敊璇爜锛歿result}");
}
@@ -167,17 +184,121 @@
this.SN = SN;
isGrabbing = false;
- // 璁剧疆缂撳瓨涓暟涓�8
- _camera.IMV_SetBufferCount(8);
+ // 娉ㄥ唽鏁版嵁甯у洖璋冨嚱鏁�
+ // Register data frame callback function
+ frameCallBack = onGetFrame;
+ int res = _camera.IMV_AttachGrabbing(frameCallBack, IntPtr.Zero);
+ if (res != IMVDefine.IMV_OK)
+ {
+ System.Diagnostics.Debug.WriteLine("Attach grabbing failed! ErrorCode:[{0}]", res);
+ AsyncLogHelper.Error("Attach grabbing failed! ErrorCode:[{0}]" + res);
+ }
+ // 璁剧疆缂撳瓨涓暟涓�12
+ _camera.IMV_SetBufferCount(12);
return true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"鍒濆鍖栫浉鏈哄け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error($"鍒濆鍖栫浉鏈哄け璐ワ細{ex.Message}");
return false;
}
}
+
+ // 鏁版嵁甯у洖璋冨嚱鏁�
+ // Data frame callback function
+ private void onGetFrame(ref IMVDefine.IMV_Frame frame, IntPtr pUser)
+ {
+ if (frame.frameHandle == IntPtr.Zero)
+ {
+ AsyncLogHelper.Info(SN + "frame is NULL");
+ return;
+ }
+ try
+ {
+ Bitmap bitmap = ConvertFrameToBitmap(frame);
+
+ // 閲婃斁甯ф暟鎹�
+ // release frame
+ _camera.IMV_ReleaseFrame(ref frame);
+ CallBackImg = (Bitmap)bitmap.Clone();
+ if (CallBackImg == null)
+ {
+ return;
+ }
+ if (GetTriggerMode(out TriggerMode mode, out TriggerSource source))
+ {
+ if (mode == TriggerMode.On && source != TriggerSource.Software)
+ TriggerRunMessageReceived?.Invoke(SN, source.ToString()); // 瑙﹀彂杩愯浜嬩欢
+ }
+ bitmap.Dispose();
+ }
+ catch { }
+ AsyncLogHelper.Info(SN + "Get frame blockId = {0}" + frame.frameInfo.blockId);
+ }
+
+ /// <summary>
+ /// 鍥惧儚鏄惁涓篗ono鏍煎紡
+ /// </summary>
+ /// <param name="enType"></param>
+ /// <returns></returns>
+ private bool IsMonoPixelFormat(IMVDefine.IMV_EPixelType enType)
+ {
+ switch (enType)
+ {
+ case IMVDefine.IMV_EPixelType.gvspPixelMono8:
+ case IMVDefine.IMV_EPixelType.gvspPixelMono10:
+ case IMVDefine.IMV_EPixelType.gvspPixelMono10Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelMono12:
+ case IMVDefine.IMV_EPixelType.gvspPixelMono12Packed:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// 鍥惧儚鏄惁涓哄僵鑹�
+ /// </summary>
+ /// <param name="enType"></param>
+ /// <returns></returns>
+ private bool IsColorPixelFormat(IMVDefine.IMV_EPixelType enType)
+ {
+ switch (enType)
+ {
+ case IMVDefine.IMV_EPixelType.gvspPixelRGB8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBGR8:
+ case IMVDefine.IMV_EPixelType.gvspPixelRGBA8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBGRA8:
+ case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8:
+ case IMVDefine.IMV_EPixelType.gvspPixelYUV422_8_UYVY:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGR8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayRG8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGB8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayBG8:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGB10:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGB10Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayBG10:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayBG10Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayRG10:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayRG10Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGR10:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGR10Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGB12:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGB12Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayBG12:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayBG12Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayRG12:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayRG12Packed:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGR12:
+ case IMVDefine.IMV_EPixelType.gvspPixelBayGR12Packed:
+ return true;
+ default:
+ return false;
+ }
+ }
+
/// <summary>
/// 鍏抽棴鐩告満璁惧
@@ -203,6 +324,7 @@
if (result != IMVDefine.IMV_OK)
{
System.Diagnostics.Debug.WriteLine($"鍏抽棴鐩告満澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Info(SN + $"鍏抽棴鐩告満澶辫触锛岄敊璇爜锛歿result}");
}
}
@@ -233,6 +355,7 @@
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"鍏抽棴鐩告満澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Info(SN + $"鍏抽棴鐩告満澶辫触锛歿ex.Message}");
return false;
}
}
@@ -251,7 +374,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
// 鍋滄鐜版湁閲囬泦
@@ -264,7 +388,8 @@
int result = _camera.IMV_StartGrabbing();
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Error(SN + $"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+ throw new Exception(SN + $"鍚姩閲囬泦澶辫触锛岄敊璇爜锛歿result}");
}
_isGrabbing = true;
@@ -280,7 +405,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鍚姩閲囬泦澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鍚姩閲囬泦澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鍚姩閲囬泦澶辫触锛歿ex.Message}");
_isGrabbing = false;
isGrabbing = false;
return false;
@@ -310,7 +436,8 @@
int result = _camera.IMV_StopGrabbing();
if (result != IMVDefine.IMV_OK)
{
- System.Diagnostics.Debug.WriteLine($"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Info(SN + $"鍋滄閲囬泦澶辫触锛岄敊璇爜锛歿result}");
}
_isGrabbing = false;
@@ -331,7 +458,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鍋滄閲囬泦澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鍋滄閲囬泦澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鍋滄閲囬泦澶辫触锛歿ex.Message}");
return false;
}
}
@@ -346,7 +474,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
int result = _camera.IMV_ExecuteCommandFeature("TriggerSoftware");
@@ -354,7 +483,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"杞Е鍙戝け璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"杞Е鍙戝け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"杞Е鍙戝け璐ワ細{ex.Message}");
return false;
}
}
@@ -375,7 +505,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
// 璁剧疆瑙﹀彂妯″紡
@@ -383,7 +514,8 @@
int result = _camera.IMV_SetEnumFeatureSymbol("TriggerMode", triggerMode);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
+ throw new Exception(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛岄敊璇爜锛歿result}");
}
// 璁剧疆瑙﹀彂婧�
@@ -393,7 +525,8 @@
result = _camera.IMV_SetEnumFeatureSymbol("TriggerSource", triggerSource);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
+ throw new Exception(SN + $"璁剧疆瑙﹀彂婧愬け璐ワ紝閿欒鐮侊細{result}");
}
}
@@ -401,7 +534,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
return false;
}
}
@@ -421,7 +555,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
// 鑾峰彇瑙﹀彂妯″紡
@@ -444,7 +579,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂妯″紡澶辫触锛歿ex.Message}");
return false;
}
}
@@ -460,7 +596,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
// 楠岃瘉鏇濆厜鏃堕棿鑼冨洿
@@ -468,32 +605,37 @@
int result = _camera.IMV_GetDoubleFeatureMin("ExposureTime", ref minExp);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+ throw new Exception(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
}
result = _camera.IMV_GetDoubleFeatureMax("ExposureTime", ref maxExp);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+ throw new Exception(SN + $"鑾峰彇鏇濆厜鏃堕棿鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
}
if (value < minExp || value > maxExp)
{
- throw new Exception($"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
+ AsyncLogHelper.Error(SN + $"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
+ throw new Exception(SN + $"鏇濆厜鏃堕棿瓒呭嚭鑼冨洿锛屾湁鏁堣寖鍥达細{minExp} - {maxExp}");
}
// 璁剧疆鏇濆厜鏃堕棿
result = _camera.IMV_SetDoubleFeatureValue("ExposureTime", value);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Error(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
+ throw new Exception(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛岄敊璇爜锛歿result}");
}
return true;
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
return false;
}
}
@@ -511,7 +653,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
int result = _camera.IMV_GetDoubleFeatureValue("ExposureTime", ref value);
@@ -519,7 +662,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇鏇濆厜鏃堕棿澶辫触锛歿ex.Message}");
return false;
}
}
@@ -535,7 +679,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -545,13 +690,15 @@
int result = _camera.IMV_GetDoubleFeatureMin(gainFeature, ref minGain);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
+ throw new Exception(SN + $"鑾峰彇澧炵泭鏈�灏忓�煎け璐ワ紝閿欒鐮侊細{result}");
}
result = _camera.IMV_GetDoubleFeatureMax(gainFeature, ref maxGain);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
+ throw new Exception(SN + $"鑾峰彇澧炵泭鏈�澶у�煎け璐ワ紝閿欒鐮侊細{result}");
}
if (gain < minGain) gain = minGain;
@@ -561,14 +708,16 @@
result = _camera.IMV_SetDoubleFeatureValue(gainFeature, gain);
if (result != IMVDefine.IMV_OK)
{
- throw new Exception($"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
+ AsyncLogHelper.Error(SN + $"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
+ throw new Exception(SN + $"璁剧疆澧炵泭澶辫触锛岄敊璇爜锛歿result}");
}
return true;
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆澧炵泭澶辫触锛歿ex.Message}");
return false;
}
}
@@ -586,7 +735,8 @@
{
if (_camera == null || !_camera.IMV_IsOpen())
{
- throw new Exception("鐩告満鏈墦寮�");
+ AsyncLogHelper.Error(SN + "鐩告満鏈墦寮�");
+ throw new Exception(SN + "鐩告満鏈墦寮�");
}
string gainFeature = _camera.IMV_FeatureIsValid("Gain") ? "Gain" : "GainRaw";
@@ -595,7 +745,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇澧炵泭澶辫触锛歿ex.Message}");
return false;
}
}
@@ -619,7 +770,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
return false;
}
}
@@ -647,7 +799,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂鏋佹�уけ璐ワ細{ex.Message}");
return false;
}
}
@@ -671,7 +824,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
return false;
}
}
@@ -695,7 +849,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂婊ゆ尝澶辫触锛歿ex.Message}");
return false;
}
}
@@ -718,7 +873,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
return false;
}
}
@@ -742,7 +898,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇瑙﹀彂寤舵椂澶辫触锛歿ex.Message}");
return false;
}
}
@@ -767,7 +924,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆淇″彿绾挎ā寮忓け璐ワ細{ex.Message}");
return false;
}
}
@@ -791,7 +949,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"璁剧疆淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
return false;
}
}
@@ -820,7 +979,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇淇″彿绾跨姸鎬佸け璐ワ細{ex.Message}");
return false;
}
}
@@ -843,7 +1003,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"鑷姩鐧藉钩琛″け璐ワ細{ex.Message}");
return false;
}
}
@@ -880,14 +1041,16 @@
if ((uint)result != 0x80000001 && result != -119 && result != -102) // 瓒呮椂閿欒浠g爜
{
// 闈炶秴鏃堕敊璇�
- System.Diagnostics.Debug.WriteLine($"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
+ AsyncLogHelper.Error(SN + $"鑾峰彇鍥惧儚甯уけ璐ワ紝閿欒鐮侊細{result}");
Thread.Sleep(10); // 鍑洪敊鏃剁◢浣滅瓑寰�
}
}
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"閲囬泦绾跨▼寮傚父锛歿ex.Message}");
Thread.Sleep(10);
}
@@ -918,7 +1081,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
+ AsyncLogHelper.Error(SN + $"澶勭悊鍥惧儚甯уけ璐ワ細{ex.Message}");
}
finally
{
@@ -957,7 +1121,8 @@
}
catch (Exception ex)
{
- System.Diagnostics.Debug.WriteLine($"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
+ System.Diagnostics.Debug.WriteLine(SN + $"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
+ AsyncLogHelper.Error(SN + $"鍥惧儚鏍煎紡杞崲澶辫触锛歿ex.Message}");
return null;
}
}
--
Gitblit v1.9.3