lrf 1 年之前
当前提交
b6faee96c2
共有 71 个文件被更改,包括 86251 次插入0 次删除
  1. 2 0
      .gitignore
  2. 二进制
      .vs/CollectInformation/v16/.suo
  3. 25 0
      CollectInformation.sln
  4. 116 0
      CollectInformation/CollectInformation.csproj
  5. 二进制
      CollectInformation/HCUSBSDK/HCUSBSDK.dll
  6. 7 0
      CollectInformation/HCUSBSDK/HCUSBSDK.xml
  7. 398 0
      CollectInformation/HCUSBSDK/HCUSBUtils.cs
  8. 404 0
      CollectInformation/HCUSBSDK/HCUsbSDKACS.cs
  9. 76 0
      CollectInformation/HCUSBSDK/Nationality.cs
  10. 二进制
      CollectInformation/HCUSBSDK/hpr.dll
  11. 二进制
      CollectInformation/HCUSBSDK/libeay32.dll
  12. 二进制
      CollectInformation/HCUSBSDK/libusb-1.0.dll
  13. 二进制
      CollectInformation/HCUSBSDK/ssleay32.dll
  14. 646 0
      CollectInformation/MainForm.Designer.cs
  15. 567 0
      CollectInformation/MainForm.cs
  16. 120 0
      CollectInformation/MainForm.resx
  17. 23 0
      CollectInformation/Program.cs
  18. 36 0
      CollectInformation/Properties/AssemblyInfo.cs
  19. 73 0
      CollectInformation/Properties/Resources.Designer.cs
  20. 124 0
      CollectInformation/Properties/Resources.resx
  21. 29 0
      CollectInformation/Properties/Settings.Designer.cs
  22. 7 0
      CollectInformation/Properties/Settings.settings
  23. 二进制
      CollectInformation/Resources/d-head.jpg
  24. 149 0
      CollectInformation/Tools/HttpUitls.cs
  25. 56 0
      CollectInformation/Tools/Image2Base64Utils.cs
  26. 95 0
      CollectInformation/Tools/JWTUtils.cs
  27. 47 0
      CollectInformation/Tools/constants.cs
  28. 11 0
      CollectInformation/app.config
  29. 7 0
      CollectInformation/config.xml
  30. 166 0
      CollectInformation/loginForm.Designer.cs
  31. 138 0
      CollectInformation/loginForm.cs
  32. 120 0
      CollectInformation/loginForm.resx
  33. 5 0
      CollectInformation/packages.config
  34. 二进制
      packages/JWT.8.4.0/.signature.p7s
  35. 二进制
      packages/JWT.8.4.0/JWT.8.4.0.nupkg
  36. 二进制
      packages/JWT.8.4.0/lib/net35/JWT.dll
  37. 二进制
      packages/JWT.8.4.0/lib/net35/JWT.pdb
  38. 1378 0
      packages/JWT.8.4.0/lib/net35/JWT.xml
  39. 二进制
      packages/JWT.8.4.0/lib/net40/JWT.dll
  40. 二进制
      packages/JWT.8.4.0/lib/net40/JWT.pdb
  41. 1378 0
      packages/JWT.8.4.0/lib/net40/JWT.xml
  42. 二进制
      packages/JWT.8.4.0/lib/net46/JWT.dll
  43. 二进制
      packages/JWT.8.4.0/lib/net46/JWT.pdb
  44. 1378 0
      packages/JWT.8.4.0/lib/net46/JWT.xml
  45. 二进制
      packages/JWT.8.4.0/lib/net5.0/JWT.dll
  46. 二进制
      packages/JWT.8.4.0/lib/net5.0/JWT.pdb
  47. 1539 0
      packages/JWT.8.4.0/lib/net5.0/JWT.xml
  48. 二进制
      packages/JWT.8.4.0/lib/netstandard1.3/JWT.dll
  49. 二进制
      packages/JWT.8.4.0/lib/netstandard1.3/JWT.pdb
  50. 1378 0
      packages/JWT.8.4.0/lib/netstandard1.3/JWT.xml
  51. 二进制
      packages/JWT.8.4.0/lib/netstandard2.0/JWT.dll
  52. 二进制
      packages/JWT.8.4.0/lib/netstandard2.0/JWT.pdb
  53. 1539 0
      packages/JWT.8.4.0/lib/netstandard2.0/JWT.xml
  54. 二进制
      packages/Newtonsoft.Json.13.0.1/.signature.p7s
  55. 20 0
      packages/Newtonsoft.Json.13.0.1/LICENSE.md
  56. 二进制
      packages/Newtonsoft.Json.13.0.1/Newtonsoft.Json.13.0.1.nupkg
  57. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.dll
  58. 10335 0
      packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.xml
  59. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.dll
  60. 9483 0
      packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.xml
  61. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.dll
  62. 9683 0
      packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.xml
  63. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.dll
  64. 11305 0
      packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.xml
  65. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
  66. 10993 0
      packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
  67. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.dll
  68. 11115 0
      packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.xml
  69. 二进制
      packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll
  70. 11280 0
      packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.xml
  71. 二进制
      packages/Newtonsoft.Json.13.0.1/packageIcon.png

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+obj
+bin

二进制
.vs/CollectInformation/v16/.suo


