ObjectClass.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Windows.Forms;
  10. using System.Reflection;
  11. using System.Net;
  12. using System.Management;
  13. using System.IO;
  14. using PTMedicalInsurance.Variables;
  15. using PTMedicalInsurance.Helper;
  16. using Newtonsoft.Json.Linq;
  17. using Newtonsoft.Json;
  18. using System.Runtime.InteropServices;
  19. using MedicareComLib;
  20. namespace PTMedicalInsurance
  21. {
  22. class SaveLogInData
  23. {
  24. /// <summary>
  25. /// 保存中心交易日志到数据库
  26. /// </summary>
  27. /// <param name="inParam"></param>
  28. /// <param name="outParam"></param>
  29. /// <param name="inParamPlain"></param>
  30. /// <param name="outParamPlain"></param>
  31. private void saveCenterLog(string inParam, string outParam, string inParamPlain, string outParamPlain)
  32. {
  33. dynamic joIris = new JObject();
  34. string sRtn = "";
  35. try
  36. {
  37. //解析postContent,插入医保交易日志表
  38. JArray jaParams = new JArray();
  39. JObject joParam = new JObject();
  40. joParam.Add("inParam", inParam);
  41. joParam.Add("outParam", outParam);
  42. joParam.Add("inParamPlain", inParamPlain);
  43. joParam.Add("outParamPlain", outParamPlain);
  44. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  45. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  46. joParam.Add("updateUserID", Global.user.ID);
  47. joParam.Add("psn_no", Global.pat.psn_no);
  48. jaParams.Add(joParam);
  49. joIris.code = "09010021";
  50. joIris.Add("params", jaParams);
  51. InvokeHelper invoker = new InvokeHelper();
  52. sRtn = invoker.invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  53. }
  54. catch (Exception ex)
  55. {
  56. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  57. Global.writeLog_Iris("保存日志异常:" + sRtn.ToString());
  58. }
  59. }
  60. }
  61. class ReadCardClass
  62. {
  63. OutpatientClass ShouXinObj = new OutpatientClass();
  64. public int CreateBusinessObj(out System.Type OutComType,out dynamic OutComInstance)
  65. {
  66. string rtn = "";
  67. string progID = "MedicareCom.Outpatient";
  68. OutComType = null;
  69. OutComInstance = "";
  70. try
  71. {
  72. OutComType = Type.GetTypeFromProgID(progID);
  73. // 创建Com的实例
  74. if (OutComType != null)
  75. {
  76. //创建实例
  77. OutComInstance = Activator.CreateInstance(OutComType);
  78. rtn = "成功";
  79. return 0;
  80. }
  81. else
  82. {
  83. rtn = "失败";
  84. return -1;
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. rtn = "失败" + ",COM加载异常" + ex.Message;
  90. return -1;
  91. }
  92. finally
  93. {
  94. Global.writeLog("GetReadCardObj", "", "创建实例" + rtn);
  95. }
  96. }
  97. public void Open(System.Type ComType, object ComInstance,out string OutPut)
  98. {
  99. OutPut = "";
  100. try
  101. {
  102. if (ComInstance == null)
  103. {
  104. OutPut = "实例不存在!";
  105. return;
  106. }
  107. //设置需要设置的参数值
  108. object[] ParamArray = new object[1];
  109. ParamArray[0] = "";
  110. //ParamArray[1] = input;
  111. ParameterModifier[] ParamMods = new ParameterModifier[1];
  112. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  113. ParamMods[0][0] = true;
  114. ComType.InvokeMember("open", // 接口函数名
  115. BindingFlags.Default | BindingFlags.InvokeMethod,
  116. null,
  117. ComInstance, // 调用的COM组件
  118. ParamArray, // 参数数组
  119. ParamMods, // 指定返回参数的ParameterModifier数组
  120. null,
  121. null);
  122. OutPut = ParamArray[0].ToString();
  123. //MessageBox.Show("Com输出:" + OutPut);
  124. return;
  125. }
  126. catch (Exception ex)
  127. {
  128. OutPut = ex.Message;
  129. MessageBox.Show("COM加载异常!" + OutPut);
  130. return;
  131. }
  132. finally
  133. {
  134. Global.writeLog("Open", "", OutPut);
  135. //this.saveCenterLog("", OutPut, "", OutPut);
  136. }
  137. }
  138. public void Close(System.Type ComType, dynamic ComInstance, out string OutPut)
  139. {
  140. OutPut = "";
  141. try
  142. {
  143. if (ComInstance == null)
  144. {
  145. OutPut = "实例不存在!";
  146. return;
  147. }
  148. //GlobalVariables.writeLog("入参infno:" + infno);
  149. //GlobalVariables.writeLog("入参input:" + input);
  150. //设置需要设置的参数值
  151. object[] ParamArray = new object[1];
  152. ParamArray[0] = "";
  153. //ParamArray[1] = input;
  154. ParameterModifier[] ParamMods = new ParameterModifier[1];
  155. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  156. ParamMods[0][0] = true;
  157. ComType.InvokeMember("close", // 接口函数名
  158. BindingFlags.Default | BindingFlags.InvokeMethod,
  159. null,
  160. ComInstance, // 调用的COM组件
  161. ParamArray, // 参数数组
  162. ParamMods, // 指定返回参数的ParameterModifier数组
  163. null,
  164. null);
  165. OutPut = ParamArray[0].ToString();
  166. //MessageBox.Show("Com输出:" + OutPut);
  167. return;
  168. }
  169. catch (Exception ex)
  170. {
  171. OutPut = ex.Message;
  172. MessageBox.Show("COM加载异常!" + OutPut);
  173. return;
  174. }
  175. finally
  176. {
  177. Global.writeLog("Close", "", OutPut);
  178. }
  179. }
  180. public void ReadCardObj(string FunName, string Input, System.Type ComType, dynamic ComInstance, out string OutPut)
  181. {
  182. OutPut = "";
  183. try
  184. {
  185. if (ComInstance == null)
  186. {
  187. OutPut = "实例不存在!";
  188. return;
  189. }
  190. //设置需要设置的参数值
  191. object[] ParamArray = new object[2];
  192. ParamArray[0] = Input;
  193. ParamArray[1] = Input;
  194. ParameterModifier[] ParamMods = new ParameterModifier[1];
  195. ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
  196. ParamMods[0][0] = true;
  197. ParamMods[0][1] = true;
  198. ComType.InvokeMember(FunName, // 接口函数名
  199. BindingFlags.Default | BindingFlags.InvokeMethod,
  200. null,
  201. ComInstance, // 调用的COM组件
  202. ParamArray, // 参数数组
  203. ParamMods, // 指定返回参数的ParameterModifier数组
  204. null,
  205. null);
  206. OutPut = ParamArray[1].ToString();
  207. return;
  208. }
  209. catch (Exception ex)
  210. {
  211. OutPut = ex.Message;
  212. MessageBox.Show("COM加载异常!" + OutPut);
  213. return;
  214. }
  215. finally
  216. {
  217. Global.writeLog(FunName, Input, OutPut);
  218. }
  219. }
  220. public void BussniessObj(string FunName, string Input, System.Type ComType, dynamic ComInstance, out string OutPut)
  221. {
  222. OutPut = "";
  223. try
  224. {
  225. if (ComInstance == null)
  226. {
  227. OutPut = "实例不存在!";
  228. return;
  229. }
  230. //设置需要设置的参数值
  231. object[] ParamArray = new object[2];
  232. ParamArray[0] = Input;
  233. ParamArray[1] = Input;
  234. ParameterModifier[] ParamMods = new ParameterModifier[1];
  235. ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
  236. ParamMods[0][0] = true;
  237. ParamMods[0][1] = true;
  238. ComType.InvokeMember(FunName, // 接口函数名
  239. BindingFlags.Default | BindingFlags.InvokeMethod,
  240. null,
  241. ComInstance, // 调用的COM组件
  242. ParamArray, // 参数数组
  243. ParamMods, // 指定返回参数的ParameterModifier数组
  244. null,
  245. null);
  246. OutPut = ParamArray[1].ToString();
  247. return;
  248. }
  249. catch (Exception ex)
  250. {
  251. OutPut = ex.Message;
  252. MessageBox.Show("COM加载异常!" + OutPut);
  253. return;
  254. }
  255. finally
  256. {
  257. Global.writeLog(FunName, Input, OutPut);
  258. }
  259. }
  260. public void Trade(System.Type ComType, dynamic ComInstance, out string OutPut)
  261. {
  262. OutPut = "";
  263. try
  264. {
  265. if (ComInstance == null)
  266. {
  267. OutPut = "实例不存在!";
  268. return;
  269. }
  270. //设置需要设置的参数值
  271. object[] ParamArray = new object[1];
  272. ParamArray[0] = "";
  273. //ParamArray[1] = input;
  274. ParameterModifier[] ParamMods = new ParameterModifier[1];
  275. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  276. ParamMods[0][0] = true;
  277. ComType.InvokeMember("Trade", // 接口函数名
  278. BindingFlags.Default | BindingFlags.InvokeMethod,
  279. null,
  280. ComInstance, // 调用的COM组件
  281. ParamArray, // 参数数组
  282. ParamMods, // 指定返回参数的ParameterModifier数组
  283. null,
  284. null);
  285. OutPut = ParamArray[0].ToString();
  286. //MessageBox.Show("Com输出:" + OutPut);
  287. return;
  288. }
  289. catch (Exception ex)
  290. {
  291. OutPut = ex.Message;
  292. MessageBox.Show("COM加载异常!" + OutPut);
  293. return;
  294. }
  295. finally
  296. {
  297. Global.writeLog("Trade", "", OutPut);
  298. }
  299. }
  300. public void TradeAll(System.Type ComType, dynamic ComInstance, out string OutPut)
  301. {
  302. OutPut = "";
  303. try
  304. {
  305. if (ComInstance == null)
  306. {
  307. OutPut = "实例不存在!";
  308. return;
  309. }
  310. //设置需要设置的参数值
  311. object[] ParamArray = new object[1];
  312. ParamArray[0] = "";
  313. //ParamArray[1] = input;
  314. ParameterModifier[] ParamMods = new ParameterModifier[1];
  315. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  316. ParamMods[0][0] = true;
  317. ComType.InvokeMember("TradeAll", // 接口函数名
  318. BindingFlags.Default | BindingFlags.InvokeMethod,
  319. null,
  320. ComInstance, // 调用的COM组件
  321. ParamArray, // 参数数组
  322. ParamMods, // 指定返回参数的ParameterModifier数组
  323. null,
  324. null);
  325. OutPut = ParamArray[0].ToString();
  326. return;
  327. }
  328. catch (Exception ex)
  329. {
  330. OutPut = ex.Message;
  331. MessageBox.Show("COM加载异常!" + OutPut);
  332. return;
  333. }
  334. finally
  335. {
  336. Global.writeLog("TradeAll", "", OutPut);
  337. //this.saveCenterLog("", OutPut, "", OutPut);
  338. }
  339. }
  340. public void Open(out string OutPut)
  341. {
  342. OutPut = "";
  343. try
  344. {
  345. ShouXinObj.Open(out OutPut);
  346. return;
  347. }
  348. catch (Exception ex)
  349. {
  350. OutPut = ex.Message;
  351. MessageBox.Show("Open加载异常!" + OutPut);
  352. return;
  353. }
  354. finally
  355. {
  356. Global.writeLog("Open", "", OutPut);
  357. //this.saveCenterLog("", OutPut, "", OutPut);
  358. }
  359. }
  360. public void Close(out string OutPut)
  361. {
  362. OutPut = "";
  363. try
  364. {
  365. ShouXinObj.Close(out OutPut);
  366. return;
  367. }
  368. catch (Exception ex)
  369. {
  370. OutPut = ex.Message;
  371. MessageBox.Show("Close加载异常!" + OutPut);
  372. return;
  373. }
  374. finally
  375. {
  376. ShouXinObj = null;
  377. Global.writeLog("Close", "", OutPut);
  378. //this.saveCenterLog("", OutPut, "", OutPut);
  379. }
  380. }
  381. public void GetPersonInfo(out string OutPut)
  382. {
  383. OutPut = "";
  384. try
  385. {
  386. ShouXinObj.GetPersonInfo(out OutPut);
  387. return;
  388. }
  389. catch (Exception ex)
  390. {
  391. OutPut = ex.Message;
  392. MessageBox.Show("GetPersonInfo加载异常!" + OutPut);
  393. return;
  394. }
  395. finally
  396. {
  397. Global.writeLog("GetPersonInfo", "", OutPut);
  398. //this.saveCenterLog("", OutPut, "", OutPut);
  399. }
  400. }
  401. /// <summary>
  402. /// 保存中心交易日志到数据库
  403. /// </summary>
  404. /// <param name="inParam"></param>
  405. /// <param name="outParam"></param>
  406. /// <param name="inParamPlain"></param>
  407. /// <param name="outParamPlain"></param>
  408. private void saveCenterLog(string inParam, string outParam, string inParamPlain, string outParamPlain)
  409. {
  410. dynamic joIris = new JObject();
  411. string sRtn = "";
  412. try
  413. {
  414. //解析postContent,插入医保交易日志表
  415. JArray jaParams = new JArray();
  416. JObject joParam = new JObject();
  417. joParam.Add("inParam", inParam);
  418. joParam.Add("outParam", outParam);
  419. joParam.Add("inParamPlain", inParamPlain);
  420. joParam.Add("outParamPlain", outParamPlain);
  421. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  422. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  423. joParam.Add("updateUserID", Global.user.ID);
  424. joParam.Add("psn_no", Global.pat.psn_no);
  425. jaParams.Add(joParam);
  426. joIris.code = "09010021";
  427. joIris.Add("params", jaParams);
  428. InvokeHelper invoker = new InvokeHelper();
  429. sRtn = invoker.invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  430. }
  431. catch (Exception ex)
  432. {
  433. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  434. Global.writeLog_Iris("保存日志异常:" + sRtn.ToString());
  435. }
  436. }
  437. }
  438. class MedOrdersShareClass
  439. {
  440. public int GetMedOrdersShareObj(out System.Type OutComType, out object OutComInstance)
  441. {
  442. Object rtnObj = "";
  443. string progID = "EachCommunicationCom.Outpatient";
  444. System.Type ComType;
  445. object ComInstance;
  446. ComType = Type.GetTypeFromProgID(progID);
  447. // 创建Com的实例
  448. if (ComType != null)
  449. {
  450. //创建实例
  451. ComInstance = Activator.CreateInstance(ComType);
  452. OutComType = ComType;
  453. OutComInstance = ComInstance;
  454. return 0;
  455. }
  456. else
  457. {
  458. OutComType = null;
  459. OutComInstance = "";
  460. return -1;
  461. }
  462. }
  463. public void ConnectServer(System.Type ComType, object ComInstance, out string OutPut)
  464. {
  465. OutPut = "";
  466. try
  467. {
  468. if (ComInstance == null)
  469. {
  470. OutPut = "实例不存在!";
  471. return;
  472. }
  473. //GlobalVariables.writeLog("入参infno:" + infno);
  474. //GlobalVariables.writeLog("入参input:" + input);
  475. //设置需要设置的参数值
  476. object[] ParamArray = new object[1];
  477. ParamArray[0] = "";
  478. //ParamArray[1] = input;
  479. ParameterModifier[] ParamMods = new ParameterModifier[1];
  480. ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
  481. ParamMods[0][0] = true;
  482. ComType.InvokeMember("ConnectServer", // 接口函数名
  483. BindingFlags.Default | BindingFlags.InvokeMethod,
  484. null,
  485. ComInstance, // 调用的COM组件
  486. ParamArray, // 参数数组
  487. ParamMods, // 指定返回参数的ParameterModifier数组
  488. null,
  489. null);
  490. OutPut = ParamArray[0].ToString();
  491. //MessageBox.Show("ConnectServer输出:" + OutPut);
  492. return;
  493. }
  494. catch (Exception ex)
  495. {
  496. OutPut = ex.Message;
  497. //MessageBox.Show("COM加载异常!" + OutPut);
  498. return;
  499. }
  500. finally
  501. {
  502. Global.writeLog("ConnectServer", "", OutPut);
  503. }
  504. }
  505. public void MedOrdersShareObj(string FunName, string Input, System.Type ComType, object ComInstance, out string OutPut)
  506. {
  507. OutPut = "";
  508. try
  509. {
  510. if (ComInstance == null)
  511. {
  512. OutPut = "实例不存在!";
  513. return;
  514. }
  515. //GlobalVariables.writeLog("入参infno:" + infno);
  516. //GlobalVariables.writeLog("入参input:" + input);
  517. //设置需要设置的参数值
  518. object[] ParamArray = new object[2];
  519. ParamArray[0] = Input;
  520. ParamArray[1] = Input;
  521. ParameterModifier[] ParamMods = new ParameterModifier[1];
  522. ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
  523. ParamMods[0][0] = true;
  524. ParamMods[0][1] = true;
  525. ComType.InvokeMember(FunName, // 接口函数名
  526. BindingFlags.Default | BindingFlags.InvokeMethod,
  527. null,
  528. ComInstance, // 调用的COM组件
  529. ParamArray, // 参数数组
  530. ParamMods, // 指定返回参数的ParameterModifier数组
  531. null,
  532. null);
  533. OutPut = ParamArray[1].ToString();
  534. return;
  535. }
  536. catch (Exception ex)
  537. {
  538. OutPut = ex.Message;
  539. MessageBox.Show("COM加载异常!" + OutPut);
  540. return;
  541. }
  542. finally
  543. {
  544. Global.writeLog(FunName, Input, OutPut);
  545. }
  546. }
  547. }
  548. }