MainForm.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Reflection;
  11. using System.Net;
  12. using System.Management;
  13. using System.Xml;
  14. using Newtonsoft.Json;
  15. using Newtonsoft.Json.Linq;
  16. using MedicareComLib;
  17. namespace BJShouXinYB_Demo
  18. {
  19. public partial class MainForm : Form
  20. {
  21. MedOrdersShareClass MOS = new MedOrdersShareClass();
  22. AnalysisXML AnXML = new AnalysisXML();
  23. string LocalMac = "38-F3-AB-9F-5D-A4";
  24. string LocalIP = "10.0.12.199";
  25. System.Type ComType;
  26. object ComInstance;
  27. public MainForm()
  28. {
  29. InitializeComponent();
  30. }
  31. private void MainForm_Load(object sender, EventArgs e)
  32. {
  33. rbg_Type.SelectedIndex = 0;
  34. }
  35. public string GetIP()
  36. {
  37. IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
  38. //string myip = IpEntry.AddressList[0].ToString();//IP6
  39. string myip = IpEntry.AddressList[1].ToString();//IP4
  40. return myip;
  41. }
  42. public string GetMAC()
  43. {
  44. try
  45. {
  46. //获取网卡硬件地址
  47. string mac = "";
  48. ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
  49. ManagementObjectCollection moc = mc.GetInstances();
  50. foreach (ManagementObject mo in moc)
  51. {
  52. if ((bool)mo["IPEnabled"] == true)
  53. {
  54. mac = mo["MacAddress"].ToString();
  55. mo.Dispose();//释放资源
  56. break;
  57. }
  58. }
  59. moc = null;
  60. mc = null;
  61. return mac;
  62. }
  63. catch
  64. {
  65. return "unknow";
  66. }
  67. }
  68. /// <summary>
  69. /// XML转换JSON对象
  70. /// </summary>
  71. /// <param name="sXML"></param>
  72. /// <param name="outParam"></param>
  73. /// <returns></returns>
  74. public JObject ConvertXMLToObject(string sXML)
  75. {
  76. XmlDocument xmlDoc = new XmlDocument();
  77. xmlDoc.LoadXml(sXML);
  78. string jsonStr = JsonConvert.SerializeXmlNode(xmlDoc);
  79. jsonStr = jsonStr.Replace("@", "").ToString();
  80. //MessageBox.Show(jsonStr);
  81. return JObject.Parse(jsonStr);
  82. }
  83. public int GetReadCardObj(out System.Type OutComType, out object OutComInstance)
  84. {
  85. Object rtnObj = "";
  86. string progID = "MedicareCom.Outpatient";
  87. System.Type ComType;
  88. object ComInstance;
  89. ComType = Type.GetTypeFromProgID(progID);
  90. // 创建Com的实例
  91. if (ComType != null)
  92. {
  93. //创建实例
  94. ComInstance = Activator.CreateInstance(ComType);
  95. OutComType = ComType;
  96. OutComInstance = ComInstance;
  97. return 0;
  98. }
  99. else
  100. {
  101. OutComType = null;
  102. OutComInstance = "";
  103. return -1;
  104. }
  105. }
  106. public void OpenOrClose(string FunName, System.Type ComType, object ComInstance, out string output)
  107. {
  108. try
  109. {
  110. //Type ComType = System.Type.GetTypeFromProgID("MedicareCom.Outpatient");
  111. if (ComType != null)
  112. {
  113. //创建实例,不能再次创建,否则会提示没有初始化
  114. //object ComInstance = System.Activator.CreateInstance(ComType);
  115. if (ComInstance == null)
  116. {
  117. output = "实例不存在!";
  118. return;
  119. }
  120. //GlobalVariables.writeLog("入参infno:" + infno);
  121. //GlobalVariables.writeLog("入参input:" + input);
  122. //设置需要设置的参数值
  123. object[] ParamArray = new object[1];
  124. ParamArray[0] = "";
  125. //ParamArray[1] = input;
  126. ParameterModifier[] ParamMods = new ParameterModifier[1];
  127. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  128. ParamMods[0][0] = true;
  129. //object o = ShouXinComType.GetMethod(FunName, BindingFlags.Default | BindingFlags.InvokeMethod);
  130. ComType.InvokeMember(FunName, // 接口函数名
  131. BindingFlags.Default | BindingFlags.InvokeMethod,
  132. null,
  133. ComInstance, // 调用的COM组件
  134. ParamArray, // 参数数组
  135. ParamMods, // 指定返回参数的ParameterModifier数组
  136. null,
  137. null);
  138. output = ParamArray[0].ToString();
  139. MessageBox.Show("Com输出:" + output);
  140. }
  141. else
  142. {
  143. output = "北京首信医保COM加载失败!";
  144. //MessageBox.Show("COM加载失败!");
  145. }
  146. }
  147. catch (Exception ex)
  148. {
  149. output = ex.Message;
  150. MessageBox.Show("COM加载异常!" + output);
  151. }
  152. }
  153. public void Myobject(string FunName, string input, out string output)
  154. {
  155. output = "";
  156. try
  157. {
  158. Type ShouXinComType = System.Type.GetTypeFromProgID("MedicareCom.Outpatient");
  159. if (ShouXinComType != null)
  160. {
  161. //创建实例,不能再次创建,否则会提示没有初始化
  162. object ShouXinComInstance = System.Activator.CreateInstance(ShouXinComType);
  163. if (ShouXinComInstance != null)
  164. {
  165. MessageBox.Show(("函数FunName:" + FunName + "\n"
  166. + "入参:" + input));
  167. }
  168. else
  169. {
  170. output = "实例不存在!";
  171. return;
  172. }
  173. //GlobalVariables.writeLog("入参infno:" + infno);
  174. //GlobalVariables.writeLog("入参input:" + input);
  175. //设置需要设置的参数值
  176. object[] ParamArray = new object[2];
  177. ParamArray[0] = input;
  178. ParamArray[1] = input;
  179. ParameterModifier[] ParamMods = new ParameterModifier[1];
  180. ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
  181. ParamMods[0][0] = true;
  182. ParamMods[0][1] = true;
  183. ShouXinComType.InvokeMember(FunName, // 接口函数名
  184. BindingFlags.Default | BindingFlags.InvokeMethod,
  185. null,
  186. ShouXinComInstance, // 调用的COM组件
  187. ParamArray, // 参数数组
  188. ParamMods, // 指定返回参数的ParameterModifier数组
  189. null,
  190. null);
  191. output = ParamArray[1].ToString();
  192. }
  193. else
  194. {
  195. output = "北京首信医保COM加载失败!";
  196. //MessageBox.Show("COM加载失败!");
  197. }
  198. }
  199. catch (Exception ex)
  200. {
  201. output = ex.Message;
  202. MessageBox.Show("COM加载异常!" + output);
  203. }
  204. }
  205. public string GetinPar(string sInpar,int i)
  206. {
  207. string Str = "";
  208. if (i == 0)
  209. {
  210. Str = @"<?xml version=""1.0"" encoding=""UTF-16"" standalone=""yes"" ?><root version=""1.00.1107"" sender=""capinfo"">";
  211. return Str + "<input>" + sInpar + "</input></root>";
  212. }
  213. else if (i == 1)
  214. {
  215. Str = @"<?xml version=""1.0"" encoding=""UTF-16"" standalone=""yes"" ?>";
  216. return Str + "<data>" + sInpar + "</data>";
  217. }
  218. else if (i == 2)
  219. {
  220. Str = @"<?xml version=""1.0"" encoding=""UTF-16"" standalone=""yes"" ?><root version=""1.00.1107"" sender =""HFHSXXJS00002.100188"" > ";
  221. return Str + "<input>" + sInpar + "</input></root>";
  222. }
  223. else
  224. {
  225. return "";
  226. }
  227. }
  228. private void btn_Open_Click(object sender, EventArgs e)
  229. {
  230. string AppMsg;
  231. ComType = null;
  232. ComInstance = null;
  233. if (GetReadCardObj(out ComType, out ComInstance) != 0)
  234. {
  235. MessageBox.Show("实例创建失败!");
  236. return;
  237. }
  238. OpenOrClose("open", ComType, ComInstance, out AppMsg);
  239. sOutPut.Text = AppMsg;
  240. }
  241. private void btn_Close_Click(object sender, EventArgs e)
  242. {
  243. string AppMsg = "";
  244. OpenOrClose("close", ComType, ComInstance, out AppMsg);
  245. sOutPut.Text = AppMsg;
  246. }
  247. private void btn_Exit_Click(object sender, EventArgs e)
  248. {
  249. //btn_Close_Click(sender, e);
  250. Close();
  251. }
  252. public int ReadCard(out string outParam,out int iOtherProvLocal)
  253. {
  254. outParam = "";
  255. iOtherProvLocal = 0;
  256. string FunName, Appmsg, AppRtnMsg, OutMsg, CloseOutMsg = string.Empty;
  257. //System.Type ComType;
  258. //object ComInstance;
  259. ReadCardClass rcl = new ReadCardClass();
  260. ChooseCard cc = new ChooseCard();
  261. cc.StartPosition = FormStartPosition.CenterScreen;
  262. try
  263. {
  264. if (cc.ShowDialog() == DialogResult.OK)
  265. {
  266. //【医保电子凭证】
  267. if (cc.sL_CardType == 1)
  268. {
  269. Appmsg = "<multiclass>" + (cc.sL_CardType + 1) + "</multiclass>" +
  270. "<QRcode>" + cc.QrCode + "</QRcode>" +
  271. "<businessType>" + cc.sYMYWLX + "</businessType>" +
  272. "<termId>" + GetMAC().Replace("-", string.Empty) + "</termId>" +
  273. "<termIp>" + GetIP() + "</termIp>" +
  274. "<operatorId>007</operatorId>" +
  275. "<operatorName>CM</operatorName>" +
  276. "<officeId>1001</officeId>" +
  277. "<officeName>收费处</officeName>";
  278. Appmsg = GetinPar(Appmsg, 0);
  279. }
  280. else
  281. {
  282. Appmsg = "<multiclass>" + (cc.sL_CardType + 1) + "</multiclass>";
  283. Appmsg = GetinPar(Appmsg, 0);
  284. }
  285. //【社保卡-本地】
  286. if (cc.iOtherProvLocal == 0)
  287. {
  288. FunName = "GetPersonInfo_Multimedia";
  289. //FunName = "GetCardInfo";
  290. }
  291. //【社保卡-异地】
  292. else
  293. {
  294. FunName = "GetPersonInfoNation_Multimedia";
  295. }
  296. iOtherProvLocal = cc.iOtherProvLocal;
  297. //创建首信医保Com实例
  298. ComType = null;
  299. ComInstance = null;
  300. if (rcl.GetReadCardObj(out ComType, out ComInstance) != 0)
  301. {
  302. outParam = "实例创建失败!";
  303. return -1;
  304. }
  305. else
  306. {
  307. //读卡前先Open
  308. if (cc.sL_CardType == 0)
  309. rcl.Open(ComType, ComInstance, out AppRtnMsg);
  310. sInput.Text = Appmsg;
  311. rcl.ReadCardObj(FunName, Appmsg, ComType, ComInstance, out AppRtnMsg);
  312. sOutPut.Text = AppRtnMsg;
  313. XmlDocument xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  314. Boolean bPass = AnXML.CheckState(xmlDoc, out OutMsg);
  315. XmlNode dataNode = AnXML.GetNodeFromPath(xmlDoc.DocumentElement, "output");
  316. //读卡结束一定要close不然再次读卡会报实例错
  317. if (cc.sL_CardType == 0)
  318. rcl.Close(ComType, ComInstance, out CloseOutMsg);
  319. if (bPass == false)
  320. {
  321. outParam = "调用 " + FunName + " 获取参保信息失败,中心返回错误信息:" + OutMsg + "\r\n" + "Close输出:" + CloseOutMsg;
  322. return -1;
  323. }
  324. outParam = AppRtnMsg;
  325. return 0;
  326. }
  327. }
  328. else
  329. {
  330. outParam = "收款员取消读卡!";
  331. return -1;
  332. }
  333. }
  334. catch (Exception ex)
  335. {
  336. if ((ComType != null) && (cc.sL_CardType == 0))
  337. rcl.Close(ComType, ComInstance, out CloseOutMsg);
  338. outParam = "ReadCard异常:" + ex.Message;
  339. return -1;
  340. }
  341. }
  342. public int ShowPatInfo(string patInfo,int type, out string outParam)
  343. {
  344. outParam = "";
  345. //弹框展示参保信息
  346. ReadCardInfo frmPatientInfo = new ReadCardInfo(patInfo, type);
  347. frmPatientInfo.StartPosition = FormStartPosition.CenterScreen;
  348. try
  349. {
  350. if (frmPatientInfo.ShowDialog() != DialogResult.OK)
  351. {
  352. outParam = "收款员取消读卡";
  353. return -1;
  354. }
  355. else
  356. {
  357. return 0;
  358. }
  359. }
  360. catch (Exception ex)
  361. {
  362. outParam = "异常:" + ex.Message;
  363. return -1;
  364. }
  365. }
  366. private void btn_GetPersonInfo_Click(object sender, EventArgs e)
  367. {
  368. string outParam;
  369. int iOtherProvLocal;
  370. OutpatientClass hObj = new OutpatientClass();
  371. hObj.Open(out string sOut);
  372. hObj.GetPersonInfo(out outParam);
  373. sOutPut.Text = outParam;
  374. hObj.Close(out sOut);
  375. MessageBox.Show(outParam);
  376. return;
  377. if (ReadCard(out outParam, out iOtherProvLocal) != 0)
  378. {
  379. MessageBox.Show(outParam);
  380. return;
  381. }
  382. else
  383. {
  384. if (ShowPatInfo(outParam, iOtherProvLocal, out outParam) != 0)
  385. {
  386. MessageBox.Show(outParam);
  387. }
  388. }
  389. }
  390. private void uiButton1_Click(object sender, EventArgs e)
  391. {
  392. string sRtnXML = sInput.Text;
  393. if (sRtnXML == "")
  394. {
  395. MessageBox.Show("入参不能为空!");
  396. return;
  397. }
  398. XmlDocument xmlDoc = new XmlDocument();
  399. xmlDoc.LoadXml(sRtnXML);
  400. string jsonStr = JsonConvert.SerializeXmlNode(xmlDoc);
  401. jsonStr = jsonStr.Replace("@", "").ToString();
  402. JObject joRtn = JObject.Parse(jsonStr);
  403. MedInsuFee frmFee = new MedInsuFee();
  404. //XML转换成JSON数组
  405. if (CountOccurrences(sInput.Text, "itemno") > 1)
  406. {
  407. frmFee.DtFee = (DataTable)joRtn["root"]["output"]["feeitemarray"]["feeitem"].ToObject(typeof(DataTable));
  408. }
  409. else
  410. {
  411. JArray jaFee = new JArray(JObject.Parse(getDestValue(joRtn, "root.output.feeitemarray.feeitem")));
  412. //jaFee.Add(JObject.Parse(getDestValue(joRtn, "root.output.feeitemarray.feeitem")));
  413. frmFee.DtFee = (DataTable)jaFee.ToObject(typeof(DataTable));
  414. }
  415. frmFee.ShowDialog();
  416. }
  417. public static string getDestValue(JObject jo, string destPath)
  418. {
  419. JToken jt = jo.SelectToken("$." + destPath);
  420. if (jt != null)
  421. {
  422. return jt.ToString();
  423. }
  424. else
  425. {
  426. // Global.writeLog(destPath + "的JToken属性值为空");
  427. return "";
  428. }
  429. }
  430. public static int CountOccurrences(string str, string subStr)
  431. {
  432. int count = 0;
  433. int index = -1; // 初始化为-1,因此会从第二个字符开始比较
  434. while ((index = str.IndexOf(subStr, index+1)) != -1)
  435. {
  436. count++;
  437. index += subStr.Length; // 更新索引位置到下一个匹配项的起始位置
  438. }
  439. return count;
  440. }
  441. private void btnConnectServer_Click(object sender, EventArgs e)
  442. {
  443. string FunName, Appmsg, AppRtnMsg, OutMsg, CloseOutMsg = string.Empty;
  444. //创建首信医保Com实例
  445. ComType = null;
  446. ComInstance = null;
  447. if (MOS.GetMedOrdersShareObj(out ComType, out ComInstance) != 0)
  448. {
  449. MessageBox.Show("实例创建失败!");
  450. return;
  451. }
  452. MOS.ConnectServer(ComType, ComInstance, out AppRtnMsg);
  453. sOutparam.Text = AppRtnMsg;
  454. }
  455. private void btnGetClinicHistoryTrade_Click(object sender, EventArgs e)
  456. {
  457. string FunName, Appmsg, AppRtnMsg, OutMsg, CloseOutMsg = string.Empty;
  458. string infotype;
  459. if (tbPsnNo.Text == "")
  460. {
  461. MessageBox.Show("医保编码不能为空!");
  462. return;
  463. }
  464. infotype = "0" + rbg_Type.SelectedIndex.ToString();
  465. //1.创建实例
  466. if (MOS.GetMedOrdersShareObj(out ComType, out ComInstance) != 0)
  467. {
  468. MessageBox.Show("实例创建失败!");
  469. return;
  470. }
  471. //2.初始化
  472. MOS.ConnectServer(ComType, ComInstance, out AppRtnMsg);
  473. //3.业务调用
  474. FunName = "GetClinicHistoryTrade";
  475. Appmsg = "<icno>" + (tbPsnNo.Text) + "</icno>" +
  476. "<registerno></registerno>" +
  477. "<infotype>" + infotype + "</infotype>";
  478. Appmsg = GetinPar(Appmsg, 0);
  479. sInparam.Text = Appmsg;
  480. MOS.MedOrdersShareObj(FunName, Appmsg, ComType, ComInstance, out AppRtnMsg);
  481. //解析返回值
  482. XmlDocument xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  483. Boolean bPass = AnXML.CheckState(xmlDoc, out OutMsg);
  484. XmlNode dataNode = AnXML.GetNodeFromPath(xmlDoc.DocumentElement, "output");
  485. if (bPass)
  486. {
  487. //sOutparam.Text = ConvertXMLToObject(AppRtnMsg).ToString();
  488. JObject joRtn = new JObject(JObject.Parse(getDestValue(ConvertXMLToObject(AppRtnMsg), "root.output")));
  489. sOutparam.Text = joRtn.ToString();
  490. }
  491. else
  492. sOutparam.Text = AppRtnMsg;
  493. }
  494. private void btnPresUpload_Click(object sender, EventArgs e)
  495. {
  496. ReadCardClass rcl = new ReadCardClass();
  497. string PutExRxInfo = sInput.Text, Appmsg = "", AppRtnMsg = "", OutMsg = "", OutMsg_Close = "", InsuOutMsg = "", outParam = "";
  498. if (PutExRxInfo == "")
  499. {
  500. MessageBox.Show("外配处方入参不能为空!");
  501. return;
  502. }
  503. //创建首信医保Com实例
  504. ComType = null;
  505. ComInstance = null;
  506. if (rcl.GetReadCardObj(out ComType, out ComInstance) != 0)
  507. {
  508. outParam = "实例创建失败!";
  509. return;
  510. }
  511. else
  512. {
  513. //读卡前先Open
  514. rcl.Open(ComType, ComInstance, out AppRtnMsg);
  515. Appmsg = "<multiclass>1</multiclass>";
  516. Appmsg = GetinPar(Appmsg, 0);
  517. rcl.ReadCardObj("GetPersonInfo_ExRx_RQ", Appmsg, ComType, ComInstance, out AppRtnMsg);
  518. sOutPut.Text = AppRtnMsg;
  519. XmlDocument xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  520. if (AnXML.CheckState(xmlDoc, out OutMsg) == false)
  521. {
  522. rcl.Close(ComType, ComInstance, out OutMsg_Close);
  523. MessageBox.Show("获取参保信息GetPersonInfo_ExRx_RQ失败,中心返回错误信息:" + OutMsg + "\r\n"
  524. + "调用【Close】关闭读卡设备输出:" + OutMsg_Close);
  525. return;
  526. }
  527. else
  528. {
  529. MessageBox.Show(AppRtnMsg);
  530. //4.调用提交外配处方信息
  531. rcl.ReadCardObj("PutExRxInfo", PutExRxInfo, ComType, ComInstance, out AppRtnMsg);
  532. xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  533. if (AnXML.CheckState(xmlDoc, out OutMsg) == false)
  534. {
  535. rcl.Close(ComType, ComInstance, out OutMsg_Close);
  536. MessageBox.Show("提交外配处方信息PutExRxInfo失败,中心返回错误信息:" + OutMsg + "\r\n"
  537. + "调用【Close】关闭读卡设备输出:" + OutMsg_Close);
  538. return;
  539. }
  540. else
  541. {
  542. xmlDoc = null;
  543. rcl.Close(ComType, ComInstance, out OutMsg_Close);
  544. MessageBox.Show("提交外配处方信息成功:" + AppRtnMsg);
  545. return;
  546. }
  547. }
  548. }
  549. }
  550. private void uiButton3_Click(object sender, EventArgs e)
  551. {
  552. sOutPut.Text = ConvertXMLToObject(sInput.Text).ToString();
  553. }
  554. private void uiButton4_Click(object sender, EventArgs e)
  555. {
  556. int iOtherProvLocal = 0;
  557. string FunName, Appmsg, AppRtnMsg, OutMsg, CloseOutMsg = string.Empty;
  558. //System.Type ComType;
  559. //object ComInstance;
  560. //创建首信医保Com实例
  561. ComType = null;
  562. ComInstance = null;
  563. ReadCardClass rcl = new ReadCardClass();
  564. ChooseCard cc = new ChooseCard();
  565. cc.StartPosition = FormStartPosition.CenterScreen;
  566. try
  567. {
  568. if (cc.ShowDialog() == DialogResult.OK)
  569. {
  570. //【医保电子凭证】
  571. if (cc.sL_CardType == 1)
  572. {
  573. Appmsg = "<multiclass>" + (cc.sL_CardType + 1) + "</multiclass>" +
  574. "<QRcode>" + cc.QrCode + "</QRcode>" +
  575. "<businessType>" + cc.sYMYWLX + "</businessType>" +
  576. "<termId>" + GetMAC().Replace("-", string.Empty) + "</termId>" +
  577. "<termIp>" + GetIP() + "</termIp>" +
  578. "<operatorId>007</operatorId>" +
  579. "<operatorName>CM</operatorName>" +
  580. "<officeId>1001</officeId>" +
  581. "<officeName>收费处</officeName>";
  582. Appmsg = GetinPar(Appmsg, 0);
  583. }
  584. else
  585. {
  586. Appmsg = "<multiclass>" + (cc.sL_CardType + 1) + "</multiclass>";
  587. Appmsg = GetinPar(Appmsg, 0);
  588. }
  589. if (rcl.GetReadCardObj(out ComType, out ComInstance) != 0)
  590. {
  591. MessageBox.Show("实例创建失败");
  592. return;
  593. }
  594. //【社保卡-本地】
  595. if (cc.iOtherProvLocal == 0)
  596. {
  597. FunName = "GetPersonInfo_Multimedia";
  598. }
  599. else //【社保卡-异地】
  600. {
  601. FunName = "GetPersonInfoNation_Multimedia";
  602. }
  603. iOtherProvLocal = cc.iOtherProvLocal;
  604. //读卡前先Open
  605. rcl.Open(ComType, ComInstance, out AppRtnMsg);
  606. sInput.Text = Appmsg;
  607. rcl.ReadCardObj("GetPersonClass_Multimedia", Appmsg, ComType, ComInstance, out AppRtnMsg);
  608. XmlDocument xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  609. Boolean bPass = AnXML.CheckState(xmlDoc, out OutMsg);
  610. XmlNode dataNode = AnXML.GetNodeFromPath(xmlDoc.DocumentElement, "output");
  611. if (bPass == false)
  612. {
  613. MessageBox.Show("调用GetPersonClass_Multimedia获取参保类别信息失败,中心返回错误信息:" + OutMsg + "\r\n" + "Close输出:" + CloseOutMsg);
  614. return;
  615. }
  616. else
  617. {
  618. MessageBox.Show("调用GetPersonClass_Multimedia获取参保类别信息成功返回:" + AppRtnMsg);
  619. return;
  620. }
  621. rcl.ReadCardObj(FunName, Appmsg, ComType, ComInstance, out AppRtnMsg);
  622. sOutPut.Text = AppRtnMsg;
  623. xmlDoc = AnXML.GetXmlDoc(AppRtnMsg);
  624. bPass = AnXML.CheckState(xmlDoc, out OutMsg);
  625. dataNode = AnXML.GetNodeFromPath(xmlDoc.DocumentElement, "output");
  626. //读卡结束一定要close不然再次读卡会报实例错
  627. rcl.Close(ComType, ComInstance, out CloseOutMsg);
  628. if (bPass == false)
  629. {
  630. MessageBox.Show("调用 " + FunName + " 获取参保信息失败,中心返回错误信息:" + OutMsg + "\r\n" + "Close输出:" + CloseOutMsg);
  631. return;
  632. }
  633. MessageBox.Show(AppRtnMsg);
  634. return;
  635. }
  636. else
  637. {
  638. MessageBox.Show("收款员取消读卡");
  639. return;
  640. }
  641. }
  642. catch (Exception ex)
  643. {
  644. if ((ComType != null) && (cc.sL_CardType == 0))
  645. rcl.Close(ComType, ComInstance, out CloseOutMsg);
  646. MessageBox.Show("ReadCard异常:" + ex.Message);
  647. return;
  648. }
  649. }
  650. }
  651. }