+ 25 - 0
CollectInformation.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31702.278
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollectInformation", "CollectInformation\CollectInformation.csproj", "{14C38775-BFFD-4735-8BCD-79B73C7BC34F}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{14C38775-BFFD-4735-8BCD-79B73C7BC34F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{14C38775-BFFD-4735-8BCD-79B73C7BC34F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{14C38775-BFFD-4735-8BCD-79B73C7BC34F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{14C38775-BFFD-4735-8BCD-79B73C7BC34F}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {62912DB7-0AF7-4B70-AB2C-61280FDC5A62}
+	EndGlobalSection
+EndGlobal

+ 116 - 0
CollectInformation/CollectInformation.csproj

@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{14C38775-BFFD-4735-8BCD-79B73C7BC34F}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>CollectInformation</RootNamespace>
+    <AssemblyName>CollectInformation</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="JWT, Version=8.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
+      <HintPath>..\packages\JWT.8.4.0\lib\net40\JWT.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="HCUSBSDK\HCUsbSDKACS.cs" />
+    <Compile Include="HCUSBSDK\HCUSBUtils.cs" />
+    <Compile Include="HCUSBSDK\Nationality.cs" />
+    <Compile Include="MainForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="MainForm.Designer.cs">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="LoginForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="LoginForm.Designer.cs">
+      <DependentUpon>LoginForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tools\constants.cs" />
+    <Compile Include="Tools\HttpUitls.cs" />
+    <Compile Include="Tools\Image2Base64Utils.cs" />
+    <Compile Include="Tools\JWTUtils.cs" />
+    <EmbeddedResource Include="LoginForm.resx">
+      <DependentUpon>LoginForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="MainForm.resx">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <None Include="app.config" />
+    <None Include="packages.config" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\d-head.jpg" />
+  </ItemGroup>
+  <ItemGroup />
+  <ItemGroup>
+    <Content Include="config.xml" />
+    <Content Include="HCUSBSDK\HCUSBSDK.dll" />
+    <Content Include="HCUSBSDK\HCUSBSDK.xml" />
+    <Content Include="HCUSBSDK\hpr.dll" />
+    <Content Include="HCUSBSDK\libeay32.dll" />
+    <Content Include="HCUSBSDK\libusb-1.0.dll" />
+    <Content Include="HCUSBSDK\ssleay32.dll" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

二进制
CollectInformation/HCUSBSDK/HCUSBSDK.dll


+ 7 - 0
CollectInformation/HCUSBSDK/HCUSBSDK.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SdkCfg>
+<logLevel>0</logLevel><!-- 0-表示关闭日志,1-表示只输出ERROR错误日志,2-输出ERROR错误信息和DEBUG调试信息,3-输出ERROR错误信息、DEBUG调试信息和INFO普通信息等所有信息-->
+<logDirectory>C:\USBSDKLog</logDirectory><!--志文件的路径-->
+<autoDelete>true</autoDelete><!--是否删除超出的文件数-->
+<Filter>true</Filter><!--慎用该节点,对接三方设备出问题不给予支持,发布前请做好充分测试--><!--枚举时是否过滤非海康设备  true:开启过滤  false:关闭过滤-->
+</SdkCfg>

+ 398 - 0
CollectInformation/HCUSBSDK/HCUSBUtils.cs

@@ -0,0 +1,398 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace CollectInformation.HCUSBSDK
+{
+    class HCUSBUtils
+    {
+        public const int INITIALIZED_INDEX = 1;
+        public uint m_VersionNum = 0;
+        public string szLogPath = Application.StartupPath + "/UsbSDKLog/";
+        public int g_nEnumDevIndex = INITIALIZED_INDEX;
+        public CHCUsbSDK.USB_DEVICE_INFO[] m_aHidDevInfo;//这个存储着遍历到的设备,列表索引1开始,所以添加
+        public static CHCUsbSDK.EnumDeviceCallBack m_OnEnumDeviceCallBack = null;//遍历设备的回调
+        public int IndexOfInfo = INITIALIZED_INDEX;//信息列表更新信息的索引,初始值为1
+        public CHCUsbSDK.USB_USER_LOGIN_INFO StruCurUsbLoginInfo = new CHCUsbSDK.USB_USER_LOGIN_INFO();
+        public int UserID = -1;
+        public string loginname = "admin";
+        //public string loginpwd = "free2021!";
+        public string loginpwd = "Admin123";
+
+        /// <summary>
+        /// 初始化SDK
+        /// </summary>
+        /// <returns>SDK版本号</returns>
+        public string initSDK()
+        {
+            string r = null;
+
+            bool res = CHCUsbSDK.USB_Init();//USB initialize
+            IntPtr ptrLogPath = Marshal.StringToHGlobalAnsi(szLogPath);//写日志
+            CHCUsbSDK.USB_SetLogToFile(3, ptrLogPath, false);//这里用枚举参数不匹配,直接写了3,
+            Marshal.FreeHGlobal(ptrLogPath);
+            m_VersionNum = CHCUsbSDK.USB_GetSDKVersion();
+            r = string.Format("{0}.{1}.{2}.{3}", (0xff000000 & m_VersionNum) >> 24, (0x00ff0000 & m_VersionNum) >> 16, (0x0000ff00 & m_VersionNum) >> 8, (0x000000ff & m_VersionNum));
+            return r;
+        }
+
+        /// <summary>
+        /// 遍历设备
+        /// </summary>
+        public bool TraverseDevice()
+        {
+            bool r = false;
+            this.m_aHidDevInfo = new CHCUsbSDK.USB_DEVICE_INFO[CHCUsbSDK.MAX_USB_DEV_LEN];
+            this.g_nEnumDevIndex = 1;
+            bool bExceedFlag = false;
+            int dwCount = CHCUsbSDK.USB_GetDeviceCount();
+            CHCUsbSDK.USB_DEVICE_INFO struDeviceInfo = new CHCUsbSDK.USB_DEVICE_INFO();
+            struDeviceInfo.Init();
+            IntPtr pDeviceInfo = Marshal.AllocHGlobal(dwCount * Marshal.SizeOf(struDeviceInfo));
+            //清空内存空间
+            for (int i = 0; i < dwCount * Marshal.SizeOf(struDeviceInfo); i++)
+            {
+                Marshal.WriteByte(pDeviceInfo, i, 0);
+            }
+            IntPtr pTempDeviceInfo = IntPtr.Zero;
+
+            if (CHCUsbSDK.USB_EnumDevices(dwCount, pDeviceInfo))                    //枚举设备
+            {
+                pTempDeviceInfo = pDeviceInfo;
+                while (--dwCount >= 0)
+                {
+                    struDeviceInfo = new CHCUsbSDK.USB_DEVICE_INFO();
+                    struDeviceInfo = (CHCUsbSDK.USB_DEVICE_INFO)Marshal.PtrToStructure(pTempDeviceInfo, typeof(CHCUsbSDK.USB_DEVICE_INFO));
+                    if (this.g_nEnumDevIndex == 64)
+                    {
+                        bExceedFlag = true;
+                        break;
+                    }
+                    this.m_aHidDevInfo[this.g_nEnumDevIndex - 1] = struDeviceInfo;        //存储到数组中方便登录获取数据
+                    this.g_nEnumDevIndex++;//更新索引
+                    pTempDeviceInfo += Marshal.SizeOf(struDeviceInfo);
+                }
+                if (bExceedFlag)
+                {
+                    MessageBox.Show("The total number of devices could not be over 64numbers", "Error", MessageBoxButtons.OK);
+                }
+                else
+                {
+                    r = true;
+                }
+            }
+            else
+            {
+                MessageBox.Show(GetErrorMsg(), "Error", MessageBoxButtons.OK);
+            }
+
+            //释放内存
+            if (pDeviceInfo != IntPtr.Zero)
+            {
+                Marshal.FreeHGlobal(pDeviceInfo);
+                pDeviceInfo = IntPtr.Zero;
+                pTempDeviceInfo = IntPtr.Zero;
+            }
+
+            if (pTempDeviceInfo != IntPtr.Zero)
+            {
+                Marshal.FreeHGlobal(pTempDeviceInfo);
+                pTempDeviceInfo = IntPtr.Zero;
+            }
+
+            return r;
+        }
+        /// <summary>
+        /// 登录第一个设备,必须在遍历设备之后执行
+        /// </summary>
+        /// <returns></returns>
+        public bool LoginDevice()
+        {
+            return LoginDevice(0);
+        }
+        /// <summary>
+        /// 登录第设备,必须在遍历设备之后执行
+        /// </summary>
+        /// <param name="index">要登录的设备在列表中的位置</param>
+        /// <returns></returns>
+        public bool LoginDevice(int index)
+        {
+            bool r = false;
+
+            if (!JudgeValidOfLoginInfo())
+            {
+                return r;
+            }
+            StruCurUsbLoginInfo.init();
+
+            StruCurUsbLoginInfo.dwSize = (int)Marshal.SizeOf(StruCurUsbLoginInfo);
+            StruCurUsbLoginInfo.dwTimeout = 5000;//登录超时时间是5秒
+            StruCurUsbLoginInfo.dwVID = this.m_aHidDevInfo[index].dwVID;
+            StruCurUsbLoginInfo.dwPID = this.m_aHidDevInfo[index].dwPID;
+
+            System.Array.Copy(this.m_aHidDevInfo[index].szSerialNumber, StruCurUsbLoginInfo.szSerialNumber, this.m_aHidDevInfo[index].szSerialNumber.Length);
+
+            byte[] TempUserArr = System.Text.Encoding.Default.GetBytes(this.loginname);
+            System.Array.Copy(TempUserArr, StruCurUsbLoginInfo.szUserName, TempUserArr.Length);
+
+            byte[] TempszPassword = System.Text.Encoding.Default.GetBytes(this.loginpwd);
+            System.Array.Copy(TempszPassword, StruCurUsbLoginInfo.szPassword, TempszPassword.Length);
+
+
+            CHCUsbSDK.USB_DEVICE_REG_RES StruDeviceRegRes = new CHCUsbSDK.USB_DEVICE_REG_RES();
+            StruDeviceRegRes.init();
+            StruDeviceRegRes.dwSize = (int)Marshal.SizeOf(StruDeviceRegRes);
+
+            int UserIDTemp = UserID;
+
+            UserID = CHCUsbSDK.USB_Login(ref StruCurUsbLoginInfo, ref StruDeviceRegRes);
+            if (UserID == CHCUsbSDK.INVALID_USER_ID)
+            {
+                GetErrorMsg();
+                UserID = UserIDTemp;//为了解决重复登录时的问题,但是这次只考虑了只能登录一个设备,两个设备同时能登录的话,ID会覆盖得继续解决ID的问题
+            }
+            else
+            {
+                string SuccesfulLoginInfo = "SUCCESS USB_Login,The device whose serial number is " + System.Text.Encoding.Default.GetString(StruCurUsbLoginInfo.szSerialNumber) + "login in successfully";
+                r = true;
+            }
+
+            return r;
+        }
+
+        /// <summary>
+        /// 人像采集
+        /// </summary>
+        /// <param name="filePath">人像临时保存位置</param>
+        /// <param name="imageName">图片名称,获取到多个图片会按照顺序从0开始加前缀“0_”</param>
+        /// <returns>其他结果内容</returns>
+        public string CaptureFace(string filePath, string imageName)
+        {
+            string r = null;
+
+            CHCUsbSDK.USB_PT_PARAM struPTparam = new CHCUsbSDK.USB_PT_PARAM();
+            struPTparam.Init();
+
+            Int32 nInSize = Marshal.SizeOf(struPTparam);
+            struPTparam.dwSize = nInSize;
+
+            string strRequestUrl = "POST /ISAPI/AccessControl/CaptureFaceData";
+            int dwRequestUrlLen = strRequestUrl.Length;
+            struPTparam.pRequestUrl = Marshal.StringToHGlobalAnsi(strRequestUrl);
+            struPTparam.dwRequestUrlLen = dwRequestUrlLen;
+
+            string strInputParam = "<CaptureFaceDataCond xmlns=\"http://www.isapi.org/ver20/XMLSchema\" version=\"2.0\">" +
+                    "<captureInfrared>true</captureInfrared>" +
+                    "<dataType>binary</dataType>" +
+                    "<readerID>1</readerID>" +
+                    "</CaptureFaceDataCond>";
+            struPTparam.pInBuffer = Marshal.StringToHGlobalAnsi(strInputParam);
+            struPTparam.dwInSize = strInputParam.Length;
+
+            struPTparam.pOutBuffer = Marshal.AllocHGlobal(1024 * 1024);
+            struPTparam.dwOutSize = 1024 * 1024;
+
+            //存放人脸采集返回的图片数据的缓冲区
+            struPTparam.struData[0].pDataBuffer = Marshal.AllocHGlobal(300 * 1024);
+            struPTparam.struData[0].dwDataSize = 300 * 1024;
+            struPTparam.struData[1].pDataBuffer = Marshal.AllocHGlobal(300 * 1024);
+            struPTparam.struData[1].dwDataSize = 300 * 1024;
+
+            struPTparam.dwSendTimeOut = 200000; //发送超时时间
+            struPTparam.dwRecvTimeOut = 200000; //接收超时时间
+
+            if (!CHCUsbSDK.USB_TransConfig(UserID, ref struPTparam))
+            {
+                String strErr = "USB_TransConfig failed, error code= " + CHCUsbSDK.USB_GetLastError();
+                MessageBox.Show(strErr);
+            }
+            else
+            {
+                int iSize = struPTparam.dwOutSize;
+
+                byte[] byOutPut = new byte[iSize];
+                Marshal.Copy(struPTparam.pOutBuffer, byOutPut, 0, iSize);
+                r = System.Text.Encoding.UTF8.GetString(byOutPut).TrimEnd('\0');
+
+                for (int i = 0; i < struPTparam.byNumOfData; i++)
+                {
+                    //保存数据
+                    if ((struPTparam.struData[i].dwDataSize != 0) && (struPTparam.struData[i].pDataBuffer != IntPtr.Zero))
+                    {
+                        if (!Directory.Exists(filePath))//路径不存在
+                        {
+                            Directory.CreateDirectory(filePath);//创建新路径
+                        }
+
+                        string strFileName = filePath + "\\" + i + "_" + imageName;
+                        FileStream fs = new FileStream(strFileName, FileMode.Create);
+                        int iLen = (int)struPTparam.struData[i].dwDataSize;
+                        byte[] by = new byte[iLen];
+                        Marshal.Copy(struPTparam.struData[i].pDataBuffer, by, 0, iLen);
+                        fs.Write(by, 0, iLen);
+                        fs.Close();
+                    }
+                }
+
+                //释放内存
+                if (struPTparam.pRequestUrl != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pRequestUrl);
+                    struPTparam.pRequestUrl = IntPtr.Zero;
+                }
+
+                if (struPTparam.pInBuffer != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pInBuffer);
+                    struPTparam.pInBuffer = IntPtr.Zero;
+                }
+
+                if (struPTparam.pOutBuffer != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pOutBuffer);
+                    struPTparam.pOutBuffer = IntPtr.Zero;
+                }
+
+                for (int i = 0; i < CHCUsbSDK.MAX_DATA_NUM; i++)
+                {
+                    if (struPTparam.struData[0].pDataBuffer != IntPtr.Zero)
+                    {
+                        Marshal.FreeHGlobal(struPTparam.struData[0].pDataBuffer);
+                        struPTparam.struData[0].pDataBuffer = IntPtr.Zero;
+                    }
+                }
+            }
+
+            return r;
+        }
+        /// <summary>
+        /// 采集指纹或身份证信息
+        /// </summary>
+        /// <param name="type">采集类型:1、身份证;2、指纹</param>
+        /// <param name="inputStr">输入参数</param>
+        /// <returns>采集结果</returns>
+        public string CollectionNoImage(int type, string inputStr)
+        {
+            string r = null;
+
+            CHCUsbSDK.USB_PT_PARAM struPTparam = new CHCUsbSDK.USB_PT_PARAM();
+            struPTparam.Init();
+
+            Int32 nInSize = Marshal.SizeOf(struPTparam);
+            struPTparam.dwSize = nInSize;
+
+            string strRequestUrl = "";
+            if (type == 1)
+            {
+                // 身份证采集
+                strRequestUrl = "POST /ISAPI/AccessControl/CaptureIDInfo?format=json";
+            }
+            else
+            {
+                // 指纹采集
+                strRequestUrl = "POST /ISAPI/AccessControl/CaptureFingerPrint";
+            }
+            int dwRequestUrlLen = strRequestUrl.Length;
+            struPTparam.pRequestUrl = Marshal.StringToHGlobalAnsi(strRequestUrl);
+            struPTparam.dwRequestUrlLen = dwRequestUrlLen;
+
+            string strInputParam = inputStr;
+            struPTparam.pInBuffer = Marshal.StringToHGlobalAnsi(strInputParam);
+            struPTparam.dwInSize = strInputParam.Length;
+
+            struPTparam.pOutBuffer = Marshal.AllocHGlobal(1024 * 1024);
+            struPTparam.dwOutSize = 1024 * 1024;
+
+            struPTparam.dwSendTimeOut = 20000; //发送超时时间
+            struPTparam.dwRecvTimeOut = 20000; //接收超时时间
+
+            if (!CHCUsbSDK.USB_TransConfig(UserID, ref struPTparam))
+            {
+                String strErr = "USB_TransConfig failed, error code= " + CHCUsbSDK.USB_GetLastError();
+                MessageBox.Show(strErr);
+            }
+            else
+            {
+                int iSize = struPTparam.dwOutSize;
+
+                byte[] byOutPut = new byte[iSize];
+                Marshal.Copy(struPTparam.pOutBuffer, byOutPut, 0, iSize);
+                r = System.Text.Encoding.UTF8.GetString(byOutPut);
+
+
+                //释放内存
+                if (struPTparam.pRequestUrl != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pRequestUrl);
+                    struPTparam.pRequestUrl = IntPtr.Zero;
+                }
+
+                if (struPTparam.pInBuffer != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pInBuffer);
+                    struPTparam.pInBuffer = IntPtr.Zero;
+                }
+
+                if (struPTparam.pOutBuffer != IntPtr.Zero)
+                {
+                    Marshal.FreeHGlobal(struPTparam.pOutBuffer);
+                    struPTparam.pOutBuffer = IntPtr.Zero;
+                }
+
+                for (int i = 0; i < CHCUsbSDK.MAX_DATA_NUM; i++)
+                {
+                    if (struPTparam.struData[0].pDataBuffer != IntPtr.Zero)
+                    {
+                        Marshal.FreeHGlobal(struPTparam.struData[0].pDataBuffer);
+                        struPTparam.struData[0].pDataBuffer = IntPtr.Zero;
+                    }
+                }
+            }
+
+            return r;
+        }
+
+        /// <summary>
+        /// 转换USB_SDK_GetErrorMsg的结果成字符串
+        /// </summary>
+        /// <returns>字符串信息</returns>
+        public string GetErrorMsg()
+        {
+            string r = "";
+            IntPtr res = IntPtr.Zero;
+            try
+            {
+                uint Error = CHCUsbSDK.USB_GetLastError();
+                res = CHCUsbSDK.USB_GetErrorMsg(Error);
+                string sRes = Marshal.PtrToStringAnsi(res);
+                r = sRes;
+                res = IntPtr.Zero;
+            }
+            catch
+            {
+                res = IntPtr.Zero;
+                r = "Fail To Show USB Error Message in Log Information.";
+            }
+            return r;
+        }
+
+        /// <summary>
+        /// 判断登录设备的相关信息是否是有效的
+        /// </summary>
+        /// <returns></returns>
+        private Boolean JudgeValidOfLoginInfo()
+        {
+            if (m_aHidDevInfo == null || m_aHidDevInfo.Length <= 0)
+            {
+                MessageBox.Show("No device .", "Attention", MessageBoxButtons.OK);
+                return false;
+            }
+            return true;
+        }
+
+    }
+}

+ 404 - 0
CollectInformation/HCUSBSDK/HCUsbSDKACS.cs

