xiongzhu 6 年 前
コミット
2edacc53ef

+ 1 - 0
CamTool/CamTool.csproj

@@ -104,6 +104,7 @@
     <Compile Include="ProcessAsUser.cs" />
     <Compile Include="UsbSwitch.cs" />
     <Compile Include="utils\AcsUtil.cs" />
+    <Compile Include="utils\TypeMap.cs" />
     <Compile Include="utils\VehicleUtil.cs" />
     <Compile Include="utils\PortUtil.cs" />
     <Compile Include="utils\ProcessUtil.cs" />

+ 76 - 44
CamTool/MainWindow.xaml.cs

@@ -506,128 +506,160 @@ namespace CamTool
                     JsonConvert.SerializeObject(responseToLog)));
         }
 
-        public void MsgCallback(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
+        private void MsgCallback(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
         {
             switch (lCommand)
             {
                 case CHCNetSDK.COMM_ALARM_ACS:
-                    try
-                    {
-                        ProcessCommAlarmACS(ref pAlarmer, pAlarmInfo, dwBufLen, pUser);
-                    }
-                    catch(Exception e)
-                    {
-                        log.Error("门禁事件", e);
-                    }
-                    
+                    ProcessCommAlarmACS(ref pAlarmer, pAlarmInfo, dwBufLen, pUser);
                     break;
                 default:
                     break;
             }
         }
 
-        public void ProcessCommAlarmACS(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
+        private void ProcessCommAlarmACS(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
         {
             CHCNetSDK.NET_DVR_ACS_ALARM_INFO struAcsAlarmInfo = new CHCNetSDK.NET_DVR_ACS_ALARM_INFO();
-
             struAcsAlarmInfo = (CHCNetSDK.NET_DVR_ACS_ALARM_INFO)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_ACS_ALARM_INFO));
-            CHCNetSDK.NET_DVR_LOG_V30 struFileInfo = new CHCNetSDK.NET_DVR_LOG_V30(); ;
+            CHCNetSDK.NET_DVR_LOG_V30 struFileInfo = new CHCNetSDK.NET_DVR_LOG_V30();
             struFileInfo.dwMajorType = struAcsAlarmInfo.dwMajor;
             struFileInfo.dwMinorType = struAcsAlarmInfo.dwMinor;
             char[] csTmp = new char[256];
 
             if (CHCNetSDK.MAJOR_ALARM == struFileInfo.dwMajorType)
             {
-                AcsUtil.AlarmMinorTypeMap(struFileInfo, csTmp);
+                TypeMap.AlarmMinorTypeMap(struFileInfo, csTmp);
             }
             else if (CHCNetSDK.MAJOR_OPERATION == struFileInfo.dwMajorType)
             {
-                AcsUtil.OperationMinorTypeMap(struFileInfo, csTmp);
+                TypeMap.OperationMinorTypeMap(struFileInfo, csTmp);
             }
             else if (CHCNetSDK.MAJOR_EXCEPTION == struFileInfo.dwMajorType)
             {
-                AcsUtil.ExceptionMinorTypeMap(struFileInfo, csTmp);
+                TypeMap.ExceptionMinorTypeMap(struFileInfo, csTmp);
             }
             else if (CHCNetSDK.MAJOR_EVENT == struFileInfo.dwMajorType)
             {
-                AcsUtil.EventMinorTypeMap(struFileInfo, csTmp);
+                TypeMap.EventMinorTypeMap(struFileInfo, csTmp);
             }
+
             String szInfo = new String(csTmp).TrimEnd('\0');
             String szInfoBuf = null;
-            char[] szNetUser = new char[struAcsAlarmInfo.sNetUser.GetLength(0) + 1];
-
-            struAcsAlarmInfo.sNetUser.CopyTo(szNetUser, 0);
+            szInfoBuf = szInfo;
+            /**************************************************/
+            String name = System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.sNetUser).TrimEnd('\0');
+            for (int i = 0; i < struAcsAlarmInfo.sNetUser.Length; i++)
+            {
+                if (struAcsAlarmInfo.sNetUser[i] == 0)
+                {
+                    name = name.Substring(0, i);
+                    break;
+                }
+            }
+            /**************************************************/
 
-            szInfoBuf = string.Format("{0} {1,4}-{2,2}-{3} {4,2}:{5,2}:{6,2} [{7}]({8})", szInfo, struAcsAlarmInfo.struTime.dwYear, struAcsAlarmInfo.struTime.dwMonth,
+            szInfoBuf = string.Format("{0} time:{1,4}-{2:D2}-{3} {4:D2}:{5:D2}:{6:D2}, [{7}]({8})", szInfo, struAcsAlarmInfo.struTime.dwYear, struAcsAlarmInfo.struTime.dwMonth,
                 struAcsAlarmInfo.struTime.dwDay, struAcsAlarmInfo.struTime.dwHour, struAcsAlarmInfo.struTime.dwMinute, struAcsAlarmInfo.struTime.dwSecond,
-                struAcsAlarmInfo.struRemoteHostAddr.sIpV4, System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.sNetUser).TrimEnd('\0'));
+                struAcsAlarmInfo.struRemoteHostAddr.sIpV4, name);
+
             if (struAcsAlarmInfo.struAcsEventInfo.byCardNo[0] != 0)
             {
-                szInfoBuf = szInfoBuf + " Card Number:" + System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.struAcsEventInfo.byCardNo).TrimEnd('\0');
+                szInfoBuf = szInfoBuf + "+Card Number:" + System.Text.Encoding.UTF8.GetString(struAcsAlarmInfo.struAcsEventInfo.byCardNo).TrimEnd('\0');
             }
             String[] szCardType = { "normal card", "disabled card", "blacklist card", "night watch card", "stress card", "super card", "guest card" };
             byte byCardType = struAcsAlarmInfo.struAcsEventInfo.byCardType;
 
             if (byCardType != 0 && byCardType <= szCardType.Length)
             {
-                szInfoBuf = szInfoBuf + " Card Type:" + szCardType[byCardType - 1];
+                szInfoBuf = szInfoBuf + "+Card Type:" + szCardType[byCardType - 1];
             }
 
             if (struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Card Reader Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo;
+                szInfoBuf = szInfoBuf + "+Card Reader Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwDoorNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Door Number:" + struAcsAlarmInfo.struAcsEventInfo.dwDoorNo;
+                szInfoBuf = szInfoBuf + "+Door Number:" + struAcsAlarmInfo.struAcsEventInfo.dwDoorNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Multiple Card Authentication Serial Number:" + struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo;
+                szInfoBuf = szInfoBuf + "+Multiple Card Authentication Serial Number:" + struAcsAlarmInfo.struAcsEventInfo.dwVerifyNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Alarm Input Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo;
+                szInfoBuf = szInfoBuf + "+Alarm Input Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmInNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Alarm Output Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo;
+                szInfoBuf = szInfoBuf + "+Alarm Output Number:" + struAcsAlarmInfo.struAcsEventInfo.dwAlarmOutNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Event Trigger Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo;
+                szInfoBuf = szInfoBuf + "+Event Trigger Number:" + struAcsAlarmInfo.struAcsEventInfo.dwCaseSensorNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwRs485No != 0)
             {
-                szInfoBuf = szInfoBuf + " RS485 Channel Number:" + struAcsAlarmInfo.struAcsEventInfo.dwRs485No;
+                szInfoBuf = szInfoBuf + "+RS485 Channel Number:" + struAcsAlarmInfo.struAcsEventInfo.dwRs485No;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo != 0)
             {
-                szInfoBuf = szInfoBuf + " Multi Recombinant Authentication ID:" + struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo;
+                szInfoBuf = szInfoBuf + "+Multi Recombinant Authentication ID:" + struAcsAlarmInfo.struAcsEventInfo.dwMultiCardGroupNo;
             }
             if (struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind != 0)
             {
-                szInfoBuf = szInfoBuf + " CardReaderKind:" + struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind.ToString();
+                szInfoBuf = szInfoBuf + "+CardReaderKind:" + struAcsAlarmInfo.struAcsEventInfo.byCardReaderKind.ToString();
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.wAccessChannel >= 0)
+            {
+                szInfoBuf = szInfoBuf + "+wAccessChannel:" + struAcsAlarmInfo.struAcsEventInfo.wAccessChannel;
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo != 0)
+            {
+                szInfoBuf = szInfoBuf + "+EmployeeNo:" + struAcsAlarmInfo.struAcsEventInfo.dwEmployeeNo;
             }
