InvokeHelper.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /******************************************************************************
  2. * 文件名称: InvokeHelper.cs
  3. * 文件说明: 调用助手,调用方法的封装
  4. * 当前版本: V1.0
  5. * 创建日期: 2022-04-12
  6. *
  7. * 2020-04-12: 增加 businessDLLInvoke 方法
  8. * 2020-04-12: 增加 writeLog 方法
  9. * 2020-04-14: 增加 businessDLLInvoke(重载) 方法
  10. * 2020-04-14: 增加 irisServiceInvoke 方法
  11. ******************************************************************************/
  12. using Newtonsoft.Json.Linq;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Net;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows.Forms;
  21. using PTMedicalInsurance.Helper;
  22. using Newtonsoft.Json;
  23. using PTMedicalInsurance.Common;
  24. using PTMedicalInsurance.Variables;
  25. namespace PTMedicalInsurance.Helper
  26. {
  27. class InvokeHelper
  28. {
  29. private string serviceURL;
  30. private string authorization;
  31. /// <summary>
  32. /// iris服务调用的封装
  33. /// </summary>
  34. /// <param name="data"></param>
  35. /// <returns></returns>
  36. public JObject invokeIrisService(string data, string serviceDesc)
  37. {
  38. string rtn = "", url = "";
  39. JObject joRtn = new JObject();
  40. try
  41. {
  42. //先根据用户请求的uri构造请求地址
  43. url = serviceURL;
  44. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  45. ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  46. //创建Web访问对象
  47. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  48. //把用户传过来的数据转成“UTF-8”的字节流
  49. byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(data);
  50. //添加头部信息
  51. myRequest.Method = "POST";
  52. myRequest.ContentLength = buf.Length;
  53. myRequest.ContentType = "application/json";
  54. myRequest.Headers.Add("Authorization", authorization);
  55. myRequest.MaximumAutomaticRedirections = 1;
  56. myRequest.AllowAutoRedirect = true;
  57. //发送请求
  58. Stream stream = myRequest.GetRequestStream();
  59. stream.Write(buf, 0, buf.Length);
  60. stream.Close();
  61. //获取接口返回值
  62. //通过Web访问对象获取响应内容
  63. HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
  64. //通过响应内容流创建StreamReader对象,因为StreamReader更高级更快
  65. StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
  66. //string rtn = HttpUtility.UrlDecode(reader.ReadToEnd());//如果有编码问题就用这个方法
  67. rtn = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
  68. reader.Close();
  69. myResponse.Close();
  70. joRtn = JObject.Parse(rtn);
  71. return joRtn;
  72. }
  73. catch (Exception ex)
  74. {
  75. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  76. rtn = JsonConvert.SerializeObject(joRtn);
  77. return joRtn;
  78. }
  79. }
  80. /// <summary>
  81. /// HIS服务调用的封装
  82. /// </summary>
  83. /// <param name="data"></param>
  84. /// <returns></returns>
  85. public JObject invokeHISService(string data, string serviceDesc)
  86. {
  87. JObject joRtn = new JObject();
  88. try
  89. {
  90. //先根据用户请求的uri构造请求地址
  91. serviceURL = string.Format("{0}/{1}", Global.hisConfig.ip, Global.hisConfig.url);
  92. authorization = Global.hisConfig.authorization;
  93. joRtn = invokeIrisService(data, serviceDesc);
  94. return joRtn;
  95. }
  96. catch (Exception ex)
  97. {
  98. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  99. return joRtn;
  100. }
  101. finally
  102. {
  103. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), JsonHelper.Compress(joRtn));
  104. }
  105. }
  106. /// <summary>
  107. /// 医保平台服务调用的封装
  108. /// </summary>
  109. /// <param name="data"></param>
  110. /// <returns></returns>
  111. public JObject invokeInsuService(string data, string serviceDesc)
  112. {
  113. string rtn = "";
  114. JObject joRtn = new JObject();
  115. try
  116. {
  117. //先根据用户请求的uri构造请求地址
  118. serviceURL = string.Format("{0}/{1}", Global.insuConfig.ip, Global.insuConfig.url);
  119. authorization = Global.insuConfig.authorization;
  120. joRtn = invokeIrisService(data, serviceDesc);
  121. rtn = JsonConvert.SerializeObject(joRtn);
  122. return joRtn;
  123. }
  124. catch (Exception ex)
  125. {
  126. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  127. rtn = JsonConvert.SerializeObject(joRtn);
  128. return joRtn;
  129. }
  130. finally
  131. {
  132. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), rtn);
  133. }
  134. }
  135. private JObject invokeCenterService(string data)
  136. {
  137. string postContent = "";
  138. JObject joRtn = new JObject();
  139. try
  140. {
  141. //创建一个HTTP请求
  142. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  143. //Post请求方式
  144. request.Method = "POST";
  145. //内容类型
  146. request.ContentType = "application/json";
  147. //设置参数,并进行URL编码
  148. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  149. byte[] payload;
  150. //将Json字符串转化为字节
  151. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  152. //设置请求的ContentLength
  153. request.ContentLength = payload.Length;
  154. //发送请求,获得请求流
  155. Stream writer;
  156. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  157. //将请求参数写入流
  158. writer.Write(payload, 0, payload.Length);
  159. writer.Close();//关闭请求流
  160. // String strValue = "";//strValue为http响应所返回的字符流
  161. HttpWebResponse response;
  162. try
  163. {
  164. //获得响应流
  165. response = (HttpWebResponse)request.GetResponse();
  166. }
  167. catch (WebException ex)
  168. {
  169. response = ex.Response as HttpWebResponse;
  170. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  171. }
  172. Stream s = response.GetResponseStream();
  173. StreamReader sRead = new StreamReader(s);
  174. postContent = sRead.ReadToEnd();
  175. sRead.Close();
  176. joRtn = JObject.Parse(postContent);//返回Json数据
  177. return joRtn;
  178. }
  179. catch (Exception ex)
  180. {
  181. postContent = "调用中心服务异常" + ex.Message;
  182. joRtn.Add("infcode", -1);
  183. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  184. return joRtn;
  185. }
  186. }
  187. /// <summary>
  188. /// 调用实名认证 智能场景监控
  189. /// </summary>
  190. /// <param name="data"></param>
  191. /// <returns></returns>
  192. public JObject invokeRealNameService(string data)
  193. {
  194. string postContent = "";
  195. JObject joRtn = new JObject();
  196. string URL = @"http://127.0.0.1:51518/stdcashFaceAuth";
  197. try
  198. {
  199. //创建一个HTTP请求
  200. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
  201. //Post请求方式
  202. request.Method = "POST";
  203. //内容类型
  204. request.ContentType = "application/json";
  205. //设置参数,并进行URL编码
  206. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  207. byte[] payload;
  208. //将Json字符串转化为字节
  209. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  210. //设置请求的ContentLength
  211. request.ContentLength = payload.Length;
  212. //发送请求,获得请求流
  213. Stream writer;
  214. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  215. //将请求参数写入流
  216. writer.Write(payload, 0, payload.Length);
  217. writer.Close();//关闭请求流
  218. // String strValue = "";//strValue为http响应所返回的字符流
  219. HttpWebResponse response;
  220. try
  221. {
  222. //获得响应流
  223. response = (HttpWebResponse)request.GetResponse();
  224. }
  225. catch (WebException ex)
  226. {
  227. response = ex.Response as HttpWebResponse;
  228. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  229. }
  230. Stream s = response.GetResponseStream();
  231. StreamReader sRead = new StreamReader(s);
  232. postContent = sRead.ReadToEnd();
  233. sRead.Close();
  234. joRtn = JObject.Parse(postContent);//返回Json数据
  235. return joRtn;
  236. }
  237. catch (Exception ex)
  238. {
  239. postContent = "调用中心服务异常" + ex.Message;
  240. joRtn.Add("code", -1);
  241. joRtn.Add("msg", "invokeRealNameService:" + ex.Message);
  242. return joRtn;
  243. }
  244. finally
  245. {
  246. Global.writeLog($"invokeRealNameService({URL})",data,joRtn.ToString());
  247. }
  248. }
  249. public JObject invokeCenterService(string funNO, JObject data)
  250. {
  251. //1
  252. string encryptData = JsonHelper.setCenterInpar(funNO, data);
  253. JObject joRtn = new JObject();
  254. JObject joOrgRtn = new JObject();//原来加密的数据
  255. String outPar = "";
  256. try
  257. {
  258. Global.curEvt.URL = Global.inf.centerURL + "/hsa-fsi-" + funNO;
  259. joRtn = invokeCenterService(encryptData);
  260. joOrgRtn = (JObject)joRtn.DeepClone();
  261. if (!Global.IsNeedEncrypt(funNO))
  262. {
  263. outPar = JsonHelper.Compress(joRtn);
  264. }
  265. else
  266. {
  267. //解密
  268. if (joRtn["output"] != null)
  269. {
  270. HaErBinEncrypt hept = new HaErBinEncrypt();
  271. string cipher = JsonHelper.getDestValue(joRtn, "output");
  272. string plain = hept.Decrypt(cipher);
  273. joRtn["output"] = JObject.Parse(plain);
  274. }
  275. }
  276. outPar = JsonHelper.Compress(joRtn);
  277. return joRtn;
  278. }
  279. catch (Exception ex)
  280. {
  281. if (joRtn["infcode"] == null)
  282. { joRtn.Add("infcode", -1); }
  283. if (joRtn["err_msg"] == null)
  284. { joRtn.Add("err_msg", "invokeCenterService(2):" + ex.Message); }
  285. outPar = JsonHelper.Compress(joRtn);
  286. joOrgRtn = (JObject)joRtn.DeepClone();
  287. return joRtn;
  288. }
  289. finally
  290. {
  291. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")(明文)", JsonHelper.Compress(data), joRtn.ToString());
  292. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")(密文)", JsonHelper.Compress(encryptData), joOrgRtn.ToString());
  293. this.saveCenterLog(JsonHelper.Compress(encryptData), joOrgRtn.ToString(),JsonHelper.Compress(data),outPar);
  294. }
  295. }
  296. public JObject invokeCenterService(string funNO, string data)
  297. {
  298. string encryptData = "";
  299. JObject joRtn = new JObject();
  300. JObject joOrgRtn = new JObject();//原来加密的数据
  301. String outPar = "";
  302. if (string.IsNullOrEmpty(data))
  303. {
  304. joRtn.Add("infcode", -1);
  305. joRtn.Add("err_msg", "入参不允许为空!");
  306. return joRtn;
  307. }
  308. encryptData = JsonHelper.setCenterInpar(funNO, data);
  309. try
  310. {
  311. Global.curEvt.URL = Global.inf.centerURL + "/hsa-fsi-" + funNO;
  312. //Global.curEvt.URL = Global.inf.centerURL ;
  313. joRtn = invokeCenterService(encryptData);
  314. joOrgRtn = (JObject)joRtn.DeepClone();
  315. //解密
  316. if (JsonHelper.getDestValue(joRtn, "infcode") != "0")
  317. {
  318. outPar = JsonHelper.Compress(joRtn);
  319. }
  320. else
  321. {
  322. if (! Global.IsNeedEncrypt(funNO))
  323. {
  324. outPar = JsonHelper.Compress(joRtn);
  325. }
  326. else
  327. {
  328. //解密
  329. string cipher = "";
  330. HaErBinEncrypt hept = new HaErBinEncrypt();
  331. if(! string.IsNullOrEmpty(JsonHelper.getDestValue(joRtn, "output")))
  332. {
  333. cipher = JsonHelper.getDestValue(joRtn, "output");
  334. string plain = hept.Decrypt(cipher);
  335. joRtn["output"] = JObject.Parse(plain);
  336. }
  337. }
  338. }
  339. outPar = JsonHelper.Compress(joRtn);
  340. return joRtn;
  341. }
  342. catch (Exception ex)
  343. {
  344. if (joRtn["infcode"] == null)
  345. { joRtn.Add("infcode", -1); }
  346. if (joRtn["err_msg"] == null)
  347. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  348. outPar = JsonHelper.Compress(joRtn);
  349. joOrgRtn = (JObject)joRtn.DeepClone();
  350. return joRtn;
  351. }
  352. finally
  353. {
  354. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")(明文)", JsonHelper.Compress(data), joRtn.ToString());
  355. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")(密文)", JsonHelper.Compress(encryptData), joOrgRtn.ToString());
  356. this.saveCenterLog(JsonHelper.Compress(encryptData), joOrgRtn.ToString(), JsonHelper.Compress(data), outPar);
  357. }
  358. }
  359. /// </summary>
  360. /// <param name="funNO"></param>
  361. /// <param name="data"></param>
  362. /// <returns></returns>
  363. public JObject invokeCenterServicePresCir(string funNO, string data)
  364. {
  365. JObject joRtn = new JObject();
  366. string outPar = "";
  367. try
  368. {
  369. if (funNO == "7101")
  370. {
  371. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/uploadChk";
  372. }
  373. else if (funNO == "7102")
  374. {
  375. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxFixmedinsSign";
  376. }
  377. else if (funNO == "7103")
  378. {
  379. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxFileUpld";
  380. }
  381. else if (funNO == "7104")
  382. {
  383. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxUndo";
  384. }
  385. else if (funNO == "7105")
  386. {
  387. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/hospRxDetlQuery";
  388. }
  389. else if (funNO == "7106")
  390. {
  391. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxChkInfoQuery";
  392. }
  393. else if (funNO == "7107")
  394. {
  395. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxSetlInfoQuery";
  396. }
  397. else if (funNO == "7108")
  398. {
  399. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxChkInfoCallback";
  400. }
  401. else if (funNO == "7109")
  402. {
  403. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/rxSetlInfoCallback";
  404. }
  405. else if (funNO == "7112") //电子处方药品目录查询
  406. {
  407. Global.curEvt.URL = Global.inf.PresCir.url + "/fixmedins/circDrugQuery";
  408. }
  409. else
  410. {
  411. Global.curEvt.URL = Global.inf.centerURL;
  412. }
  413. //Global.curEvt.URL = Global.inf.centerURL;
  414. joRtn = invokeCenterServicePresCir(data);
  415. outPar = JsonHelper.Compress(joRtn);
  416. return joRtn;
  417. }
  418. catch (Exception ex)
  419. {
  420. if (joRtn["infcode"] == null)
  421. { joRtn.Add("infcode", -1); }
  422. if (joRtn["err_msg"] == null)
  423. { joRtn.Add("err_msg", "invokeCenterServicePresCir(3):" + ex.Message); }
  424. outPar = JsonHelper.Compress(joRtn);
  425. return joRtn;
  426. }
  427. finally
  428. {
  429. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  430. //this.saveCenterLog(JsonHelper.Compress(data), outPar, JsonHelper.Compress(data), outPar);
  431. }
  432. }
  433. private JObject invokeCenterServicePresCir(string data)
  434. {
  435. string postContent = "";
  436. JObject joRtn = new JObject();
  437. try
  438. {
  439. //创建一个HTTP请求
  440. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  441. //Post请求方式
  442. request.Method = "POST";
  443. //内容类型
  444. request.ContentType = "application/json";
  445. //设置参数,并进行URL编码
  446. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  447. byte[] payload;
  448. //将Json字符串转化为字节
  449. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  450. //设置请求的ContentLength
  451. request.ContentLength = payload.Length;
  452. //发送请求,获得请求流
  453. Stream writer;
  454. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  455. //将请求参数写入流
  456. writer.Write(payload, 0, payload.Length);
  457. writer.Close();//关闭请求流
  458. // String strValue = "";//strValue为http响应所返回的字符流
  459. HttpWebResponse response;
  460. try
  461. {
  462. //获得响应流
  463. response = (HttpWebResponse)request.GetResponse();
  464. }
  465. catch (WebException ex)
  466. {
  467. response = ex.Response as HttpWebResponse;
  468. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  469. }
  470. Stream s = response.GetResponseStream();
  471. StreamReader sRead = new StreamReader(s);
  472. postContent = sRead.ReadToEnd();
  473. sRead.Close();
  474. joRtn = JObject.Parse(postContent);//返回Json数据
  475. return joRtn;
  476. }
  477. catch (Exception ex)
  478. {
  479. postContent = "调用中心服务异常" + ex.Message;
  480. joRtn.Add("infcode", -1);
  481. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  482. return joRtn;
  483. }
  484. }
  485. public JObject DownloadCenterFile(string fileName,string data)
  486. {
  487. string error = string.Empty; int errorCode = 0;
  488. string sRtn = "";
  489. try
  490. {
  491. string filePath = Global.curEvt.path + "\\Download\\" + fileName;
  492. Global.writeLog(filePath);
  493. //获取文件夹路径
  494. int a = filePath.LastIndexOf('\\');
  495. string dirPath = filePath.Substring(0, a);
  496. Global.writeLog(dirPath);
  497. //如果不存在目录,则创建目录
  498. if (!Directory.Exists(dirPath))
  499. {
  500. //创建文件夹
  501. DirectoryInfo dirInfo = Directory.CreateDirectory(dirPath);
  502. }
  503. if (File.Exists(filePath))
  504. {
  505. File.Delete(filePath);
  506. }
  507. FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
  508. //创建一个HTTP请求
  509. Global.curEvt.URL = Global.inf.centerURL;
  510. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  511. //Post请求方式
  512. request.Method = "POST";
  513. //内容类型
  514. request.ContentType = "application/json";
  515. String stamp = TimeStamp.get13().ToString();
  516. string apiName = Global.curEvt.URL.Substring(Global.curEvt.URL.Length - 12);
  517. //设置参数,并进行URL编码
  518. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  519. byte[] payload;
  520. //将Json字符串转化为字节
  521. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  522. //设置请求的ContentLength
  523. request.ContentLength = payload.Length;
  524. Stream writer;
  525. try
  526. {
  527. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  528. }
  529. catch (Exception)
  530. {
  531. writer = null;
  532. errorCode = -100;
  533. error = "连接服务器失败!";
  534. }
  535. //将请求参数写入流
  536. writer.Write(payload, 0, payload.Length);
  537. writer.Close();//关闭请求流
  538. // String strValue = "";//strValue为http响应所返回的字符流
  539. //发送请求并获取相应回应数据
  540. HttpWebResponse response = request.GetResponse() as HttpWebResponse;
  541. //直到request.GetResponse()程序才开始向目标网页发送Post请求
  542. Stream responseStream = response.GetResponseStream();
  543. //创建本地文件写入流
  544. byte[] bArr = new byte[1024];
  545. int iTotalSize = 0;
  546. int size = responseStream.Read(bArr, 0, (int)bArr.Length);
  547. while (size > 0)
  548. {
  549. iTotalSize += size;
  550. fs.Write(bArr, 0, size);
  551. size = responseStream.Read(bArr, 0, (int)bArr.Length);
  552. }
  553. fs.Close();
  554. responseStream.Close();
  555. dynamic joReturn = new JObject();
  556. joReturn.errorCode = errorCode;
  557. joReturn.errorMessage = error;
  558. joReturn.filePath = filePath;
  559. sRtn = joReturn.ToString();
  560. return joReturn;
  561. }
  562. catch (Exception ex)
  563. {
  564. errorCode = -100;
  565. error = ex.Message;
  566. dynamic joReturn = new JObject();
  567. joReturn.errorCode = errorCode;
  568. joReturn.errorMessage = error;
  569. sRtn = joReturn.ToString();
  570. return joReturn;
  571. }
  572. finally
  573. {
  574. Global.writeLog("DownloadCenterFile" + "(" + Global.curEvt.URL + ")", data, sRtn);
  575. }
  576. }
  577. /// <summary>
  578. /// 保存中心交易日志到数据库
  579. /// </summary>
  580. /// <param name="inParam"></param>
  581. /// <param name="outParam"></param>
  582. private void saveCenterLog(string inParam, string outParam,string inParamPlain,string outParamPlain)
  583. {
  584. dynamic joIris = new JObject();
  585. string sRtn = "";
  586. try
  587. {
  588. //解析postContent,插入医保交易日志表
  589. JObject joIn = new JObject(JObject.Parse(inParam));
  590. JObject joOut = new JObject(JObject.Parse(outParam));
  591. JObject joInPlain = new JObject(JObject.Parse(inParamPlain));
  592. JObject joOutPlain = new JObject(JObject.Parse(outParamPlain));
  593. JArray jaParams = new JArray();
  594. JObject joParam = new JObject();
  595. joParam.Add("inParam", JObject.FromObject(joIn));
  596. joParam.Add("outParam", JObject.FromObject(joOut));
  597. joParam.Add("inParamPlain", JObject.FromObject(joInPlain));
  598. joParam.Add("outParamPlain", JObject.FromObject(joOutPlain));
  599. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  600. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  601. joParam.Add("updateUserID", Global.user.ID);
  602. joParam.Add("psn_no", Global.pat.psn_no);
  603. jaParams.Add(joParam);
  604. joIris.code = "09010021";
  605. joIris.Add("params", jaParams);
  606. //InvokeHelper invoker = new InvokeHelper();
  607. sRtn = invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  608. }
  609. catch (Exception ex)
  610. {
  611. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  612. }
  613. }
  614. }
  615. }