@@ -0,0 +1,404 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+namespace CollectInformation.HCUSBSDK
+{
+   public class CHCUsbSDK
+    {
+        #region HCUsbSDK.dll macro definition
+
+        #region common use
+        public const int MAX_MANUFACTURE_LEN=32;
+        public const int MAX_DEVICE_NAME_LEN=32;
+        public const int MAX_SERIAL_NUM_LEN=48;////序列号的最大长度
+        public const int MAX_USB_DEV_LEN = 64;
+        public const int ERR_LEVEL = 1;//ListInfo里面的信息类型
+        public const int DBG_LEVEL = 2;//ListInfo里面的信息类型
+        public const int INF_LEVEL = 3;//ListInfo里面的信息类型
+        public const int MAX_USERNAME_LEN = 32;//用户名的最大长度
+        public const int MAX_PASSWORD_LEN = 16;//最大的密码长度
+        public const int INVALID_USER_ID = -1;
+        public const int USB_ERROR_BASE = 0;
+        public const int USB_SUCCESS = (CHCUsbSDK.USB_ERROR_BASE + 0);
+        public const uint USB_GET_ACTIVATE_CARD     = 1004;
+        public const uint USB_GET_CERTIFICATE_INFO  = 1020;
+        public const int HPR_MAX_PATH = 260;
+        public const int MAX_DATA_NUM = 8;
+        public const int MAX_FILE_PATH_LEN = 256;
+        #endregion
+
+        #region
+        public const int USB_SDK_SET_BEEP_AND_FLICKER = 0x0100;     //控制蜂鸣器及显示灯
+        public const int USB_SDK_SET_CARD_PROTO = 0x0103;           //设置操作卡协议类型
+        public const int USB_SDK_SET_M1_PWD_VERIFY  = 0x0106;       //(M1卡) 验证扇区密码
+        public const int USB_SDK_SET_M1_WRITE_BLOCK = 0x0108;       //(M1卡) 写卡指定块数据
+        public const int USB_SDK_SET_M1_MODIFY_SCB = 0x0109;        //(M1卡) 修改指定扇区控制块
+        public const int USB_SDK_SET_M1_BLOCK_ADD_VALUE = 0x010A;   //(M1卡) 块加值
+        public const int USB_SDK_SET_M1_BLOCK_MINUS_VALUE = 0x010B; //(M1卡) 块减值
+        public const int USB_SDK_SET_M1_MIFARE_PACK = 0x010E;       //(M1卡) Mifare数据包透传
+        public const int USB_SDK_SET_CARD_PARAM = 0x0111;           //(M1卡) 设置卡参数
+        public const int USB_SDK_SET_CPU_CARD_PACK = 0x0113;        //(M1卡) CPU卡数据包透传
+        #endregion
+
+
+        public enum LOG_LEVEL_ENUM
+        {
+            ENUM_ERROR_LEVEL= 1,
+            ENUM_DEBUG_LEVEL = 2,
+            ENUM_INFO_LEVEL = 3
+        }
+        #endregion
+
+        #region structure definition
+
+        [StructLayoutAttribute(LayoutKind.Sequential)]
+        public struct USB_DEVICE_INFO
+        {
+            public int dwSize;   //结构体大小
+            public int dwIndex; // 设备索引 
+            public int dwVID;   //设备VID
+            public int dwPID;   //设备PID
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = MAX_MANUFACTURE_LEN, ArraySubType = UnmanagedType.I1)]
+            public byte[] szManufacturer;               //制造商(来自描述符)
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = MAX_DEVICE_NAME_LEN, ArraySubType = UnmanagedType.I1)]
+            public byte[] szDeviceName;                 //设备名称(来自描述符)
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = MAX_SERIAL_NUM_LEN, ArraySubType = UnmanagedType.I1)]
+            public byte[] szSerialNumber;           //设备序列号(来自描述符)
+            public byte byHaveAudio;	// 是否具有音频
+            public byte iColorType;     // 1.RGB路, 2.IR路
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = HPR_MAX_PATH, ArraySubType = UnmanagedType.I1)]
+            public byte[] szDevicePath;
+            public byte byDeviceType;  		//设备类型, 4-音频,5-视频
+            public int dwBCD;         		//设备软件版本号
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 249, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;
+            public void Init()
+            {
+                szManufacturer = new byte[MAX_MANUFACTURE_LEN];
+                szDeviceName = new byte[MAX_DEVICE_NAME_LEN];
+                szSerialNumber = new byte[MAX_SERIAL_NUM_LEN];
+                szDevicePath = new byte[HPR_MAX_PATH];
+                byRes = new byte[249];
+            }
+        };
+
+        [StructLayoutAttribute(LayoutKind.Sequential)]
+        public struct  USB_USER_LOGIN_INFO
+        {
+            public int      dwSize;                    //结构体大小
+            public int      dwTimeout;                 //登录超时时间(单位:毫秒)
+            public int      dwDevIndex;                //设备下标
+            public int      dwVID;                     //设备VID,枚举设备时得到
+            public int      dwPID;                     //设备PID,枚举设备时得到
+
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_USERNAME_LEN, ArraySubType = UnmanagedType.I1)]              //用户名32
+            public byte[]   szUserName;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_PASSWORD_LEN, ArraySubType = UnmanagedType.I1)]             //密码16
+            public byte[]   szPassword;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_SERIAL_NUM_LEN, ArraySubType = UnmanagedType.I1)]        //序列号的最大长度48
+            public byte[]   szSerialNumber;
+           
+            
+            public byte     byLoginMode;                 //0-认证登陆 1-默认账号登陆(不关心用户名密码)(权限不同,部分功能需认证登陆才支持)
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byRes2;                    //保留的字段
+            public int      dwFd;                      //设备描述符fd (android下没有root权限登录时使用)
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 248, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byRes;                    //保留的字段
+
+            public void init()
+            {
+                szUserName      = new byte[MAX_USERNAME_LEN];
+                szPassword      = new byte[MAX_PASSWORD_LEN];
+                szSerialNumber  = new byte[MAX_SERIAL_NUM_LEN];
+                byRes2          = new byte[3];
+                byRes           = new byte[248];
+            }
+        }
+
+       [StructLayoutAttribute(LayoutKind.Sequential)]
+       public struct  USB_DEVICE_REG_RES
+       {
+           public int           dwSize;                     //结构体大小
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = MAX_DEVICE_NAME_LEN, ArraySubType = UnmanagedType.I1)]
+           public byte[]        szDeviceName;
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = MAX_SERIAL_NUM_LEN, ArraySubType = UnmanagedType.I1)]
+           public byte[]        szSerialNumber;
+           public int           dwSoftwareVersion;      //软件版本号,高16位是主版本,低16位是次版本
+           public ushort        wYear;
+           public byte          byMonth;
+           public byte          byDay;
+           public byte          byRetryLoginTimes;      //剩余可尝试登陆的次数
+
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.I1)]
+           public byte[] byRes1;
+           public byte bySurplusLockTime;          //剩余时间,单位秒 用户锁定时,此参数有效
+
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 256, ArraySubType = UnmanagedType.I1)]
+           public byte[] byRes;
+
+           public void init()
+           {
+               szDeviceName     = new byte[MAX_DEVICE_NAME_LEN];
+               szSerialNumber   = new byte[MAX_SERIAL_NUM_LEN];
+               byRes1 = new byte[3];
+               byRes = new byte[256];
+           }
+
+       }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_M1_PWD_VERIFY_INFO    //卡扇区带密码验证结构体
+        {
+            public int      dwSize;
+            public byte     byPasswordType;
+            public byte     bySectionNum;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.I1)]
+            public byte[]     byRes1;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]
+            public byte[]     byPassword;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 18, ArraySubType = UnmanagedType.I1)]
+            public byte[]     byRes;
+            public void Init()
+            {
+                byRes1 = new byte[2];
+                byPassword = new byte[6];
+                byRes = new byte[18];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_M1_BLOCK_WRITE_DATA   //写卡指定块数据
+        {
+            public int      dwSize;
+            public short    wAddr;
+            public byte     byDataLen;
+            public byte     byRes1;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 16, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byData;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byRes;
+            public void Init()
+            {
+                byData = new byte[16];
+                byRes = new byte[8];
+            }
+        }
+
+       [StructLayout(LayoutKind.Sequential)]
+        public struct USB_M1_MODIFY_SCB   //(M1卡) 修改指定扇区控制块
+       {
+            public int     dwSize;
+            public byte     bySectionNum;
+            [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byPasswordA;
+            public byte     byRes1;
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byCtrlBits;
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byPasswordB;
+           [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byRes;
+           public void Init()
+           {
+               byPasswordA = new byte[6];
+               byCtrlBits = new byte[4];
+               byPasswordB = new byte[6];
+               byRes = new byte[10];
+           }
+       }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_ACTIVATE_CARD_RES
+        {
+            public int dwSize;
+            public byte byCardType;// 卡类型(0-TypeA m1卡,1-TypeA cpu卡,2-TypeB,3-125kHz Id卡)
+            public byte bySerialLen; //卡物理序列号字节长度
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.I1)]
+            public byte[] bySerial;//卡物理序列号
+            public byte bySelectVerifyLen;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.I1)]
+            public byte[] bySelectVerify;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;
+
+            public void Init()
+            {
+                bySerial = new byte[10];
+                bySelectVerify = new byte[3];
+                byRes = new byte[12];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_WAIT_SECOND
+        {
+            public int dwSize;//结构体的大小
+            public byte byWait;//1Byte操作等待时间(0-一直执行直到有卡响应,其他对应1S单位)
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 27, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;
+
+            public void Init()
+            {
+                byRes = new byte[27];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_CONFIG_INPUT_INFO
+        {
+            public IntPtr lpCondBuffer;//指向条件缓冲区
+            public int dwCondBufferSize;//条件缓冲区大小
+            public IntPtr lpInBuffer;//指向输出缓冲区
+            public int dwInBufferSize;//输入缓冲区大小
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 48, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;
+
+            public void Init()
+            {
+                byRes = new byte[48];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_CONFIG_OUTPUT_INFO
+        {
+            public IntPtr   lpOutBuffer;//指向输出缓冲区
+            public int      dwOutBufferSize;//输出缓冲区大小
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 56, ArraySubType = UnmanagedType.I1)]
+            public byte[]   byRes;          // 56个字节
+            public void Init()
+            {
+                byRes = new byte[56];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_CERTIFICATE_INFO
+        {
+            public int dwSize; //结构体大小
+            public ushort wWordInfoSize; //文字信息长度
+            public ushort wPicInfoSize; //相片信息长度
+            public ushort wFingerPrintInfoSize; //指纹信息长度
+            public byte byCertificateType; //证件类型:0-身份证,1-中国绿卡
+            public byte byRes2;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256, ArraySubType = UnmanagedType.I1)]
+            public byte[] byWordInfo;//文字信息
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024, ArraySubType = UnmanagedType.I1)]
+            public byte[] byPicInfo;//相片信息
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024, ArraySubType = UnmanagedType.I1)]
+            public byte[] byFingerPrintInfo;//指纹信息
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 40, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;
+
+            public void Init()
+            {
+                byWordInfo = new byte[256];
+                byPicInfo = new byte[1024];
+                byFingerPrintInfo = new byte[1024];
+                byRes = new byte[40];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_DATA_BUFFER
+        {
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_FILE_PATH_LEN, ArraySubType = UnmanagedType.I1)]
+            public byte[] szName;  //[OUT]对应name字段
+            public IntPtr pDataBuffer;         //[IN/OUT]数据缓冲区
+            public int dwDataSize;              //[IN/OUT]数据缓冲区大小/实际从设备接收到的数据的长度
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;               //保留
+
+            public void Init()
+            {
+                szName = new byte[MAX_FILE_PATH_LEN];
+                byRes = new byte[12];
+            }
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public struct USB_PT_PARAM
+        {
+            public int dwSize;   //结构体大小
+            public IntPtr pRequestUrl;        //[IN]请求URL
+            public int dwRequestUrlLen;    //[IN]请求URL长度
+            public IntPtr pInBuffer;          //[IN]输入数据
+            public int dwInSize;           //[IN]输入数据长度
+            public IntPtr pOutBuffer;         //[IN/OUT]输出缓冲区
+            public int dwOutSize;          //[IN/OUT]输出缓冲区大小/实际从设备接收到的数据的长度
+            public int dwSendTimeOut;      //[IN]默认5000ms
+            public int dwRecvTimeOut;      //[IN]默认5000ms
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DATA_NUM, ArraySubType = UnmanagedType.Struct)]
+            public USB_DATA_BUFFER[] struData;
+            public byte byNumOfMultiPart;   //[IN]0-无效,其他值表示报文分段个数,非零时pInBuffer传入的是USB_SDK_MIME_UNIT结构体数组的指针,该值即代表结构体个数
+            public byte byNumOfData;        //[OUT]实际设备返回的DATA数据数量(如采集人脸数量)
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 62, ArraySubType = UnmanagedType.I1)]
+            public byte[] byRes;          //保留
+            public void Init()
+            {
+                struData = new USB_DATA_BUFFER[MAX_DATA_NUM];
+                for (int i = 0; i < MAX_DATA_NUM; i++)
+                {
+                    struData[i].Init();
+                }
+
+                byRes = new byte[62];
+            }
+        }
+
+        #endregion
+
+        #region HCUsbSDK.dll function definition
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern bool USB_Init();
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern bool USB_Cleanup();
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern uint USB_GetLastError();
+
+        public delegate void EnumDeviceCallBack(ref CHCUsbSDK.USB_DEVICE_INFO pDevceInfo, IntPtr pUser);
+       
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern bool USB_EnumDevices(int dwCount, IntPtr pDevInfoList);
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern int USB_GetDeviceCount();
+
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern IntPtr USB_GetErrorMsg(uint dwErrorCode);
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern bool USB_SetLogToFile(uint dwLogLevel, IntPtr strLogDir, bool bAutoDel);
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern uint USB_GetSDKVersion();
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern int USB_Login(ref CHCUsbSDK.USB_USER_LOGIN_INFO pUsbLoginInfo, ref CHCUsbSDK.USB_DEVICE_REG_RES pDevRegRes);
+
+        [DllImport(@"HCUSBSDK.dll")]
+        public static extern bool USB_Logout(int lUserID);
+
+        [DllImportAttribute(@"HCUSBSDK.dll")]
+        public static extern bool USB_GetDeviceConfig(int lUserID, uint dwCommand, ref CHCUsbSDK.USB_CONFIG_INPUT_INFO pInputInfo, ref CHCUsbSDK.USB_CONFIG_OUTPUT_INFO pOutputInfo);
+
+        [DllImportAttribute(@"HCUSBSDK.dll")]
+        public static extern bool USB_SetDeviceConfig(int lUserID, uint dwCommand, ref CHCUsbSDK.USB_CONFIG_INPUT_INFO pInputInfo, ref CHCUsbSDK.USB_CONFIG_OUTPUT_INFO pOutputInfo);
+
+        [DllImportAttribute(@"HCUSBSDK.dll")]
+        public static extern bool USB_TransConfig(int lUserID, ref USB_PT_PARAM lpParam);
+
+        [DllImport(@"Dewlt.dll")]
+        public static extern int dewlt(IntPtr strPictureBin);
+        #endregion
+
+    }
+}