+            if (struAcsAlarmInfo.struAcsEventInfo.byDeviceNo != 0)
+            {
+                szInfoBuf = szInfoBuf + "+byDeviceNo:" + struAcsAlarmInfo.struAcsEventInfo.byDeviceNo.ToString();
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID >= 0)
+            {
+                szInfoBuf = szInfoBuf + "+wLocalControllerID:" + struAcsAlarmInfo.struAcsEventInfo.wLocalControllerID;
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.byInternetAccess >= 0)
+            {
+                szInfoBuf = szInfoBuf + "+byInternetAccess:" + struAcsAlarmInfo.struAcsEventInfo.byInternetAccess.ToString();
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.byType >= 0)
+            {
+                szInfoBuf = szInfoBuf + "+byType:" + struAcsAlarmInfo.struAcsEventInfo.byType.ToString();
+            }
+            if (struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType != 0)
+            {
+                szInfoBuf = szInfoBuf + "+bySwipeCardType:" + struAcsAlarmInfo.struAcsEventInfo.bySwipeCardType.ToString();
+            }
+            //其它消息先不罗列了......
+
             if (struAcsAlarmInfo.dwPicDataLen > 0)
             {
-                Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
-                DateTime curTime = DateTime.Now;
                 string path = null;
+                Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
                 path = string.Format(@"C:/Picture/ACS_LocalTime{0}_{1}.bmp", szInfo, rand.Next());
-                FileStream fs = new FileStream(path, FileMode.Create);
-                int iLen = (int)struAcsAlarmInfo.dwPicDataLen;
-                byte[] by = new byte[iLen];
-                Marshal.Copy(struAcsAlarmInfo.pPicData, by, 0, iLen);
-                fs.Write(by, 0, iLen);
-                fs.Close();
-                szInfoBuf = szInfoBuf + " SavePath:" + path;
+                using (FileStream fs = new FileStream(path, FileMode.Create))
+                {
+                    int iLen = (int)struAcsAlarmInfo.dwPicDataLen;
+                    byte[] by = new byte[iLen];
+                    Marshal.Copy(struAcsAlarmInfo.pPicData, by, 0, iLen);
+                    fs.Write(by, 0, iLen);
+                    fs.Close();
+                }
+                szInfoBuf = szInfoBuf + "SavePath:" + path;
             }
