MainForm.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. using CollectInformation.HCUSBSDK;
  2. using CollectInformation.Tools;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Drawing;
  8. using System.Runtime.InteropServices;
  9. using System.Windows.Forms;
  10. using System.Xml;
  11. namespace CollectInformation
  12. {
  13. public partial class MainForm : Form
  14. {
  15. Dictionary<string, string> loginUser = null;
  16. //Dictionary<string, string> user = null;
  17. Dictionary<string, string> securityInfo = null;
  18. HCUSBUtils hcUSBUtils = null;
  19. bool isInit = false;
  20. string sdkLevel = "";
  21. string devName = "";
  22. bool isLoginD = false;
  23. public MainForm()
  24. {
  25. InitializeComponent();
  26. }
  27. public MainForm(Dictionary<string, string> loginUser)
  28. {
  29. InitializeComponent();
  30. this.loginUser = loginUser;
  31. if (loginUser != null)
  32. {
  33. this.Text = loginUser["name"] + "欢迎您使用" + this.Text;
  34. }
  35. isInit = false;
  36. this.btnLinkEquipment.Enabled = true;
  37. this.btnReadID.Enabled = false;
  38. initD();
  39. }
  40. private void initD()
  41. {
  42. this.hcUSBUtils = new HCUSBUtils();
  43. this.sdkLevel = "SDK lv " + hcUSBUtils.initSDK();
  44. this.isInit = this.hcUSBUtils.TraverseDevice();
  45. if (this.isInit)
  46. {
  47. this.devName = System.Text.Encoding.UTF8.GetString(this.hcUSBUtils.m_aHidDevInfo[0].szDeviceName).TrimEnd('\0');
  48. this.labLinkStatus.Text = "" + this.devName + " | " + this.sdkLevel;
  49. }
  50. else
  51. {
  52. this.isInit = false;
  53. MessageBox.Show("当前设备链接失败,请尝试重新链接,或联系管理员。", "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  54. }
  55. }
  56. private void MainForm_Load(object sender, EventArgs e)
  57. {
  58. if (securityInfo == null)
  59. {
  60. clear();
  61. }
  62. }
  63. private void btnReplaceUser_Click(object sender, EventArgs e)
  64. {
  65. if (MessageBox.Show("您将要使用当前身份证信息覆盖报名人员信息,此操作无法撤销,请确定是否进行操作!", "系统警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
  66. {
  67. this.labName2.Text = this.labName.Text;
  68. this.labSex2.Text = this.labSex.Text;
  69. this.labNation2.Text = this.labNation.Text;
  70. this.labBirthday2.Text = this.labBirthday.Text.Replace("年", "-").Replace("月", "-").Replace("日", "");
  71. this.securityInfo["name"] = this.labName.Text;
  72. this.securityInfo["gender"] = this.labSex.Text;
  73. this.securityInfo["nation"] = this.labNation.Text;
  74. this.securityInfo["birth"] = this.labBirthday.Text.Replace("年", "-").Replace("月", "-").Replace("日", "");
  75. }
  76. }
  77. private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
  78. {
  79. if (e.CloseReason == CloseReason.UserClosing)
  80. {
  81. if (MessageBox.Show("您确定要退出采集终端么?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
  82. {
  83. e.Cancel = true;
  84. }
  85. else
  86. {
  87. Application.Exit();
  88. }
  89. }
  90. }
  91. private void btnLinkEquipment_Click(object sender, EventArgs e)
  92. {
  93. if (!this.isInit)
  94. {
  95. initD();
  96. }
  97. if (this.isInit)
  98. {
  99. this.isLoginD = hcUSBUtils.LoginDevice();
  100. if (this.isLoginD)
  101. {
  102. MessageBox.Show("设备链接成功。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  103. this.btnReadID.Enabled = true;
  104. this.labLinkStatus.Text = "已连接 " + this.devName + " | " + this.sdkLevel;
  105. }
  106. else
  107. {
  108. MessageBox.Show("当前设备链接失败,请尝试重新链接,或联系管理员。", "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  109. }
  110. }
  111. }
  112. private void btnReadID_Click(object sender, EventArgs e)
  113. {
  114. // 获取身份证信息
  115. string inputStr = "{\"IdentityInfoCond\":{}}";
  116. string outputStr = this.hcUSBUtils.CollectionNoImage(1, inputStr).TrimEnd('\0');
  117. try
  118. {
  119. Dictionary<string, object> d1 = JsonConvert.DeserializeObject<Dictionary<string, object>>(outputStr);
  120. if (d1.ContainsKey("statusString"))
  121. {
  122. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  123. return;
  124. }
  125. }
  126. catch (Exception)
  127. {
  128. XmlDocument xdoc = new XmlDocument();
  129. xdoc.LoadXml(outputStr);
  130. XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
  131. nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
  132. XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
  133. if (statusNode != null)
  134. {
  135. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  136. return;
  137. }
  138. else
  139. {
  140. outputStr = JsonConvert.SerializeXmlNode(xdoc.FirstChild);
  141. }
  142. }
  143. Dictionary<String, object> os = JsonConvert.DeserializeObject<Dictionary<string, object>>(outputStr);
  144. Dictionary<string, object> IdentityInfoD = JsonConvert.DeserializeObject<Dictionary<string, object>>(os["IdentityInfo"].ToString());
  145. this.labName.Text = IdentityInfoD["chnName"].ToString();
  146. this.labSex.Text = IdentityInfoD["sex"].ToString() == "male" ? "男" : IdentityInfoD["sex"].ToString() == "female" ? "女" : "未知";
  147. string nationIndex = IdentityInfoD["nation"].ToString().PadLeft(2, '0');
  148. this.labNation.Text = Nationality.GetNationality(ref nationIndex);
  149. this.labBirthday.Text = this.getDate(IdentityInfoD["birth"].ToString());
  150. this.labAddress.Text = IdentityInfoD["addr"].ToString();
  151. this.labID.Text = IdentityInfoD["IDCardNo"].ToString(); // "220182199603257024";
  152. this.labSigning.Text = IdentityInfoD["issuingAuthority"].ToString();
  153. this.labValidity.Text = this.getDate(IdentityInfoD["startDate"].ToString()) + " 至 " + this.getDate(IdentityInfoD["endDate"].ToString());
  154. // 使用身份证号获取待采集人员
  155. string url = constants.host + string.Format(constants.fetch, "security_guard_base") + "?status=1&card=" + labID.Text;
  156. Dictionary<string, string> res = HttpUitls.Get(url, constants.userToken);
  157. if (res["code"] == "0")
  158. {
  159. MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  160. }
  161. else
  162. {
  163. Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  164. if (retData["errcode"].ToString() == "0")
  165. {
  166. Dictionary<string, Object> ret = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  167. if (ret["data"] != null)
  168. {
  169. string securityStr = JsonConvert.SerializeObject(ret["data"]);
  170. this.securityInfo = JsonConvert.DeserializeObject<Dictionary<string, string>>(securityStr);
  171. this.labName2.Text = securityInfo["name"];
  172. this.labBeforeName.Text = securityInfo["beforeName"];
  173. this.labSex2.Text = securityInfo["gender"];
  174. this.labNation2.Text = securityInfo["nation"];
  175. this.labBirthday2.Text = securityInfo["birth"];
  176. this.labLevel.Text = securityInfo["grade"];
  177. this.labCompany.Text = securityInfo["sign_company"];
  178. this.labID2.Text = securityInfo["card"];
  179. this.btnOK.Enabled = true;
  180. if (securityInfo["collect_photo"].ToString() == "已采集")
  181. {
  182. this.btnGetImage.Enabled = false;
  183. url = constants.host + string.Format(constants.fetch, "security_guard_collect") + "?type=人像&security_guard_id=" + securityInfo["id"].ToString();
  184. Dictionary<string, string> resCollect = HttpUitls.Get(url, constants.userToken);
  185. if (res["code"] == "0")
  186. {
  187. this.btnGetImage.Enabled = true;
  188. }
  189. else
  190. {
  191. Dictionary<string, Object> collect = JsonConvert.DeserializeObject<Dictionary<string, Object>>(resCollect["data"]);
  192. string collectStr = JsonConvert.SerializeObject(collect["data"]);
  193. Dictionary<string, string> collect1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(collectStr);
  194. this.picUser.ImageLocation = constants.urlbase + collect1["data"].ToString();
  195. }
  196. }
  197. else
  198. {
  199. this.btnGetImage.Enabled = true;
  200. }
  201. this.btnGetFingerprint.Enabled = true;
  202. this.btnReplaceUser.Enabled = true;
  203. }
  204. else
  205. {
  206. MessageBox.Show("没有对应的待采集人员信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  207. }
  208. }
  209. else
  210. {
  211. MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  212. }
  213. }
  214. }
  215. private void btnClear_Click(object sender, EventArgs e)
  216. {
  217. clear();
  218. }
  219. private void clear()
  220. {
  221. // 清空身份证读取信息
  222. this.labName.Text = "";
  223. this.labSex.Text = "";
  224. this.labNation.Text = "";
  225. this.labBirthday.Text = "";
  226. this.labAddress.Text = "";
  227. this.labID.Text = "";
  228. this.labSigning.Text = "";
  229. this.labValidity.Text = "";
  230. // 清空采集人员信息
  231. this.securityInfo = null;
  232. this.labName2.Text = "";
  233. this.labBeforeName.Text = "";
  234. this.labSex2.Text = "";
  235. this.labNation2.Text = "";
  236. this.labBirthday2.Text = "";
  237. this.labLevel.Text = "";
  238. this.labUserFingerprint.Text = "";
  239. this.labCompany.Text = "";
  240. this.labID2.Text = "";
  241. this.picUser.Image = null;
  242. // 控制管理按钮
  243. this.btnReplaceUser.Enabled = false;
  244. this.btnOK.Enabled = false;
  245. this.btnGetFingerprint.Enabled = false;
  246. this.btnGetImage.Enabled = false;
  247. }
  248. private void btnOK_Click(object sender, EventArgs e)
  249. {
  250. if (this.securityInfo != null)
  251. {
  252. // 上传指纹采集信息,并修改保安员状态
  253. if (this.labUserFingerprint.Text == "" || this.labUserFingerprint.Text == "未获取")
  254. {
  255. MessageBox.Show("请采集指纹信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  256. }
  257. else if(this.securityInfo["collect_photo"] != "已采集" && this.picUser.Image == null)
  258. {
  259. MessageBox.Show("请采集人像信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  260. }
  261. else
  262. {
  263. string url = constants.host + string.Format(constants.fetch, "security_guard_others") + "?security_guard_id=" + this.securityInfo["id"];
  264. Dictionary<string, string> res = HttpUitls.Get(url, constants.userToken);
  265. if (res["code"] == "0")
  266. {
  267. MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  268. }
  269. else
  270. {
  271. Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  272. if (retData["errcode"].ToString() == "0")
  273. {
  274. Dictionary<string, Object> ret = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  275. if (ret["data"] != null)
  276. {
  277. string otherStr = JsonConvert.SerializeObject(ret["data"]);
  278. Dictionary<string, string> securityOther = JsonConvert.DeserializeObject<Dictionary<string, string>>(otherStr);
  279. //securityOther["fingerprint_num"] = this.labUserFingerprint.Text;
  280. securityOther["fingerprint_date"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  281. securityOther["fingerprint_personal"] = this.loginUser["name"];
  282. securityOther["fingerprint_office"] = this.loginUser["belong_company"];
  283. this.editSecurityOtherInfo(securityOther);
  284. }
  285. }
  286. else
  287. {
  288. MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  289. }
  290. }
  291. Dictionary<string, string> collect = new Dictionary<string, string>();
  292. collect["name"] = this.securityInfo["name"];
  293. collect["security_guard_id"] = this.securityInfo["id"];
  294. collect["type"] = "指纹";
  295. collect["data"] = this.labUserFingerprint.Text;
  296. collect["collect_personal"] = this.loginUser["name"];
  297. collect["collect_police"] = this.loginUser["belong_company"];
  298. if (this.createSecurityCollect(collect))
  299. {
  300. if (this.securityInfo["collect_photo"] == "已采集")
  301. {
  302. this.securityInfo["status"] = "2";
  303. this.securityInfo["collect_fingerprint"] = "已采集";
  304. if (this.editSecurityBassInfo(this.securityInfo))
  305. {
  306. MessageBox.Show("信息上传成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  307. clear();
  308. }
  309. }
  310. else
  311. {
  312. this.securityInfo["collect_fingerprint"] = "已采集";
  313. this.editSecurityBassInfo(this.securityInfo);
  314. // 上传头像信息,并修改保安员状态
  315. string upLoadUrl = string.Format(constants.filehost, "baoan", "collect", DateTime.Now.ToString("yyyyMMdd"), this.securityInfo["card"]);
  316. Dictionary<string, string> upLoadRes = HttpUitls.UploadImage(upLoadUrl, this.picUser.ImageLocation, constants.userToken);
  317. if (upLoadRes["code"] != "0")
  318. {
  319. Dictionary<string, Object> tempData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(upLoadRes["data"]);
  320. if (tempData["errcode"].ToString() == "0")
  321. {
  322. //Dictionary<string, Object> upLoadResData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(tempData["data"].ToString());
  323. collect = new Dictionary<string, string>();
  324. collect["name"] = this.securityInfo["name"];
  325. collect["security_guard_id"] = this.securityInfo["id"];
  326. collect["type"] = "人像";
  327. collect["data"] = tempData["uri"].ToString();
  328. collect["collect_personal"] = this.loginUser["name"];
  329. collect["collect_police"] = this.loginUser["belong_company"];
  330. if (this.createSecurityCollect(collect))
  331. {
  332. // 全部处理成功后,修改保安员状态
  333. this.securityInfo["collect_photo"] = "已采集";
  334. this.securityInfo["status"] = "2";
  335. if (this.editSecurityBassInfo(this.securityInfo))
  336. {
  337. MessageBox.Show("信息上传成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  338. clear();
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. else
  346. {
  347. MessageBox.Show("指纹信息保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  348. }
  349. }
  350. }
  351. else
  352. {
  353. MessageBox.Show("没有需要提交写信息,请重新操作!", "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  354. this.btnOK.Enabled = false;
  355. }
  356. }
  357. bool editSecurityBassInfo(Dictionary<string, string> security)
  358. {
  359. bool rest = false;
  360. // 创建修改链接
  361. string url = constants.host + string.Format(constants.update, "security_guard_base") + "?id=" + security["id"];
  362. string data = JsonConvert.SerializeObject(security);
  363. Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
  364. if (res["code"] == "0")
  365. {
  366. MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  367. }
  368. else
  369. {
  370. Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  371. if (retData["errcode"].ToString() == "0")
  372. {
  373. rest = true;
  374. }
  375. else
  376. {
  377. MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  378. }
  379. }
  380. return rest;
  381. }
  382. bool editSecurityOtherInfo(Dictionary<string, string> securityOther)
  383. {
  384. bool rest = false;
  385. // 创建修改链接
  386. string url = constants.host + string.Format(constants.update, "security_guard_others") + "?id=" + securityOther["id"];
  387. string data = JsonConvert.SerializeObject(securityOther);
  388. Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
  389. if (res["code"] == "0")
  390. {
  391. MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  392. }
  393. else
  394. {
  395. Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  396. if (retData["errcode"].ToString() == "0")
  397. {
  398. rest = true;
  399. }
  400. else
  401. {
  402. MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  403. }
  404. }
  405. return rest;
  406. }
  407. bool createSecurityCollect(Dictionary<string, string> collect)
  408. {
  409. bool rest = false;
  410. // 创建修改链接
  411. string url = constants.host + string.Format(constants.install, "security_guard_collect");
  412. string data = JsonConvert.SerializeObject(collect);
  413. Dictionary<string, string> res = HttpUitls.Post(url, data, "", constants.userToken);
  414. if (res["code"] == "0")
  415. {
  416. MessageBox.Show("系统出现异常,请联系管理员进行处理!\r\n错误信息:" + res["message"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  417. }
  418. else
  419. {
  420. Dictionary<string, Object> retData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res["data"]);
  421. if (retData["errcode"].ToString() == "0")
  422. {
  423. rest = true;
  424. }
  425. else
  426. {
  427. MessageBox.Show("服务端返回异常信息,请联系管理员!\r\n异常信息:" + retData["errmsg"], "系统异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  428. }
  429. }
  430. return rest;
  431. }
  432. private void btnGetImage_Click(object sender, EventArgs e)
  433. {
  434. string filePath = Application.StartupPath + "\\" + constants.tempFiles;
  435. string fileName = "tempImage.png";
  436. string outputStr = this.hcUSBUtils.CaptureFace(filePath, fileName);
  437. if (outputStr != null)
  438. {
  439. try
  440. {
  441. Dictionary<string, string> d1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(outputStr);
  442. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  443. return;
  444. }
  445. catch (Exception)
  446. {
  447. XmlDocument xdoc = new XmlDocument();
  448. xdoc.LoadXml(outputStr);
  449. XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
  450. nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
  451. XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
  452. if (statusNode != null)
  453. {
  454. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  455. }
  456. XmlNode captureProgressNode = xdoc.SelectSingleNode("/ns:CaptureFaceData/ns:captureProgress", nsMgr);
  457. if (captureProgressNode != null && captureProgressNode.InnerText == "100")
  458. {
  459. // 使用第一张图片
  460. string fileFullPath = filePath + "\\0_" + fileName;
  461. this.picUser.ImageLocation = fileFullPath;
  462. }
  463. else
  464. {
  465. MessageBox.Show("人像采集失败,请重新尝试。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  466. }
  467. }
  468. }
  469. }
  470. private void btnGetFingerprint_Click(object sender, EventArgs e)
  471. {
  472. string inputStr = "<CaptureFingerPrintCond xmlns=\"http://www.isapi.org/ver20/XMLSchema\" version=\"2.0\">" +
  473. "<fingerNo>1</fingerNo>" +
  474. "</CaptureFingerPrintCond>";
  475. string outputStr = this.hcUSBUtils.CollectionNoImage(2, inputStr).TrimEnd('\0');
  476. if (outputStr != null)
  477. {
  478. try
  479. {
  480. Dictionary<string, string> d1 = JsonConvert.DeserializeObject<Dictionary<string, string>>(outputStr);
  481. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + d1["statusString"], "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  482. return;
  483. }
  484. catch (Exception)
  485. {
  486. XmlDocument xdoc = new XmlDocument();
  487. xdoc.LoadXml(outputStr);
  488. XmlNamespaceManager nsMgr = new XmlNamespaceManager(xdoc.NameTable);
  489. nsMgr.AddNamespace("ns", "http://www.isapi.org/ver20/XMLSchema");
  490. //outputStr = JsonConvert.SerializeXmlNode(xdoc.FirstChild);
  491. XmlNode statusNode = xdoc.SelectSingleNode("/ns:ResponseStatus/ns:statusString", nsMgr);
  492. if (statusNode != null)
  493. {
  494. MessageBox.Show("设备未返回正确信息请重新尝试!错误信息:" + statusNode.InnerText, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  495. }
  496. XmlNode fingerDataNode = xdoc.SelectSingleNode("/ns:CaptureFingerPrint/ns:fingerData", nsMgr);
  497. if (fingerDataNode != null)
  498. {
  499. string finger = fingerDataNode.InnerText;
  500. this.labUserFingerprint.Text = finger;
  501. }
  502. else
  503. {
  504. MessageBox.Show("指纹采集失败,请重新尝试。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  505. }
  506. }
  507. }
  508. }
  509. string getDate(string str)
  510. {
  511. string yyyy = str.Substring(0,4);
  512. string mm = str.Substring(4, 2);
  513. string dd = str.Substring(6, 2);
  514. return yyyy + "年" + mm + "月" + dd + "日";
  515. }
  516. }
  517. }