+ 76 - 0
CollectInformation/HCUSBSDK/Nationality.cs

@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CollectInformation.HCUSBSDK
+{
+    public static class Nationality
+    {
+        static Dictionary<string, string> NationalDictionary= new Dictionary<string, string>()
+        {
+            {"01","汉"},
+            {"02","蒙古"},
+            {"03","回"},
+            {"04","藏"},
+            {"05","维吾尔"},
+            {"06","苗"},
+            {"07","彝"},
+            {"08","壮"},
+            {"09","布依"},
+            {"10","朝鲜"},
+            {"11","满"},
+            {"12","侗"},
+            {"13","瑶"},
+            {"14","白"},
+            {"15","土家"},
+            {"16","哈尼"},
+            {"17","哈萨克"},
+            {"18","傣"},
+            {"19","黎"},
+            {"20","傈僳"},
+            {"21","佤"},
+            {"22","畲"},
+            {"23","高山"},
+            {"24","拉祜"},
+            {"25","水"},
+            {"26","东乡"},
+            {"27","纳西"},
+            {"28","景颇"},
+            {"29","柯尔克孜"},
+            {"30","土"},
+            {"31","达斡尔"},
+            {"32","仫佬"},
+            {"33","羌"},
+            {"34","布朗"},
+            {"35","撒拉"},
+            {"36","毛南"},
+            {"37","仡佬"},
+            {"38","锡伯"},
+            {"39","阿昌"},
+            {"40","普米"},
+            {"41","塔吉克"},
+            {"42","怒"},
+            {"43","乌孜别克"},
+            {"44","俄罗斯"},
+            {"45","鄂温克"},
+            {"46","德昂"},
+            {"47","保安"},
+            {"48","裕固"},
+            {"49","京"},
+            {"50","塔塔尔"},
+            {"51","独龙"},
+            {"52","鄂伦春"},
+            {"53","赫哲"},
+            {"54","门巴"},
+            {"55","珞巴"},
+            {"56","基诺"},
+        };
+
+        public static string GetNationality(ref string Num)
+        {
+            return NationalDictionary[Num];
+        }
+    }
+}

二进制
CollectInformation/HCUSBSDK/hpr.dll


二进制
CollectInformation/HCUSBSDK/libeay32.dll


二进制
CollectInformation/HCUSBSDK/libusb-1.0.dll


二进制
CollectInformation/HCUSBSDK/ssleay32.dll


+ 646 - 0
CollectInformation/MainForm.Designer.cs