-            log.Info(szInfo);
+            log.Info(szInfoBuf);
         }
 
 
-
     }
 
 

BIN
CamTool/bin/x86/Debug/CamTool.exe


BIN
CamTool/bin/x86/Debug/CamTool.pdb


+ 1 - 1
CamTool/obj/x86/Debug/CamTool.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-6521a5f8dc9ed9943428382bccf8495a204eacfd
+1a9aad808b5cdff4e81e8145db8b715d3804dddf

BIN
CamTool/obj/x86/Debug/CamTool.csprojAssemblyReference.cache


BIN
CamTool/obj/x86/Debug/CamTool.exe


BIN
CamTool/obj/x86/Debug/CamTool.pdb


+ 1 - 1
CamTool/obj/x86/Debug/CamTool_MarkupCompile.cache

@@ -12,7 +12,7 @@ false
 C:\Users\xiong\Projects\csharp\CamTool\CamTool\App.xaml
 11151548125
 
-16-650453758
+17-237106186
 191610000482
 MainWindow.xaml;
 

+ 1 - 1
CamTool/obj/x86/Debug/CamTool_MarkupCompile.i.cache

@@ -12,7 +12,7 @@ false
 C:\Users\xiong\Projects\csharp\CamTool\CamTool\App.xaml
 11151548125
 
-171021301734
+181434649306
 191610000482
 MainWindow.xaml;