|
|
@@ -68,19 +68,19 @@ namespace DeviceCenter
|
|
|
|
|
|
lv_device.ItemsSource = devices;
|
|
|
|
|
|
- System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
|
|
|
- dispatcherTimer.Tick += GetAllCard;
|
|
|
- dispatcherTimer.Interval = new TimeSpan(0, 30, 0);
|
|
|
- dispatcherTimer.Start();
|
|
|
-
|
|
|
- System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
|
|
|
- timer.Tick += (s, e) =>
|
|
|
- {
|
|
|
- ((System.Windows.Threading.DispatcherTimer)s).Stop();
|
|
|
- GetAllCard(null, null);
|
|
|
- };
|
|
|
- timer.Interval = new TimeSpan(0, 0, 5);
|
|
|
- timer.Start();
|
|
|
+ //System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
|
|
|
+ //dispatcherTimer.Tick += GetAllCard;
|
|
|
+ //dispatcherTimer.Interval = new TimeSpan(0, 30, 0);
|
|
|
+ //dispatcherTimer.Start();
|
|
|
+
|
|
|
+ //System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
|
|
|
+ //timer.Tick += (s, e) =>
|
|
|
+ //{
|
|
|
+ // ((System.Windows.Threading.DispatcherTimer)s).Stop();
|
|
|
+ // GetAllCard(null, null);
|
|
|
+ //};
|
|
|
+ //timer.Interval = new TimeSpan(0, 0, 5);
|
|
|
+ //timer.Start();
|
|
|
}
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
@@ -261,55 +261,50 @@ namespace DeviceCenter
|
|
|
|
|
|
private void GetAllCard(object source, EventArgs e)
|
|
|
{
|
|
|
+
|
|
|
+ int m_userId = -1;
|
|
|
+ AcsDevice device = null;
|
|
|
try
|
|
|
{
|
|
|
- int m_userId = -1;
|
|
|
- AcsDevice device = null;
|
|
|
- try
|
|
|
- {
|
|
|
- device = (AcsDevice)devices.First(i => i.type == DeviceType.ACS && i.status == DeviceStatus.CONNECTED);
|
|
|
- }
|
|
|
- catch { }
|
|
|
- if (device == null)
|
|
|
- {
|
|
|
- log.Info("no connected device");
|
|
|
- return;
|
|
|
- }
|
|
|
- m_userId = device.userId;
|
|
|
- if (-1 != m_lGetCardCfgHandle)
|
|
|
- {
|
|
|
- if (CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetCardCfgHandle))
|
|
|
- {
|
|
|
- m_lGetCardCfgHandle = -1;
|
|
|
- }
|
|
|
- }
|
|
|
- CHCNetSDK.NET_DVR_CARD_CFG_COND struCond = new CHCNetSDK.NET_DVR_CARD_CFG_COND();
|
|
|
- struCond.dwSize = (uint)Marshal.SizeOf(struCond);
|
|
|
- struCond.wLocalControllerID = 0;
|
|
|
- struCond.dwCardNum = 0xffffffff;
|
|
|
- struCond.byCheckCardNo = 1;
|
|
|
-
|
|
|
- int dwSize = Marshal.SizeOf(struCond);
|
|
|
- IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);
|
|
|
- Marshal.StructureToPtr(struCond, ptrStruCond, false);
|
|
|
- g_fGetGatewayCardCallback = new CHCNetSDK.RemoteConfigCallback(ProcessGetGatewayCardCallback);
|
|
|
-
|
|
|
- m_lGetCardCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_userId, CHCNetSDK.NET_DVR_GET_CARD_CFG_V50, ptrStruCond, dwSize, g_fGetGatewayCardCallback, new WindowInteropHelper(this).Handle);
|
|
|
- if (m_lGetCardCfgHandle == -1)
|
|
|
- {
|
|
|
- log.Info(string.Format("NET_DVR_GET_CARD_CFG_V50 FAIL, ERROR CODE {0}", CHCNetSDK.NET_DVR_GetLastError()));
|
|
|
- Marshal.FreeHGlobal(ptrStruCond);
|
|
|
- return;
|
|
|
- }
|
|
|
- else
|
|
|
+ device = (AcsDevice)devices.First(i => i.type == DeviceType.ACS && i.status == DeviceStatus.CONNECTED);
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ if (device == null)
|
|
|
+ {
|
|
|
+ log.Info("no connected device");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_userId = device.userId;
|
|
|
+ if (-1 != m_lGetCardCfgHandle)
|
|
|
+ {
|
|
|
+ if (CHCNetSDK.NET_DVR_StopRemoteConfig(m_lGetCardCfgHandle))
|
|
|
{
|
|
|
- log.Info("SUCC NET_DVR_GET_CARD_CFG_V50");
|
|
|
+ m_lGetCardCfgHandle = -1;
|
|
|
}
|
|
|
+ }
|
|
|
+ CHCNetSDK.NET_DVR_CARD_CFG_COND struCond = new CHCNetSDK.NET_DVR_CARD_CFG_COND();
|
|
|
+ struCond.dwSize = (uint)Marshal.SizeOf(struCond);
|
|
|
+ struCond.wLocalControllerID = 0;
|
|
|
+ struCond.dwCardNum = 0xffffffff;
|
|
|
+ struCond.byCheckCardNo = 1;
|
|
|
+
|
|
|
+ int dwSize = Marshal.SizeOf(struCond);
|
|
|
+ IntPtr ptrStruCond = Marshal.AllocHGlobal(dwSize);
|
|
|
+ Marshal.StructureToPtr(struCond, ptrStruCond, false);
|
|
|
+ g_fGetGatewayCardCallback = new CHCNetSDK.RemoteConfigCallback(ProcessGetGatewayCardCallback);
|
|
|
+
|
|
|
+ m_lGetCardCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_userId, CHCNetSDK.NET_DVR_GET_CARD_CFG_V50, ptrStruCond, dwSize, g_fGetGatewayCardCallback, new WindowInteropHelper(this).Handle);
|
|
|
+ if (m_lGetCardCfgHandle == -1)
|
|
|
+ {
|
|
|
+ log.Info(string.Format("NET_DVR_GET_CARD_CFG_V50 FAIL, ERROR CODE {0}", CHCNetSDK.NET_DVR_GetLastError()));
|
|
|
Marshal.FreeHGlobal(ptrStruCond);
|
|
|
+ return;
|
|
|
}
|
|
|
- catch (Exception ex) {
|
|
|
- log.Error(ex);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ log.Info("SUCC NET_DVR_GET_CARD_CFG_V50");
|
|
|
}
|
|
|
+ Marshal.FreeHGlobal(ptrStruCond);
|
|
|
}
|
|
|
|
|
|
private void ProcessGetGatewayCardCallback(uint dwType, IntPtr lpBuffer, uint dwBufLen, IntPtr pUserData)
|