@@ -0,0 +1,646 @@
+
+namespace CollectInformation
+{
+    partial class MainForm
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.labID = new System.Windows.Forms.Label();
+            this.labAddress = new System.Windows.Forms.Label();
+            this.labBirthday = new System.Windows.Forms.Label();
+            this.labNation = new System.Windows.Forms.Label();
+            this.labSex = new System.Windows.Forms.Label();
+            this.labName = new System.Windows.Forms.Label();
+            this.labSigning = new System.Windows.Forms.Label();
+            this.labValidity = new System.Windows.Forms.Label();
+            this.label8 = new System.Windows.Forms.Label();
+            this.label7 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label10 = new System.Windows.Forms.Label();
+            this.labLinkStatus = new System.Windows.Forms.Label();
+            this.btnLinkEquipment = new System.Windows.Forms.Button();
+            this.btnReadID = new System.Windows.Forms.Button();
+            this.btnOK = new System.Windows.Forms.Button();
+            this.btnClear = new System.Windows.Forms.Button();
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.labCompany = new System.Windows.Forms.Label();
+            this.label16 = new System.Windows.Forms.Label();
+            this.labBeforeName = new System.Windows.Forms.Label();
+            this.label14 = new System.Windows.Forms.Label();
+            this.labLevel = new System.Windows.Forms.Label();
+            this.label11 = new System.Windows.Forms.Label();
+            this.labUserFingerprint = new System.Windows.Forms.Label();
+            this.label12 = new System.Windows.Forms.Label();
+            this.labID2 = new System.Windows.Forms.Label();
+            this.labBirthday2 = new System.Windows.Forms.Label();
+            this.labNation2 = new System.Windows.Forms.Label();
+            this.labSex2 = new System.Windows.Forms.Label();
+            this.labName2 = new System.Windows.Forms.Label();
+            this.label17 = new System.Windows.Forms.Label();
+            this.label19 = new System.Windows.Forms.Label();
+            this.label20 = new System.Windows.Forms.Label();
+            this.label21 = new System.Windows.Forms.Label();
+            this.label22 = new System.Windows.Forms.Label();
+            this.picUser = new System.Windows.Forms.PictureBox();
+            this.btnGetFingerprint = new System.Windows.Forms.Button();
+            this.btnGetImage = new System.Windows.Forms.Button();
+            this.btnReplaceUser = new System.Windows.Forms.Button();
+            this.picID = new System.Windows.Forms.PictureBox();
+            this.groupBox1.SuspendLayout();
+            this.groupBox2.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.picUser)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.picID)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox1.Controls.Add(this.picID);
+            this.groupBox1.Controls.Add(this.labID);
+            this.groupBox1.Controls.Add(this.labAddress);
+            this.groupBox1.Controls.Add(this.labBirthday);
+            this.groupBox1.Controls.Add(this.labNation);
+            this.groupBox1.Controls.Add(this.labSex);
+            this.groupBox1.Controls.Add(this.labName);
+            this.groupBox1.Controls.Add(this.labSigning);
+            this.groupBox1.Controls.Add(this.labValidity);
+            this.groupBox1.Controls.Add(this.label8);
+            this.groupBox1.Controls.Add(this.label7);
+            this.groupBox1.Controls.Add(this.label5);
+            this.groupBox1.Controls.Add(this.label6);
+            this.groupBox1.Controls.Add(this.label4);
+            this.groupBox1.Controls.Add(this.label3);
+            this.groupBox1.Controls.Add(this.label2);
+            this.groupBox1.Controls.Add(this.label1);
+            this.groupBox1.Location = new System.Drawing.Point(12, 96);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(653, 160);
+            this.groupBox1.TabIndex = 1;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "身份证信息";
+            // 
+            // labID
+            // 
+            this.labID.AutoSize = true;
+            this.labID.Location = new System.Drawing.Point(104, 101);
+            this.labID.Name = "labID";
+            this.labID.Size = new System.Drawing.Size(113, 12);
+            this.labID.TabIndex = 3;
+            this.labID.Text = "220101190001010011";
+            // 
+            // labAddress
+            // 
+            this.labAddress.AutoSize = true;
+            this.labAddress.Location = new System.Drawing.Point(49, 68);
+            this.labAddress.Name = "labAddress";
+            this.labAddress.Size = new System.Drawing.Size(41, 12);
+            this.labAddress.TabIndex = 3;
+            this.labAddress.Text = "未获取";
+            // 
+            // labBirthday
+            // 
+            this.labBirthday.AutoSize = true;
+            this.labBirthday.Location = new System.Drawing.Point(395, 35);
+            this.labBirthday.Name = "labBirthday";
+            this.labBirthday.Size = new System.Drawing.Size(41, 12);
+            this.labBirthday.TabIndex = 3;
+            this.labBirthday.Text = "未获取";
+            // 
+            // labNation
+            // 
+            this.labNation.AutoSize = true;
+            this.labNation.Location = new System.Drawing.Point(272, 35);
+            this.labNation.Name = "labNation";
+            this.labNation.Size = new System.Drawing.Size(41, 12);
+            this.labNation.TabIndex = 3;
+            this.labNation.Text = "未获取";
+            // 
+            // labSex
+            // 
+            this.labSex.AutoSize = true;
+            this.labSex.Location = new System.Drawing.Point(167, 35);
+            this.labSex.Name = "labSex";
+            this.labSex.Size = new System.Drawing.Size(41, 12);
+            this.labSex.TabIndex = 3;
+            this.labSex.Text = "未获取";
+            // 
+            // labName
+            // 
+            this.labName.AutoSize = true;
+            this.labName.Location = new System.Drawing.Point(49, 35);
+            this.labName.Name = "labName";
+            this.labName.Size = new System.Drawing.Size(41, 12);
+            this.labName.TabIndex = 3;
+            this.labName.Text = "未获取";
+            // 
+            // labSigning
+            // 
+            this.labSigning.AutoSize = true;
+            this.labSigning.Location = new System.Drawing.Point(291, 101);
+            this.labSigning.Name = "labSigning";
+            this.labSigning.Size = new System.Drawing.Size(41, 12);
+            this.labSigning.TabIndex = 2;
+            this.labSigning.Text = "未获取";
+            // 
+            // labValidity
+            // 
+            this.labValidity.AutoSize = true;
+            this.labValidity.Location = new System.Drawing.Point(62, 134);
+            this.labValidity.Name = "labValidity";
+            this.labValidity.Size = new System.Drawing.Size(41, 12);
+            this.labValidity.TabIndex = 2;
+            this.labValidity.Text = "未获取";
+            // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(9, 134);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(53, 12);
+            this.label8.TabIndex = 2;
+            this.label8.Text = "有效期:";
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Location = new System.Drawing.Point(232, 101);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(65, 12);
+            this.label7.TabIndex = 2;
+            this.label7.Text = "签发机关:";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(9, 101);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(101, 12);
+            this.label6.TabIndex = 2;
+            this.label6.Text = "公民身份证号码:";
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(9, 68);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(41, 12);
+            this.label5.TabIndex = 2;
+            this.label5.Text = "住址:";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(335, 35);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(65, 12);
+            this.label4.TabIndex = 2;
+            this.label4.Text = "出生日期:";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(232, 35);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(41, 12);
+            this.label3.TabIndex = 2;
+            this.label3.Text = "民族:";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(127, 35);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(41, 12);
+            this.label2.TabIndex = 2;
+            this.label2.Text = "性别:";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(9, 35);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(41, 12);
+            this.label1.TabIndex = 1;
+            this.label1.Text = "姓名:";
+            // 
+            // label10
+            // 
+            this.label10.AutoSize = true;
+            this.label10.Location = new System.Drawing.Point(13, 13);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(65, 12);
+            this.label10.TabIndex = 2;
+            this.label10.Text = "当前设备:";
+            // 
+            // labLinkStatus
+            // 
+            this.labLinkStatus.AutoSize = true;
+            this.labLinkStatus.Location = new System.Drawing.Point(86, 13);
+            this.labLinkStatus.Name = "labLinkStatus";
+            this.labLinkStatus.Size = new System.Drawing.Size(41, 12);
+            this.labLinkStatus.TabIndex = 2;
+            this.labLinkStatus.Text = "未连接";
+            // 
+            // btnLinkEquipment
+            // 
+            this.btnLinkEquipment.Location = new System.Drawing.Point(15, 39);
+            this.btnLinkEquipment.Name = "btnLinkEquipment";
+            this.btnLinkEquipment.Size = new System.Drawing.Size(75, 23);
+            this.btnLinkEquipment.TabIndex = 3;
+            this.btnLinkEquipment.Text = "链接设备";
+            this.btnLinkEquipment.UseVisualStyleBackColor = true;
+            this.btnLinkEquipment.Click += new System.EventHandler(this.btnLinkEquipment_Click);
+            // 
+            // btnReadID
+            // 
+            this.btnReadID.Location = new System.Drawing.Point(96, 39);
+            this.btnReadID.Name = "btnReadID";
+            this.btnReadID.Size = new System.Drawing.Size(75, 23);
+            this.btnReadID.TabIndex = 4;
+            this.btnReadID.Text = "读取身份证";
+            this.btnReadID.UseVisualStyleBackColor = true;
+            this.btnReadID.Click += new System.EventHandler(this.btnReadID_Click);
+            // 
+            // btnOK
+            // 
+            this.btnOK.Location = new System.Drawing.Point(177, 39);
+            this.btnOK.Name = "btnOK";
+            this.btnOK.Size = new System.Drawing.Size(75, 23);
+            this.btnOK.TabIndex = 5;
+            this.btnOK.Text = "提交";
+            this.btnOK.UseVisualStyleBackColor = true;
+            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
+            // 
+            // btnClear
+            // 
+            this.btnClear.Location = new System.Drawing.Point(258, 39);
+            this.btnClear.Name = "btnClear";
+            this.btnClear.Size = new System.Drawing.Size(75, 23);
+            this.btnClear.TabIndex = 6;
+            this.btnClear.Text = "清空";
+            this.btnClear.UseVisualStyleBackColor = true;
+            this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox2.Controls.Add(this.labCompany);
+            this.groupBox2.Controls.Add(this.label16);
+            this.groupBox2.Controls.Add(this.labBeforeName);
+            this.groupBox2.Controls.Add(this.label14);
+            this.groupBox2.Controls.Add(this.labLevel);
+            this.groupBox2.Controls.Add(this.label11);
+            this.groupBox2.Controls.Add(this.labUserFingerprint);
+            this.groupBox2.Controls.Add(this.label12);
+            this.groupBox2.Controls.Add(this.labID2);
+            this.groupBox2.Controls.Add(this.labBirthday2);
+            this.groupBox2.Controls.Add(this.labNation2);
+            this.groupBox2.Controls.Add(this.labSex2);
+            this.groupBox2.Controls.Add(this.labName2);
+            this.groupBox2.Controls.Add(this.label17);
+            this.groupBox2.Controls.Add(this.label19);
+            this.groupBox2.Controls.Add(this.label20);
+            this.groupBox2.Controls.Add(this.label21);
+            this.groupBox2.Controls.Add(this.label22);
+            this.groupBox2.Controls.Add(this.picUser);
+            this.groupBox2.Location = new System.Drawing.Point(12, 262);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(653, 335);
+            this.groupBox2.TabIndex = 7;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "报考人员信息";
+            // 
+            // labCompany
+            // 
+            this.labCompany.AutoSize = true;
+            this.labCompany.Location = new System.Drawing.Point(73, 212);
+            this.labCompany.Name = "labCompany";
+            this.labCompany.Size = new System.Drawing.Size(41, 12);
+            this.labCompany.TabIndex = 18;
+            this.labCompany.Text = "未获取";
+            // 
+            // label16
+            // 
+            this.label16.AutoSize = true;
+            this.label16.Location = new System.Drawing.Point(14, 212);
+            this.label16.Name = "label16";
+            this.label16.Size = new System.Drawing.Size(53, 12);
+            this.label16.TabIndex = 19;
+            this.label16.Text = "报考企业";
+            // 
+            // labBeforeName
+            // 
+            this.labBeforeName.AutoSize = true;
+            this.labBeforeName.Location = new System.Drawing.Point(61, 71);
+            this.labBeforeName.Name = "labBeforeName";
+            this.labBeforeName.Size = new System.Drawing.Size(41, 12);
+            this.labBeforeName.TabIndex = 18;
+            this.labBeforeName.Text = "未获取";
+            // 
+            // label14
+            // 
+            this.label14.AutoSize = true;
+            this.label14.Location = new System.Drawing.Point(14, 71);
+            this.label14.Name = "label14";
+            this.label14.Size = new System.Drawing.Size(41, 12);
+            this.label14.TabIndex = 19;
+            this.label14.Text = "曾用名";
+            // 
+            // labLevel
+            // 
+            this.labLevel.AutoSize = true;
+            this.labLevel.Location = new System.Drawing.Point(73, 179);
+            this.labLevel.Name = "labLevel";
+            this.labLevel.Size = new System.Drawing.Size(41, 12);
+            this.labLevel.TabIndex = 18;
+            this.labLevel.Text = "未获取";
+            // 
+            // label11
+            // 
+            this.label11.AutoSize = true;
+            this.label11.Location = new System.Drawing.Point(14, 179);
+            this.label11.Name = "label11";
+            this.label11.Size = new System.Drawing.Size(53, 12);
+            this.label11.TabIndex = 19;
+            this.label11.Text = "报考等级";
+            // 
+            // labUserFingerprint
+            // 
+            this.labUserFingerprint.AutoSize = true;
+            this.labUserFingerprint.Location = new System.Drawing.Point(85, 274);
+            this.labUserFingerprint.Name = "labUserFingerprint";
+            this.labUserFingerprint.Size = new System.Drawing.Size(41, 12);
+            this.labUserFingerprint.TabIndex = 18;
+            this.labUserFingerprint.Text = "未获取";
+            // 
+            // label12
+            // 
+            this.label12.AutoSize = true;
+            this.label12.Location = new System.Drawing.Point(14, 274);
+            this.label12.Name = "label12";
+            this.label12.Size = new System.Drawing.Size(65, 12);
+            this.label12.TabIndex = 19;
+            this.label12.Text = "指纹特征值";
+            // 
+            // labID2
+            // 
+            this.labID2.AutoSize = true;
+            this.labID2.Location = new System.Drawing.Point(109, 244);
+            this.labID2.Name = "labID2";
+            this.labID2.Size = new System.Drawing.Size(41, 12);
+            this.labID2.TabIndex = 11;
+            this.labID2.Text = "未获取";
+            // 
+            // labBirthday2
+            // 
+            this.labBirthday2.AutoSize = true;
+            this.labBirthday2.Location = new System.Drawing.Point(54, 143);
+            this.labBirthday2.Name = "labBirthday2";
+            this.labBirthday2.Size = new System.Drawing.Size(41, 12);
+            this.labBirthday2.TabIndex = 13;
+            this.labBirthday2.Text = "未获取";
+            // 
+            // labNation2
+            // 
+            this.labNation2.AutoSize = true;
+            this.labNation2.Location = new System.Drawing.Point(146, 107);
+            this.labNation2.Name = "labNation2";
+            this.labNation2.Size = new System.Drawing.Size(41, 12);
+            this.labNation2.TabIndex = 14;
+            this.labNation2.Text = "未获取";
+            // 
+            // labSex2
+            // 
+            this.labSex2.AutoSize = true;
+            this.labSex2.Location = new System.Drawing.Point(54, 107);
+            this.labSex2.Name = "labSex2";
+            this.labSex2.Size = new System.Drawing.Size(41, 12);
+            this.labSex2.TabIndex = 15;
+            this.labSex2.Text = "未获取";
+            // 
+            // labName2
+            // 
+            this.labName2.AutoSize = true;
+            this.labName2.Location = new System.Drawing.Point(54, 35);
+            this.labName2.Name = "labName2";
+            this.labName2.Size = new System.Drawing.Size(41, 12);
+            this.labName2.TabIndex = 16;
+            this.labName2.Text = "未获取";
+            // 
+            // label17
+            // 
+            this.label17.AutoSize = true;
+            this.label17.Location = new System.Drawing.Point(14, 244);
+            this.label17.Name = "label17";
+            this.label17.Size = new System.Drawing.Size(89, 12);
+            this.label17.TabIndex = 6;
+            this.label17.Text = "公民身份证号码";
+            // 
+            // label19
+            // 
+            this.label19.AutoSize = true;
+            this.label19.Location = new System.Drawing.Point(14, 143);
+            this.label19.Name = "label19";
+            this.label19.Size = new System.Drawing.Size(29, 12);
+            this.label19.TabIndex = 8;
+            this.label19.Text = "出生";
+            // 
+            // label20
+            // 
+            this.label20.AutoSize = true;
+            this.label20.Location = new System.Drawing.Point(106, 107);
+            this.label20.Name = "label20";
+            this.label20.Size = new System.Drawing.Size(29, 12);
+            this.label20.TabIndex = 9;
+            this.label20.Text = "民族";
+            // 
+            // label21
+            // 
+            this.label21.AutoSize = true;
+            this.label21.Location = new System.Drawing.Point(14, 107);
+            this.label21.Name = "label21";
+            this.label21.Size = new System.Drawing.Size(29, 12);
+            this.label21.TabIndex = 10;
+            this.label21.Text = "性别";
+            // 
+            // label22
+            // 
+            this.label22.AutoSize = true;
+            this.label22.Location = new System.Drawing.Point(14, 35);
+            this.label22.Name = "label22";
+            this.label22.Size = new System.Drawing.Size(29, 12);
+            this.label22.TabIndex = 5;
+            this.label22.Text = "姓名";
+            // 
+            // picUser
+            // 
+            this.picUser.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.picUser.BackgroundImage = global::CollectInformation.Properties.Resources.d_head;
+            this.picUser.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+            this.picUser.ImageLocation = "";
+            this.picUser.Location = new System.Drawing.Point(487, 25);
+            this.picUser.Name = "picUser";
+            this.picUser.Size = new System.Drawing.Size(153, 214);
+            this.picUser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+            this.picUser.TabIndex = 4;
+            this.picUser.TabStop = false;
+            // 
+            // btnGetFingerprint
+            // 
+            this.btnGetFingerprint.Location = new System.Drawing.Point(562, 39);
+            this.btnGetFingerprint.Name = "btnGetFingerprint";
+            this.btnGetFingerprint.Size = new System.Drawing.Size(102, 23);
+            this.btnGetFingerprint.TabIndex = 17;
+            this.btnGetFingerprint.Text = "采集指纹";
+            this.btnGetFingerprint.UseVisualStyleBackColor = true;
+            this.btnGetFingerprint.Click += new System.EventHandler(this.btnGetFingerprint_Click);
+            // 
+            // btnGetImage
+            // 
+            this.btnGetImage.Location = new System.Drawing.Point(454, 39);
+            this.btnGetImage.Name = "btnGetImage";
+            this.btnGetImage.Size = new System.Drawing.Size(102, 23);
+            this.btnGetImage.TabIndex = 17;
+            this.btnGetImage.Text = "采集人像";
+            this.btnGetImage.UseVisualStyleBackColor = true;
+            this.btnGetImage.Click += new System.EventHandler(this.btnGetImage_Click);
+            // 
+            // btnReplaceUser
+            // 
+            this.btnReplaceUser.Location = new System.Drawing.Point(339, 39);
+            this.btnReplaceUser.Name = "btnReplaceUser";
+            this.btnReplaceUser.Size = new System.Drawing.Size(109, 23);
+            this.btnReplaceUser.TabIndex = 8;
+            this.btnReplaceUser.Text = "使用身份证信息";
+            this.btnReplaceUser.UseVisualStyleBackColor = true;
+            this.btnReplaceUser.Click += new System.EventHandler(this.btnReplaceUser_Click);
+            // 
+            // picID
+            // 
+            this.picID.BackgroundImage = global::CollectInformation.Properties.Resources.d_head;
+            this.picID.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.picID.Location = new System.Drawing.Point(540, 26);
+            this.picID.Name = "picID";
+            this.picID.Size = new System.Drawing.Size(100, 115);
+            this.picID.TabIndex = 4;
+            this.picID.TabStop = false;
+            // 
+            // MainForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(677, 609);
+            this.Controls.Add(this.btnReplaceUser);
+            this.Controls.Add(this.groupBox2);
+            this.Controls.Add(this.btnClear);
+            this.Controls.Add(this.btnOK);
+            this.Controls.Add(this.btnReadID);
+            this.Controls.Add(this.btnLinkEquipment);
+            this.Controls.Add(this.labLinkStatus);
+            this.Controls.Add(this.label10);
+            this.Controls.Add(this.btnGetFingerprint);
+            this.Controls.Add(this.btnGetImage);
+            this.Controls.Add(this.groupBox1);
+            this.MaximizeBox = false;
+            this.MinimizeBox = false;
+            this.Name = "MainForm";
+            this.ShowIcon = false;
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "长春市保安监管系统采集终端";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
+            this.Load += new System.EventHandler(this.MainForm_Load);
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox1.PerformLayout();
+            this.groupBox2.ResumeLayout(false);
+            this.groupBox2.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.picUser)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.picID)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.Label labID;
+        private System.Windows.Forms.Label labAddress;
+        private System.Windows.Forms.Label labBirthday;
+        private System.Windows.Forms.Label labNation;
+        private System.Windows.Forms.Label labSex;
+        private System.Windows.Forms.Label labName;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label labSigning;
+        private System.Windows.Forms.Label labValidity;
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.Label label10;
+        private System.Windows.Forms.Label labLinkStatus;
+        private System.Windows.Forms.Button btnLinkEquipment;
+        private System.Windows.Forms.Button btnReadID;
+        private System.Windows.Forms.Button btnOK;
+        private System.Windows.Forms.Button btnClear;
+        private System.Windows.Forms.GroupBox groupBox2;
+        private System.Windows.Forms.Button btnGetImage;
+        private System.Windows.Forms.Label labID2;
+        private System.Windows.Forms.Label labBirthday2;
+        private System.Windows.Forms.Label labNation2;
+        private System.Windows.Forms.Label labSex2;
+        private System.Windows.Forms.Label labName2;
+        private System.Windows.Forms.Label label17;
+        private System.Windows.Forms.Label label19;
+        private System.Windows.Forms.Label label20;
+        private System.Windows.Forms.Label label21;
+        private System.Windows.Forms.Label label22;
+        private System.Windows.Forms.PictureBox picUser;
+        private System.Windows.Forms.Button btnReplaceUser;
+        private System.Windows.Forms.Label labUserFingerprint;
+        private System.Windows.Forms.Label label12;
+        private System.Windows.Forms.Button btnGetFingerprint;
+        private System.Windows.Forms.Label labCompany;
+        private System.Windows.Forms.Label label16;
+        private System.Windows.Forms.Label labBeforeName;
+        private System.Windows.Forms.Label label14;
+        private System.Windows.Forms.Label labLevel;
+        private System.Windows.Forms.Label label11;
+        private System.Windows.Forms.PictureBox picID;
+    }
+}
+

+ 567 - 0
CollectInformation/MainForm.cs

@@ -0,0 +1,567 @@
+using CollectInformation.HCUSBSDK;
+using CollectInformation.Tools;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace CollectInformation
+{
+    public partial class MainForm : Form
+    {
+        Dictionary<string, string> loginUser = null;
+        //Dictionary<string, string> user = null;
+        Dictionary<string, string> securityInfo = null;
+        HCUSBUtils hcUSBUtils = null;
+
+        bool isInit = false;
+        string sdkLevel = "";
+        string devName = "";
+        bool isLoginD = false;
+
+        public MainForm()
+        {
+            InitializeComponent();
+        }
+        public MainForm(Dictionary<string, string> loginUser)
+        {
+            InitializeComponent();
+            this.loginUser = loginUser;
+            if (loginUser != null)
+            {
+                this.Text = loginUser["name"] + "欢迎您使用" + this.Text;
+            }
+            isInit = false;
+            this.btnLinkEquipment.Enabled = true;
+            this.btnReadID.Enabled = false;
+            initD();
+        }
+
+        private void initD()
+        {
+            this.hcUSBUtils = new HCUSBUtils();
+            this.sdkLevel = "SDK lv " + hcUSBUtils.initSDK();
+
+            this.isInit = this.hcUSBUtils.TraverseDevice();
+            if (this.isInit)
+            {
+                this.devName = System.Text.Encoding.UTF8.GetString(this.hcUSBUtils.m_aHidDevInfo[0].szDeviceName).TrimEnd('\0');
+                this.labLinkStatus.Text = "" + this.devName + " | " + this.sdkLevel;
+            }
+            else
+            {
+                this.isInit = false;
+                MessageBox.Show("当前设备链接失败,请尝试重新链接,或联系管理员。", "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+            }
+        }
+
+        private void MainForm_Load(object sender, EventArgs e)
+        {
+
+            if (securityInfo == null)
+            {
+                clear();
+            }
+        }
+
+        private void btnReplaceUser_Click(object sender, EventArgs e)
+        {
+            if (MessageBox.Show("您将要使用当前身份证信息覆盖报名人员信息,此操作无法撤销,请确定是否进行操作!", "系统警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
+            {
+                this.labName2.Text = this.labName.Text;
+                this.labSex2.Text = this.labSex.Text;
+                this.labNation2.Text = this.labNation.Text;
+                this.labBirthday2.Text = this.labBirthday.Text.Replace("年", "-").Replace("月", "-").Replace("日", "");
+
+                this.securityInfo["name"] = this.labName.Text;
+                this.securityInfo["gender"] = this.labSex.Text;
+                this.securityInfo["nation"] = this.labNation.Text;
+                this.securityInfo["birth"] = this.labBirthday.Text.Replace("年", "-").Replace("月", "-").Replace("日", "");
+            }
+        }
+
+        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (e.CloseReason == CloseReason.UserClosing)
+            {
+                if (MessageBox.Show("您确定要退出采集终端么?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
+                {
+                    e.Cancel = true;
+                }
+                else
+                {
+                    Application.Exit();
+                }
+            }
+        }
+
+        private void btnLinkEquipment_Click(object sender, EventArgs e)
+        {
+            if (!this.isInit)
+            {
+                initD();
+            }
+            if (this.isInit)
+            {
+                this.isLoginD = hcUSBUtils.LoginDevice();
+                if (this.isLoginD)
+                {
+                    MessageBox.Show("设备链接成功。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                    this.btnReadID.Enabled = true;
+                    this.labLinkStatus.Text = "已连接 " + this.devName + " | " + this.sdkLevel;
+                }
+                else
+                {
+                    MessageBox.Show("当前设备链接失败,请尝试重新链接,或联系管理员。", "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                }
+            }
+        }
+
+        private void btnReadID_Click(object sender, EventArgs e)
+        {
+            // 获取身份证信息
+            string inputStr = "{\"IdentityInfoCond\":{}}";
+            string outputStr = this.hcUSBUtils.CollectionNoImage(1, inputStr).TrimEnd('\0');
+            try
+            {
+                Dictionary<string, object> d1 = JsonConvert.DeserializeObject<Dictionary<string, object>>(outputStr);
+                if (d1.ContainsKey("statusString"))
+                {
+                    MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
+            }
+            catch (Exception)
+            {
+                XmlDocument xdoc = new XmlDocument();
+                xdoc.LoadXml(outputStr);
+
+                XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
+                nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
+
+                XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
+                if (statusNode != null)
+                {
+                    MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
+                else
+                {
+                    outputStr = JsonConvert.SerializeXmlNode(xdoc.FirstChild);
+                }
+            }
+
+            Dictionary<String, object> os = JsonConvert.DeserializeObject<Dictionary<string, object>>(outputStr);
+
+            Dictionary<string, object> IdentityInfoD = JsonConvert.DeserializeObject<Dictionary<string, object>>(os["IdentityInfo"].ToString());
+
+
+            this.labName.Text = IdentityInfoD["chnName"].ToString();
+            this.labSex.Text = IdentityInfoD["sex"].ToString() == "male" ? "男" : IdentityInfoD["sex"].ToString() == "female" ? "女" : "未知";
+            string nationIndex = IdentityInfoD["nation"].ToString().PadLeft(2, '0');
+            this.labNation.Text = Nationality.GetNationality(ref nationIndex);
+            this.labBirthday.Text = this.getDate(IdentityInfoD["birth"].ToString());
+            this.labAddress.Text = IdentityInfoD["addr"].ToString();
+            this.labID.Text = IdentityInfoD["IDCardNo"].ToString(); // "220182199603257024";
+            this.labSigning.Text = IdentityInfoD["issuingAuthority"].ToString();
+            this.labValidity.Text = this.getDate(IdentityInfoD["startDate"].ToString()) + " 至 " + this.getDate(IdentityInfoD["endDate"].ToString());
+
+            // 使用身份证号获取待采集人员
+            string url = constants.host + string.Format(constants.fetch, "security_guard_base") + "?status=1&card=" + labID.Text;
+
+            Dictionary<string, string> res = HttpUitls.Get(url, constants.userToken);
+            if (res["code"] == "0")
+            {
+                MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+            else
+            {
+                Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                if (retData["errcode"].ToString() == "0")
+                {
+                    Dictionary<string, Object> ret = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                    if (ret["data"] != null)
+                    {
+                        string securityStr = JsonConvert.SerializeObject(ret["data"]);
+                        this.securityInfo = JsonConvert.DeserializeObject<Dictionary<string, string>>(securityStr);
+                        this.labName2.Text = securityInfo["name"];
+                        this.labBeforeName.Text = securityInfo["beforeName"];
+                        this.labSex2.Text = securityInfo["gender"];
+                        this.labNation2.Text = securityInfo["nation"];
+                        this.labBirthday2.Text = securityInfo["birth"];
+                        this.labLevel.Text = securityInfo["grade"];
+                        this.labCompany.Text = securityInfo["sign_company"];
+                        this.labID2.Text = securityInfo["card"];
+
+                        this.btnOK.Enabled = true;
+                        if (securityInfo["collect_photo"].ToString() == "已采集")
+                        {
+                            this.btnGetImage.Enabled = false;
+                            url = constants.host + string.Format(constants.fetch, "security_guard_collect") + "?type=人像&security_guard_id=" + securityInfo["id"].ToString();
+                            Dictionary<string, string> resCollect = HttpUitls.Get(url, constants.userToken);
+                            if (res["code"] == "0")
+                            {
+                                this.btnGetImage.Enabled = true;
+                            }
+                            else
+                            {
+                                Dictionary<string, Object> collect = JsonConvert.DeserializeObject<Dictionary<string, Object>>(resCollect["data"]);
+                                string collectStr = JsonConvert.SerializeObject(collect["data"]);
+                                Dictionary<string, string> collect1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(collectStr);
+                                this.picUser.ImageLocation = constants.urlbase + collect1["data"].ToString();
+                            }
+                        }
+                        else
+                        {
+                            this.btnGetImage.Enabled = true;
+                        }
+                        this.btnGetFingerprint.Enabled = true;
+                        this.btnReplaceUser.Enabled = true;
+                    }
+                    else
+                    {
+                        MessageBox.Show("没有对应的待采集人员信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+                }
+                else
+                {
+                    MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+
+        }
+
+        private void btnClear_Click(object sender, EventArgs e)
+        {
+            clear();
+        }
+
+        private void clear()
+        {
+            // 清空身份证读取信息
+            this.labName.Text = "";
+            this.labSex.Text = "";
+            this.labNation.Text = "";
+            this.labBirthday.Text = "";
+            this.labAddress.Text = "";
+            this.labID.Text = "";
+            this.labSigning.Text = "";
+            this.labValidity.Text = "";
+
+            // 清空采集人员信息
+            this.securityInfo = null;
+            this.labName2.Text = "";
+            this.labBeforeName.Text = "";
+            this.labSex2.Text = "";
+            this.labNation2.Text = "";
+            this.labBirthday2.Text = "";
+            this.labLevel.Text = "";
+            this.labUserFingerprint.Text = "";
+            this.labCompany.Text = "";
+            this.labID2.Text = "";
+            this.picUser.Image = null;
+
+            // 控制管理按钮
+            this.btnReplaceUser.Enabled = false;
+            this.btnOK.Enabled = false;
+            this.btnGetFingerprint.Enabled = false;
+            this.btnGetImage.Enabled = false;
+        }
+
+        private void btnOK_Click(object sender, EventArgs e)
+        {
+            if (this.securityInfo != null)
+            {
+                // 上传指纹采集信息,并修改保安员状态
+                if (this.labUserFingerprint.Text == "" || this.labUserFingerprint.Text == "未获取")
+                {
+                    MessageBox.Show("请采集指纹信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                }
+                else if(this.securityInfo["collect_photo"] != "已采集" && this.picUser.Image == null)
+                {
+                    MessageBox.Show("请采集人像信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                }
+                else
+                {
+                    string url = constants.host + string.Format(constants.fetch, "security_guard_others") + "?security_guard_id=" + this.securityInfo["id"];
+
+                    Dictionary<string, string> res = HttpUitls.Get(url, constants.userToken);
+                    if (res["code"] == "0")
+                    {
+                        MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    }
+                    else
+                    {
+                        Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                        if (retData["errcode"].ToString() == "0")
+                        {
+                            Dictionary<string, Object> ret = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                            if (ret["data"] != null)
+                            {
+                                string otherStr = JsonConvert.SerializeObject(ret["data"]);
+                                Dictionary<string, string> securityOther = JsonConvert.DeserializeObject<Dictionary<string, string>>(otherStr);
+                                //securityOther["fingerprint_num"] = this.labUserFingerprint.Text;
+                                securityOther["fingerprint_date"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                                securityOther["fingerprint_personal"] = this.loginUser["name"];
+                                securityOther["fingerprint_office"] = this.loginUser["belong_company"];
+                                this.editSecurityOtherInfo(securityOther);
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                        }
+                    }
+                    Dictionary<string, string> collect = new Dictionary<string, string>();
+                    collect["name"] = this.securityInfo["name"];
+                    collect["security_guard_id"] = this.securityInfo["id"];
+                    collect["type"] = "指纹";
+                    collect["data"] = this.labUserFingerprint.Text;
+                    collect["collect_personal"] = this.loginUser["name"];
+                    collect["collect_police"] = this.loginUser["belong_company"];
+
+                    if (this.createSecurityCollect(collect))
+                    {
+                        if (this.securityInfo["collect_photo"] == "已采集")
+                        {
+                            this.securityInfo["status"] = "2";
+                            this.securityInfo["collect_fingerprint"] = "已采集";
+                            if (this.editSecurityBassInfo(this.securityInfo))
+                            {
+                                MessageBox.Show("信息上传成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                                clear();
+                            }
+                        }
+                        else
+                        {
+                            this.securityInfo["collect_fingerprint"] = "已采集";
+                            this.editSecurityBassInfo(this.securityInfo);
+                            // 上传头像信息,并修改保安员状态
+                            string upLoadUrl = string.Format(constants.filehost, "baoan", "collect", DateTime.Now.ToString("yyyyMMdd"), this.securityInfo["card"]);
+                            Dictionary<string, string> upLoadRes = HttpUitls.UploadImage(upLoadUrl, this.picUser.ImageLocation, constants.userToken);
+                            if (upLoadRes["code"] != "0")
+                            {
+                                Dictionary<string, Object> tempData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(upLoadRes["data"]);
+                                if (tempData["errcode"].ToString() == "0")
+                                {
+                                    //Dictionary<string, Object> upLoadResData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(tempData["data"].ToString());
+                                    collect = new Dictionary<string, string>();
+                                    collect["name"] = this.securityInfo["name"];
+                                    collect["security_guard_id"] = this.securityInfo["id"];
+                                    collect["type"] = "人像";
+                                    collect["data"] = tempData["uri"].ToString();
+                                    collect["collect_personal"] = this.loginUser["name"];
+                                    collect["collect_police"] = this.loginUser["belong_company"];
+
+                                    if (this.createSecurityCollect(collect))
+                                    {
+                                        // 全部处理成功后,修改保安员状态
+                                        this.securityInfo["collect_photo"] = "已采集";
+                                        this.securityInfo["status"] = "2";
+                                        if (this.editSecurityBassInfo(this.securityInfo))
+                                        {
+                                            MessageBox.Show("信息上传成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                                            clear();
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        MessageBox.Show("指纹信息保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    }
+                }
+
+            }
+            else
+            {
+                MessageBox.Show("没有需要提交写信息,请重新操作!", "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                this.btnOK.Enabled = false;
+            }
+        }
+        bool editSecurityBassInfo(Dictionary<string, string> security)
+        {
+            bool rest = false;
+
+            // 创建修改链接
+            string url = constants.host + string.Format(constants.update, "security_guard_base") + "?id=" + security["id"];
+
+            string data = JsonConvert.SerializeObject(security);
+            Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
+            if (res["code"] == "0")
+            {
+                MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+            else
+            {
+                Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                if (retData["errcode"].ToString() == "0")
+                {
+                    rest = true;
+                }
+                else
+                {
+                    MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+            return rest;
+        }
+        bool editSecurityOtherInfo(Dictionary<string, string> securityOther)
+        {
+            bool rest = false;
+
+            // 创建修改链接
+            string url = constants.host + string.Format(constants.update, "security_guard_others") + "?id=" + securityOther["id"];
+
+            string data = JsonConvert.SerializeObject(securityOther);
+            Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
+            if (res["code"] == "0")
+            {
+                MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+            else
+            {
+                Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                if (retData["errcode"].ToString() == "0")
+                {
+                    rest = true;
+                }
+                else
+                {
+                    MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+            return rest;
+        }
+        bool createSecurityCollect(Dictionary<string, string> collect)
+        {
+            bool rest = false;
+
+            // 创建修改链接
+            string url = constants.host + string.Format(constants.install, "security_guard_collect");
+
+
+            string data = JsonConvert.SerializeObject(collect);
+            Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
+            if (res["code"] == "0")
+            {
+                MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
+            else
+            {
+                Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                if (retData["errcode"].ToString() == "0")
+                {
+                    rest = true;
+                }
+                else
+                {
+                    MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+            }
+            return rest;
+        }
+
+        private void btnGetImage_Click(object sender, EventArgs e)
+        {
+            string filePath = Application.StartupPath + "\\" + constants.tempFiles;
+            string fileName = "tempImage.png";
+            string outputStr = this.hcUSBUtils.CaptureFace(filePath, fileName);
+            if (outputStr != null)
+            {
+                try
+                {
+                    Dictionary<string, string> d1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(outputStr);
+                    MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
+                catch (Exception)
+                {
+                    XmlDocument xdoc = new XmlDocument();
+                    xdoc.LoadXml(outputStr);
+
+                    XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
+                    nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
+
+                    XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
+                    if (statusNode != null)
+                    {
+                        MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+                    XmlNode captureProgressNode = xdoc.SelectSingleNode("/ns:CaptureFaceData/ns:captureProgress", nsMgr);
+                    if (captureProgressNode != null && captureProgressNode.InnerText == "100")
+                    {
+                        // 使用第一张图片
+                        string fileFullPath = filePath + "\\0_" + fileName;
+                        this.picUser.ImageLocation = fileFullPath;
+                    }
+                    else
+                    {
+                        MessageBox.Show("人像采集失败,请重新尝试。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+                }
+            }
+        }
+
+        private void btnGetFingerprint_Click(object sender, EventArgs e)
+        {
+            string inputStr = "<CaptureFingerPrintCond xmlns=\"http://www.isapi.org/ver20/XMLSchema\" version=\"2.0\">" +
+                                "<fingerNo>1</fingerNo>" +
+                            "</CaptureFingerPrintCond>";
+            string outputStr = this.hcUSBUtils.CollectionNoImage(2, inputStr).TrimEnd('\0');
+            if (outputStr != null)
+            {
+                try
+                {
+                    Dictionary<string, string> d1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(outputStr);
+                    MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    return;
+                }
+                catch (Exception)
+                {
+                    XmlDocument xdoc = new XmlDocument();
+                    xdoc.LoadXml(outputStr);
+
+                    XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
+                    nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
+
+                    //outputStr = JsonConvert.SerializeXmlNode(xdoc.FirstChild);
+
+                    XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
+                    if (statusNode != null)
+                    {
+                        MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+
+                    XmlNode fingerDataNode = xdoc.SelectSingleNode("/ns:CaptureFingerPrint/ns:fingerData", nsMgr);
+                    if (fingerDataNode != null)
+                    {
+                        string finger = fingerDataNode.InnerText;
+                        this.labUserFingerprint.Text = finger;
+                    }
+                    else
+                    {
+                        MessageBox.Show("指纹采集失败,请重新尝试。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    }
+
+                }
+            }
+        }
+
+        string getDate(string str)
+        {
+            string yyyy = str.Substring(0,4);
+            string mm = str.Substring(4, 2);
+            string dd = str.Substring(6, 2);
+
+            return yyyy + "年" + mm + "月" + dd + "日";
+        }
+
+    }
+}

+ 120 - 0
CollectInformation/MainForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 23 - 0
CollectInformation/Program.cs

@@ -0,0 +1,23 @@
+using CollectInformation.Tools;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace CollectInformation
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            constants.init(Application.StartupPath);
+            Application.Run(new LoginForm());
+        }
+    }
+}

+ 36 - 0
CollectInformation/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("CollectInformation")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CollectInformation")]
+[assembly: AssemblyCopyright("Copyright ©  2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("14c38775-bffd-4735-8bcd-79b73c7bc34f")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 73 - 0
CollectInformation/Properties/Resources.Designer.cs

@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace CollectInformation.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   一个强类型的资源类,用于查找本地化的字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   返回此类使用的缓存的 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CollectInformation.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   重写当前线程的 CurrentUICulture 属性,对
+        ///   使用此强类型资源类的所有资源查找执行重写。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap d_head {
+            get {
+                object obj = ResourceManager.GetObject("d-head", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+    }
+}

+ 124 - 0
CollectInformation/Properties/Resources.resx

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="d-head" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\d-head.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+</root>

+ 29 - 0
CollectInformation/Properties/Settings.Designer.cs

@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+
+namespace CollectInformation.Properties
+{
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
CollectInformation/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

二进制
CollectInformation/Resources/d-head.jpg


+ 149 - 0
CollectInformation/Tools/HttpUitls.cs

@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+
+namespace CollectInformation.Tools
+{
+    public static class HttpUitls
+    {
+        public static Dictionary<string, string> Get(string Url)
+        {
+            return Get(Url, null);
+        }
+        public static Dictionary<string, string> Get(string Url, string userToken)
+        {
+            Dictionary<string, string> ret = new Dictionary<string, string>();
+            ret.Add("code", "1");
+            try
+            {
+                //System.GC.Collect();
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
+                request.Proxy = null;
+                request.KeepAlive = false;
+                request.Method = "GET";
+                request.ContentType = "application/json; charset=UTF-8";
+
+                if (userToken != null)
+                {
+                    request.Headers.Add("Authorization", userToken);
+                }
+
+                request.AutomaticDecompression = DecompressionMethods.GZip;
+
+                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+                Stream myResponseStream = response.GetResponseStream();
+                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
+                string retString = myStreamReader.ReadToEnd();
+
+                myStreamReader.Close();
+                myResponseStream.Close();
+
+                if (response != null)
+                {
+                    response.Close();
+                }
+                if (request != null)
+                {
+                    request.Abort();
+                }
+
+
+                ret.Add("data", retString);
+            }
+            catch (Exception e)
+            {
+                ret["code"] = "0";
+                ret.Add("message", e.Message);
+            }
+            return ret;
+        }
+
+        public static Dictionary<string, string> Post(string Url, string Data, string Referer)
+        {
+            return Post(Url, Data, Referer, null);
+        }
+        public static Dictionary<string, string> Post(string Url, string Data, string Referer, string userToken)
+        {
+            Dictionary<string, string> ret = new Dictionary<string, string>();
+            ret.Add("code", "1");
+            try
+            {
+
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
+                request.Method = "POST";
+                request.Referer = Referer;
+                byte[] bytes = Encoding.UTF8.GetBytes(Data);
+                request.ContentType = "application/json; charset=UTF-8";
+
+                if (userToken != null)
+                {
+                    request.Headers.Add("Authorization", userToken);
+                }
+
+                request.ContentLength = bytes.Length;
+                Stream myResponseStream = request.GetRequestStream();
+                myResponseStream.Write(bytes, 0, bytes.Length);
+
+                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+                StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
+                string retString = myStreamReader.ReadToEnd();
+                // 添加调试输出
+                Console.WriteLine(retString);
+                ret.Add("data", retString);
+                myStreamReader.Close();
+                myResponseStream.Close();
+
+                if (response != null)
+                {
+                    response.Close();
+                }
+                if (request != null)
+                {
+                    request.Abort();
+                }
+            }
+            catch (Exception e)
+            {
+                ret["code"] = "0";
+                ret.Add("message", e.Message);
+            }
+            return ret;
+        }
+
+        /// <summary>
+        /// 通过http上传图片及传参数
+        /// </summary>
+        /// <param name="imgPath">图片地址(绝对路径:D:\demo\img\123.jpg)</param>
+        public static Dictionary<string, string> UploadImage(string uploadUrl, string imgPath, string userToken)
+        {
+            Dictionary<string, string> ret = new Dictionary<string, string>();
+            ret.Add("code", "1");
+            try
+            {
+                string resstr = "";
+            WebClient webClient = new WebClient();
+            if (userToken != null)
+            {
+                webClient.Headers.Add("Authorization", userToken);
+            }
+            byte[] res = webClient.UploadFile(uploadUrl, "POST", imgPath);
+            if (res != null)
+            {
+                resstr = System.Text.Encoding.UTF8.GetString(res);
+            }
+
+                ret.Add("data", resstr);
+        }
+            catch (Exception e)
+            {
+                ret["code"] = "0";
+                ret.Add("message", e.Message);
+            }
+            return ret;
+
+        }
+    }
+}

+ 56 - 0
CollectInformation/Tools/Image2Base64Utils.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Drawing;
+using System.IO;
+
+namespace CollectInformation.Tools
+{
+    static class Image2Base64Utils
+    {
+        #region 图片转为base64编码的字符串
+        public static string ImgToBase64String(Bitmap bmp)
+        {
+            try
+            {
+                MemoryStream ms = new MemoryStream();
+                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
+                byte[] arr = new byte[ms.Length];
+                ms.Position = 0;
+                ms.Read(arr, 0, (int)ms.Length);
+                ms.Close();
+                return Convert.ToBase64String(arr);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+                return null;
+            }
+        }
+        #endregion
+
+        #region base64编码的字符串转为图片
+        public static Image Base64StringToImage(string strbase64)
+        {
+
+            try
+            {
+                byte[] arr = Convert.FromBase64String(strbase64);
+                MemoryStream ms = new MemoryStream(arr);
+                System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
+
+                //System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
+                //img.Save("ImgName.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
+                //img.Save("ImgName.bmp", ImageFormat.Bmp);
+                //img.Save("ImgName.gif", ImageFormat.Gif);
+                //img.Save(@"images\ImgName.png", ImageFormat.Png);
+                return img;
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+                return null;
+            }
+        }
+        #endregion
+
+    }
+}

+ 95 - 0
CollectInformation/Tools/JWTUtils.cs

@@ -0,0 +1,95 @@
+using JWT;
+using JWT.Algorithms;
+using JWT.Exceptions;
+using JWT.Serializers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace CollectInformation.Tools
+{
+    public class JWTUtils
+    {
+        /// <summary>
+        /// 创建token
+        /// </summary>
+        /// <returns></returns>
+        public static string CreateJwtToken(IDictionary<string, object> payload, string secret, IDictionary<string, object> extraHeaders = null)
+        {
+            IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
+            IJsonSerializer serializer = new JsonNetSerializer();
+            IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+            IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
+            var token = encoder.Encode(payload, secret);
+            return token;
+        }
+
+        /// <summary>
+        /// 校验解析token
+        /// </summary>
+        /// <returns></returns>
+        public static string ValidateJwtToken(string token)
+        {
+            try
+            {
+                IJsonSerializer serializer = new JsonNetSerializer();
+                IDateTimeProvider provider = new UtcDateTimeProvider();
+                IJwtValidator validator = new JwtValidator(serializer, provider);
+                IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+                IJwtAlgorithm alg = new HMACSHA256Algorithm();
+                IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, alg);
+                string json = decoder.Decode(token);
+                //校验通过,返回解密后的字符串
+                return json;
+            }
+            catch (TokenExpiredException)
+            {
+                //表示过期
+                return "expired";
+            }
+            catch (SignatureVerificationException)
+            {
+                //表示验证不通过
+                return "invalid";
+            }
+            catch (Exception)
+            {
+                return "error";
+            }
+        }
+        /// <summary>
+        /// 校验解析token
+        /// </summary>
+        /// <returns></returns>
+        public static string ValidateJwtToken(string token, string secret)
+        {
+            try
+            {
+                IJsonSerializer serializer = new JsonNetSerializer();
+                IDateTimeProvider provider = new UtcDateTimeProvider();
+                IJwtValidator validator = new JwtValidator(serializer, provider);
+                IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
+                IJwtAlgorithm alg = new HMACSHA256Algorithm();
+                IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, alg);
+                var json = decoder.Decode(token, secret, true);
+                //校验通过,返回解密后的字符串
+                return json;
+            }
+            catch (TokenExpiredException)
+            {
+                //表示过期
+                return "expired";
+            }
+            catch (SignatureVerificationException)
+            {
+                //表示验证不通过
+                return "invalid";
+            }
+            catch (Exception)
+            {
+                return "error";
+            }
+        }
+    }
+}

+ 47 - 0
CollectInformation/Tools/constants.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml;
+
+namespace CollectInformation.Tools
+{
+    public static class constants
+    {
+        public static string urlbase = "http://broadcast.kqyjy.com";
+        public static string host = urlbase + "/api/";
+        public static string filehost = urlbase + "/files/{0}/{1}_{2}_{3}/upload";
+        public static string fetch = "usual/{0}/fetch";
+        public static string update = "usual/{0}/update";
+        public static string install = "usual/{0}";
+        public static string tempFiles = "tempFiles\\";
+        public static string userToken = null;
+        public static string loginName = "";
+        public static string loginpwd = "";
+        public static string saveName = "0";
+        public static string savePwd = "0";
+
+        public static void init(string path)
+        {
+            try
+            {
+                XmlDocument xdoc = new XmlDocument();
+                xdoc.Load(path + "\\config.xml");
+                XmlNode configNode = xdoc.FirstChild;
+                constants.urlbase = configNode.SelectSingleNode("urlbase").InnerText;
+                constants.host = constants.urlbase + "/api/";
+                constants.filehost = constants.urlbase + "/files/{0}/{1}_{2}_{3}/upload";
+                constants.loginName = configNode.SelectSingleNode("loginName").InnerText;
+                constants.loginpwd = configNode.SelectSingleNode("password").InnerText;
+                constants.saveName = configNode.SelectSingleNode("saveName").InnerText;
+                constants.savePwd = configNode.SelectSingleNode("savePwd").InnerText;
+
+            }
+            catch (Exception e)
+            {
+
+            }
+
+        }
+    }
+}

+ 11 - 0
CollectInformation/app.config

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 7 - 0
CollectInformation/config.xml

@@ -0,0 +1,7 @@
+<config>
+  <urlbase>http://broadcast.kqyjy.com</urlbase>
+  <loginName>11111111111</loginName>
+  <saveName>1</saveName>
+  <password>1qaz2wsx</password>
+  <savePwd>1</savePwd>
+</config>

+ 166 - 0
CollectInformation/loginForm.Designer.cs

@@ -0,0 +1,166 @@
+
+namespace CollectInformation
+{
+    partial class LoginForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.txtName = new System.Windows.Forms.TextBox();
+            this.txtPwd = new System.Windows.Forms.TextBox();
+            this.btnOK = new System.Windows.Forms.Button();
+            this.btnClose = new System.Windows.Forms.Button();
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
+            this.checkBox2 = new System.Windows.Forms.CheckBox();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(24, 21);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(417, 27);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "长春市保安服务监管系统采集终端";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(54, 76);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(65, 12);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "登录账号:";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(56, 121);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(65, 12);
+            this.label3.TabIndex = 2;
+            this.label3.Text = "登录密码:";
+            // 
+            // txtName
+            // 
+            this.txtName.Location = new System.Drawing.Point(125, 73);
+            this.txtName.Name = "txtName";
+            this.txtName.Size = new System.Drawing.Size(274, 21);
+            this.txtName.TabIndex = 3;
+            // 
+            // txtPwd
+            // 
+            this.txtPwd.Location = new System.Drawing.Point(125, 118);
+            this.txtPwd.Name = "txtPwd";
+            this.txtPwd.PasswordChar = '*';
+            this.txtPwd.Size = new System.Drawing.Size(274, 21);
+            this.txtPwd.TabIndex = 4;
+            // 
+            // btnOK
+            // 
+            this.btnOK.Location = new System.Drawing.Point(125, 185);
+            this.btnOK.Name = "btnOK";
+            this.btnOK.Size = new System.Drawing.Size(75, 23);
+            this.btnOK.TabIndex = 5;
+            this.btnOK.Text = "登录";
+            this.btnOK.UseVisualStyleBackColor = true;
+            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
+            // 
+            // btnClose
+            // 
+            this.btnClose.Location = new System.Drawing.Point(324, 185);
+            this.btnClose.Name = "btnClose";
+            this.btnClose.Size = new System.Drawing.Size(75, 23);
+            this.btnClose.TabIndex = 6;
+            this.btnClose.Text = "关闭";
+            this.btnClose.UseVisualStyleBackColor = true;
+            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
+            // 
+            // checkBox1
+            // 
+            this.checkBox1.AutoSize = true;
+            this.checkBox1.Location = new System.Drawing.Point(125, 155);
+            this.checkBox1.Name = "checkBox1";
+            this.checkBox1.Size = new System.Drawing.Size(84, 16);
+            this.checkBox1.TabIndex = 7;
+            this.checkBox1.Text = "保存用户名";
+            this.checkBox1.UseVisualStyleBackColor = true;
+            // 
+            // checkBox2
+            // 
+            this.checkBox2.AutoSize = true;
+            this.checkBox2.Location = new System.Drawing.Point(215, 155);
+            this.checkBox2.Name = "checkBox2";
+            this.checkBox2.Size = new System.Drawing.Size(72, 16);
+            this.checkBox2.TabIndex = 8;
+            this.checkBox2.Text = "保存密码";
+            this.checkBox2.UseVisualStyleBackColor = true;
+            this.checkBox2.Click += new System.EventHandler(this.checkBox2_Click);
+            // 
+            // LoginForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(466, 224);
+            this.Controls.Add(this.checkBox2);
+            this.Controls.Add(this.checkBox1);
+            this.Controls.Add(this.btnClose);
+            this.Controls.Add(this.btnOK);
+            this.Controls.Add(this.txtPwd);
+            this.Controls.Add(this.txtName);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+            this.MaximizeBox = false;
+            this.MinimizeBox = false;
+            this.Name = "LoginForm";
+            this.ShowIcon = false;
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "长春市保安服务监管系统采集终端-登录";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LoginForm_FormClosing);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox txtName;
+        private System.Windows.Forms.TextBox txtPwd;
+        private System.Windows.Forms.Button btnOK;
+        private System.Windows.Forms.Button btnClose;
+        private System.Windows.Forms.CheckBox checkBox1;
+        private System.Windows.Forms.CheckBox checkBox2;
+    }
+}

+ 138 - 0
CollectInformation/loginForm.cs

@@ -0,0 +1,138 @@
+using CollectInformation.Tools;
+using Newtonsoft.Json;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace CollectInformation
+{
+    public partial class LoginForm : Form
+    {
+        public LoginForm()
+        {
+            InitializeComponent();
+            if(constants.saveName == "1")
+            {
+                this.checkBox1.Checked = true;
+            }
+            if(constants.savePwd == "1")
+            {
+                this.checkBox2.Checked = true;
+            }
+            this.txtName.Text = constants.loginName;
+            this.txtPwd.Text = constants.loginpwd;
+        }
+
+        private void btnOK_Click(object sender, EventArgs e)
+        {
+            string url = constants.host + "login/system_account";
+            Dictionary<string,string> loginData = new Dictionary<string, string>();
+            loginData.Add("phone", this.txtName.Text);
+            loginData.Add("password", this.txtPwd.Text);
+            string data = JsonConvert.SerializeObject(loginData);
+            // 调试输出
+            Console.WriteLine(data);
+            Dictionary<string, string> res = HttpUitls.Post(url, data, "");
+            if(res["code"] == "0")
+            {
+                MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }else
+            {
+                Dictionary<string, string> retData = JsonConvert.DeserializeObject<Dictionary<string, string>>(res["data"]);
+                if (retData["errcode"] == "0")
+                {
+                    // 处理登录数据,获取登录用户信息,打开主界面,并传入登录用户信息
+                    string userToken = retData["data"];
+                    constants.userToken = userToken;
+                    string jsonStr = JWTUtils.ValidateJwtToken(userToken);
+                    Dictionary<string, string> userBaseInfo = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonStr);
+                    url = constants.host + string.Format(constants.fetch, userBaseInfo["table"]) + "?id=" + userBaseInfo["id"];
+
+                    res = HttpUitls.Get(url, constants.userToken);
+                    if (res["code"] == "0")
+                    {
+                        MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                    }
+                    else
+                    {
+                        Dictionary<string, Object> userInfo = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
+                        if (userInfo["errcode"].ToString() == "0")
+                        {
+                            string userStr = JsonConvert.SerializeObject(userInfo["data"]);
+                            userBaseInfo = JsonConvert.DeserializeObject<Dictionary<string, string>>(userStr);
+                            MainForm mainForm1 = new MainForm(userBaseInfo);
+                            mainForm1.Show();
+
+                            XmlDocument xdoc = new XmlDocument();
+                            xdoc.Load(Application.StartupPath + "\\config.xml");
+                            if (this.checkBox1.Checked)
+                            {
+                                xdoc.FirstChild.SelectSingleNode("loginName").InnerText = this.txtName.Text;
+                                xdoc.FirstChild.SelectSingleNode("saveName").InnerText = "1";
+                            }
+                            else
+                            {
+                                xdoc.FirstChild.SelectSingleNode("loginName").InnerText = "";
+                                xdoc.FirstChild.SelectSingleNode("saveName").InnerText = "0";
+                            }
+                            if (this.checkBox2.Checked)
+                            {
+                                xdoc.FirstChild.SelectSingleNode("password").InnerText = this.txtPwd.Text;
+                                xdoc.FirstChild.SelectSingleNode("savePwd").InnerText = "1";
+                            }
+                            else
+                            {
+                                xdoc.FirstChild.SelectSingleNode("password").InnerText = "";
+                                xdoc.FirstChild.SelectSingleNode("savePwd").InnerText = "0";
+                            }
+                            xdoc.Save(Application.StartupPath + "\\config.xml");
+
+                            this.Hide();
+                        }
+                        else
+                        {
+                            MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"]);
+                        }
+                    }
+                }else
+                {
+                    MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"]);
+                }
+            }
+        }
+
+        private void btnClose_Click(object sender, EventArgs e)
+        {
+            this.Close();
+        }
+
+        private void LoginForm_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (e.CloseReason == CloseReason.UserClosing)
+            {
+                if (MessageBox.Show("您确定要退出采集终端么?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
+                {
+                    e.Cancel = true;
+                }
+            }
+        }
+
+        private void checkBox2_Click(object sender, EventArgs e)
+        {
+            if (this.checkBox2.Checked)
+            {
+                if (MessageBox.Show("密码会以明文保存在配置文件中,可能导致密码丢失,您确定要保存密码么?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+                {
+                    this.checkBox2.Checked = false;
+                }
+            }
+        }
+    }
+}

+ 120 - 0
CollectInformation/loginForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 5 - 0
CollectInformation/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="JWT" version="8.4.0" targetFramework="net40" />
+  <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net40" />
+</packages>

二进制
packages/JWT.8.4.0/.signature.p7s


二进制
packages/JWT.8.4.0/JWT.8.4.0.nupkg


二进制
packages/JWT.8.4.0/lib/net35/JWT.dll


二进制
packages/JWT.8.4.0/lib/net35/JWT.pdb


文件差异内容过多而无法显示
+ 1378 - 0
packages/JWT.8.4.0/lib/net35/JWT.xml


二进制
packages/JWT.8.4.0/lib/net40/JWT.dll


二进制
packages/JWT.8.4.0/lib/net40/JWT.pdb


文件差异内容过多而无法显示
+ 1378 - 0
packages/JWT.8.4.0/lib/net40/JWT.xml


二进制
packages/JWT.8.4.0/lib/net46/JWT.dll


二进制
packages/JWT.8.4.0/lib/net46/JWT.pdb


文件差异内容过多而无法显示
+ 1378 - 0
packages/JWT.8.4.0/lib/net46/JWT.xml


二进制
packages/JWT.8.4.0/lib/net5.0/JWT.dll


二进制
packages/JWT.8.4.0/lib/net5.0/JWT.pdb


文件差异内容过多而无法显示
+ 1539 - 0
packages/JWT.8.4.0/lib/net5.0/JWT.xml


二进制
packages/JWT.8.4.0/lib/netstandard1.3/JWT.dll


二进制
packages/JWT.8.4.0/lib/netstandard1.3/JWT.pdb


文件差异内容过多而无法显示
+ 1378 - 0
packages/JWT.8.4.0/lib/netstandard1.3/JWT.xml


二进制
packages/JWT.8.4.0/lib/netstandard2.0/JWT.dll


二进制
packages/JWT.8.4.0/lib/netstandard2.0/JWT.pdb


文件差异内容过多而无法显示
+ 1539 - 0
packages/JWT.8.4.0/lib/netstandard2.0/JWT.xml


二进制
packages/Newtonsoft.Json.13.0.1/.signature.p7s


+ 20 - 0
packages/Newtonsoft.Json.13.0.1/LICENSE.md

@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2007 James Newton-King
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

二进制
packages/Newtonsoft.Json.13.0.1/Newtonsoft.Json.13.0.1.nupkg


二进制
packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 10335 - 0
packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 9483 - 0
packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 9683 - 0
packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 11305 - 0
packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 10993 - 0
packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 11115 - 0
packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll


文件差异内容过多而无法显示
+ 11280 - 0
packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.xml


二进制
packages/Newtonsoft.Json.13.0.1/packageIcon.png