InvokeHelper.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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. using System.Runtime.InteropServices;
  26. using PTMedicalInsurance.Forms;
  27. using GMCrypto.Lib;
  28. namespace PTMedicalInsurance.Helper
  29. {
  30. class InvokeHelper
  31. {
  32. private string serviceURL;
  33. private string authorization;
  34. public InvokeHelper()
  35. {
  36. IniFile ini = new IniFile(Global.curEvt.path + @"\CenterServiceURL.ini");
  37. Global.inf.centerURL = ini.ReadValue("CENTER", "url");
  38. Global.inf.uploadURL = ini.ReadValue("CENTER", "upload");
  39. Global.inf.downURL = ini.ReadValue("CENTER", "download");
  40. Global.inf.ecURL = ini.ReadValue("CENTER", "ecToken");
  41. Global.inf.mobilePayURL = ini.ReadValue("CENTER", "mobilePay");
  42. Global.inf.ecPrescURL = ini.ReadValue("CENTER", "prescription");
  43. if (string.IsNullOrEmpty(Global.inf.mobilePayURL))
  44. {
  45. Global.inf.mobilePayURL = "http://10.123.185.12:8080";
  46. }
  47. if (string.IsNullOrEmpty(Global.inf.ecPrescURL))
  48. {
  49. Global.inf.ecPrescURL = "http://10.123.185.12:8080/epc/api";
  50. }
  51. }
  52. #region 内部服务调用
  53. /// <summary>
  54. /// iris服务调用的封装
  55. /// </summary>
  56. /// <param name="data"></param>
  57. /// <returns></returns>
  58. public JObject invokeIrisService(string data, string serviceDesc)
  59. {
  60. string rtn = "", url = "";
  61. JObject joRtn = new JObject();
  62. try
  63. {
  64. //先根据用户请求的uri构造请求地址
  65. url = serviceURL;
  66. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  67. ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  68. //创建Web访问对象
  69. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  70. //把用户传过来的数据转成“UTF-8”的字节流
  71. byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(data);
  72. //添加头部信息
  73. myRequest.Method = "POST";
  74. myRequest.ContentLength = buf.Length;
  75. myRequest.ContentType = "application/json";
  76. myRequest.Headers.Add("Authorization", authorization);
  77. myRequest.MaximumAutomaticRedirections = 1;
  78. myRequest.AllowAutoRedirect = true;
  79. //发送请求
  80. Stream stream = myRequest.GetRequestStream();
  81. stream.Write(buf, 0, buf.Length);
  82. stream.Close();
  83. //获取接口返回值
  84. //通过Web访问对象获取响应内容
  85. HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
  86. rtn = getResponseData(myResponse);
  87. joRtn = JObject.Parse(rtn);
  88. return joRtn;
  89. }
  90. catch (Exception ex)
  91. {
  92. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  93. rtn = JsonConvert.SerializeObject(joRtn);
  94. return joRtn;
  95. }
  96. }
  97. /// <summary>
  98. /// HIS服务调用的封装
  99. /// </summary>
  100. /// <param name="data"></param>
  101. /// <returns></returns>
  102. ///
  103. public JObject invokeHISService(string data, string serviceDesc)
  104. {
  105. JObject joRtn = new JObject();
  106. try
  107. {
  108. //先根据用户请求的uri构造请求地址
  109. serviceURL = string.Format("{0}/{1}", Global.hisConfig.ip, Global.hisConfig.url);
  110. authorization = Global.hisConfig.authorization;
  111. joRtn = invokeIrisService(data, serviceDesc);
  112. return joRtn;
  113. }
  114. catch (Exception ex)
  115. {
  116. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  117. return joRtn;
  118. }
  119. finally
  120. {
  121. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), JsonHelper.Compress(joRtn));
  122. }
  123. }
  124. /// <summary>
  125. /// 医保平台服务调用的封装
  126. /// </summary>
  127. /// <param name="data"></param>
  128. /// <returns></returns>
  129. public JObject invokeInsuService(string data, string serviceDesc)
  130. {
  131. string rtn = "";
  132. JObject joRtn = new JObject();
  133. try
  134. {
  135. //先根据用户请求的uri构造请求地址
  136. serviceURL = string.Format("{0}/{1}", Global.insuConfig.ip, Global.insuConfig.url);
  137. authorization = Global.insuConfig.authorization;
  138. joRtn = invokeIrisService(data, serviceDesc);
  139. rtn = JsonConvert.SerializeObject(joRtn);
  140. //if (serviceDesc == "插入签到信息")
  141. //{
  142. // MessageBox.Show("插入签到信息入参:" + data +"|返回值:"+ rtn.ToString()+"|"+ Global.insuConfig.url);
  143. //}
  144. return joRtn;
  145. }
  146. catch (Exception ex)
  147. {
  148. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  149. rtn = JsonConvert.SerializeObject(joRtn);
  150. return joRtn;
  151. }
  152. finally
  153. {
  154. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), rtn);
  155. }
  156. }
  157. private string getResponseData(HttpWebResponse response)
  158. {
  159. string data = "";
  160. if (response != null)
  161. {
  162. Stream s = response.GetResponseStream();
  163. StreamReader sRead = new StreamReader(s);
  164. data = sRead.ReadToEnd();
  165. sRead.Close();
  166. response.Close();
  167. }
  168. return data;
  169. }
  170. #endregion
  171. #region 医保中心调用
  172. private JObject invokeCenterService(string data)
  173. {
  174. JObject joRtn = new JObject();
  175. try
  176. {
  177. IInvokeCenter center = InvokeCenterFactory.create();
  178. string outputData = "";
  179. string errMsg = "";
  180. int iInt = center.Init(ref errMsg);
  181. if (iInt == 0)
  182. {
  183. iInt = center.Business(data, ref outputData, ref errMsg);
  184. if (iInt == 0 && !string.IsNullOrEmpty(outputData))
  185. {
  186. try
  187. {
  188. joRtn = JObject.Parse(outputData);
  189. }
  190. catch (Exception ex)
  191. {
  192. joRtn.Add("infcode", iInt);
  193. joRtn.Add("err_msg", "返回参数异常:" + outputData);
  194. }
  195. }
  196. else
  197. {
  198. joRtn.Add("infcode", iInt);
  199. joRtn.Add("err_msg", outputData);
  200. return joRtn;
  201. }
  202. return joRtn;
  203. }
  204. else
  205. {
  206. joRtn.Add("infcode", -1);
  207. joRtn.Add("err_msg", "医保动态库初始化失败invokeInitByDLL:" + errMsg);
  208. return joRtn;
  209. }
  210. }
  211. finally
  212. {
  213. Global.writeLog("调用中心:", JsonHelper.Compress(data), joRtn.ToString());
  214. // 保存到服务器
  215. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  216. }
  217. }
  218. private void prepareCallCenter(string funNo)
  219. {
  220. string prefix = Global.inf.centerURL;
  221. switch (funNo)
  222. {
  223. case "9101":
  224. prefix = Global.inf.uploadURL;
  225. break;
  226. case "9102":
  227. prefix = Global.inf.downURL;
  228. break;
  229. default:
  230. prefix = Global.inf.centerURL;
  231. break;
  232. }
  233. Global.curEvt.URL = prefix + funNo;
  234. }
  235. /// <summary>
  236. /// 这个是调用业务服务的invokeCenterService
  237. /// </summary>
  238. /// <param name="funNO"></param>
  239. /// <param name="data"></param>
  240. /// <returns></returns>
  241. public JObject invokeCenterService(string funNO, JObject data)
  242. {
  243. // 动态调试模式
  244. if (Global.curEvt.enabledDebug)
  245. {
  246. CenterResult center = new CenterResult();
  247. center.setTradeNo(funNO);
  248. if (center.ShowDialog() == DialogResult.OK)
  249. {
  250. string outPar = center.returnData;
  251. return JObject.Parse(outPar);
  252. }
  253. }
  254. prepareCallCenter(funNO);
  255. return invokeCenterService(JsonHelper.toJsonString(data));
  256. }
  257. /// <summary>
  258. /// 这个是下载目录用的invokeCenterService
  259. /// </summary>
  260. /// <param name="funNO"></param>
  261. /// <param name="data"></param>
  262. /// <returns></returns>
  263. public JObject invokeCenterService(string funNO, string data)
  264. {
  265. // 动态调试模式
  266. if (Global.curEvt.enabledDebug)
  267. {
  268. CenterResult center = new CenterResult();
  269. center.setTradeNo(funNO);
  270. if (center.ShowDialog() == DialogResult.OK)
  271. {
  272. string outPar = center.returnData;
  273. return JObject.Parse(outPar);
  274. }
  275. }
  276. prepareCallCenter(funNO);
  277. return invokeCenterService(data);
  278. }
  279. /// <summary>
  280. /// 医保目录txt文件下载
  281. /// </summary>
  282. /// <param name="data"></param>
  283. /// <returns></returns>
  284. public JObject DownloadCenterFile(string data)
  285. {
  286. //download file
  287. IInvokeCenter center = InvokeCenterFactory.create();
  288. string outputMsg = "";
  289. JObject joRtn = new JObject();
  290. int rtnCode = center.DownloadFile(data, ref outputMsg);
  291. if(rtnCode==0)
  292. {
  293. joRtn = JObject.Parse(outputMsg);
  294. }
  295. else
  296. {
  297. joRtn.Add("infcode", -1);
  298. joRtn.Add("err_msg", "下载文件失败DownloadFile:" + outputMsg);
  299. }
  300. return joRtn;
  301. }
  302. #endregion
  303. #region 移动
  304. /// <summary>
  305. /// 移动
  306. /// </summary>
  307. /// <param name="funNO"></param>
  308. /// <param name="data"></param>
  309. /// <returns></returns>
  310. public JObject invokeMPService(string funNO, string data)
  311. {
  312. return invokeMPService(funNO, JObject.Parse(data));
  313. }
  314. public JObject invokeMPService(string funNO, JObject joInput)
  315. {
  316. JObject joRtn = new JObject();
  317. String outPar = "";
  318. try
  319. {
  320. string url = "";
  321. switch (funNO)
  322. {
  323. case "6201":
  324. url = "/org/local/api/hos/uldFeeInfo";
  325. break;
  326. case "6202":
  327. url = "/org/local/api/hos/pay_order";
  328. break;
  329. case "6203":
  330. url = "/org/local/api/hos/refund_Order";
  331. break;
  332. case "6301":
  333. url = "/org/local/api/hos/query_order_info";
  334. break;
  335. case "6401":
  336. url = "/org/local/api/hos/revoke_order";
  337. break;
  338. default:
  339. break;
  340. }
  341. EncryptHelper encrypt = new EncryptHelper();
  342. string data = JsonHelper.setMPCenterInpar(funNO, joInput);
  343. // 移动支付地址
  344. Global.curEvt.URL = Global.inf.mobilePayURL + url;
  345. string outputData = "", errMsg = "";
  346. // 动态调试模式
  347. if (Global.curEvt.enabledDebug)
  348. {
  349. CenterResult center = new CenterResult();
  350. center.setTradeNo(funNO);
  351. if (center.ShowDialog() == DialogResult.OK)
  352. {
  353. outPar = center.returnData;
  354. return JObject.Parse(outPar);
  355. }
  356. }
  357. try
  358. {
  359. InvokeRestCenter mobileCenter = new InvokeRestCenter();
  360. int iInt = mobileCenter.Business(data, ref outputData, ref errMsg);
  361. joRtn = JObject.Parse(outputData);
  362. string encData = JsonHelper.getDestValue(joRtn, "encData");
  363. string signData = JsonHelper.getDestValue(joRtn, "signData");
  364. if (!string.IsNullOrEmpty(encData) && !string.IsNullOrEmpty(signData))
  365. {
  366. joRtn.Remove("encData");
  367. joRtn.Remove("signData");
  368. joRtn.Remove("data");
  369. //解密
  370. string decData = encrypt.decrypt(encData);
  371. // 验签
  372. JsonConvert.DefaultSettings = () => new JsonSerializerSettings
  373. {
  374. FloatParseHandling = FloatParseHandling.Decimal
  375. };
  376. joRtn.Add("data", JToken.FromObject(JsonConvert.DeserializeObject(decData)));
  377. bool rtn = encrypt.verify(joRtn, signData);
  378. if (rtn)
  379. {
  380. joRtn = JObject.Parse(decData);
  381. joRtn.Add("success", "True");
  382. }
  383. else
  384. {
  385. Global.writeLog("验签失败,请核查!");
  386. }
  387. }
  388. return joRtn;
  389. }
  390. finally
  391. {
  392. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  393. }
  394. }
  395. catch (Exception ex)
  396. {
  397. if (joRtn["infcode"] == null)
  398. { joRtn.Add("infcode", -1); }
  399. if (joRtn["err_msg"] == null)
  400. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  401. outPar = JsonHelper.Compress(joRtn);
  402. return joRtn;
  403. }
  404. finally
  405. {
  406. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", joInput.ToString(), joRtn.ToString());
  407. this.saveCenterLog(joInput.ToString(), joRtn.ToString(), joInput.ToString(), joRtn.ToString());
  408. }
  409. }
  410. /// <summary>
  411. /// 保存中心交易日志到数据库
  412. /// </summary>
  413. /// <param name="inParam"></param>
  414. /// <param name="outParam"></param>
  415. /// <param name="inParamPlain"></param>
  416. /// <param name="outParamPlain"></param>
  417. private void saveCenterLog(string inParam, string outParam, string inParamPlain, string outParamPlain)
  418. {
  419. dynamic joIris = new JObject();
  420. string sRtn = "";
  421. try
  422. {
  423. //解析postContent,插入医保交易日志表
  424. JObject joInParam = new JObject(JObject.Parse(inParam));
  425. //解包
  426. JObject joIn = Utils.removeWrapper(joInParam);
  427. JObject joOut = new JObject(JObject.Parse(outParam));
  428. JObject joInPlain = new JObject(JObject.Parse(inParamPlain));
  429. JObject joOutPlain = new JObject(JObject.Parse(outParamPlain));
  430. JArray jaParams = new JArray();
  431. JObject joParam = new JObject();
  432. joParam.Add("inParam", JObject.FromObject(joIn));
  433. joParam.Add("outParam", JObject.FromObject(joOut));
  434. joParam.Add("inParamPlain", JObject.FromObject(joInPlain));
  435. joParam.Add("outParamPlain", JObject.FromObject(joOutPlain));
  436. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  437. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  438. joParam.Add("updateUserID", Global.user.ID);
  439. joParam.Add("psn_no", Global.pat.psn_no);
  440. jaParams.Add(joParam);
  441. joIris.code = "09010021";
  442. joIris.Add("params", jaParams);
  443. //InvokeHelper invoker = new InvokeHelper();
  444. sRtn = invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  445. }
  446. catch (Exception ex)
  447. {
  448. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  449. Global.writeLog_Iris("保存日志异常:" + sRtn.ToString());
  450. }
  451. }
  452. #endregion
  453. #region 电子处方
  454. /// </summary>
  455. /// <param name="funNO"></param>
  456. /// <param name="data"></param>
  457. /// <returns></returns>
  458. public JObject invokeEPCenterService(string funNO, string data)
  459. {
  460. JObject joRtn = new JObject();
  461. string outPar = "";
  462. try
  463. {
  464. Global.curEvt.URL = Global.inf.ecPrescURL;
  465. switch (funNO)
  466. {
  467. case "7101":
  468. {
  469. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/uploadChk";
  470. break;
  471. }
  472. case "7102":
  473. {
  474. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxFixmedinsSign";
  475. break;
  476. }
  477. case "7103":
  478. {
  479. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxFileUpld";
  480. break;
  481. }
  482. case "7104":
  483. {
  484. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxUndo";
  485. break;
  486. }
  487. case "7105":
  488. {
  489. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/hospRxDetlQuery";
  490. break;
  491. }
  492. case "7106":
  493. {
  494. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxChkInfoQuery";
  495. break;
  496. }
  497. case "7107":
  498. {
  499. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxSetlInfoQuery";
  500. break;
  501. }
  502. case "7108":
  503. {
  504. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxChkInfoCallback";
  505. break;
  506. }
  507. case "7109":
  508. {
  509. Global.curEvt.URL = Global.curEvt.URL + "/fixmedins/rxSetlInfoCallback";
  510. break;
  511. }
  512. }
  513. //Global.curEvt.URL = Global.inf.centerURL;
  514. joRtn = invokeEPCenterService(data);
  515. outPar = JsonHelper.Compress(joRtn);
  516. return joRtn;
  517. }
  518. catch (Exception ex)
  519. {
  520. if (joRtn["infcode"] == null)
  521. { joRtn.Add("infcode", -1); }
  522. if (joRtn["err_msg"] == null)
  523. { joRtn.Add("err_msg", "invokeCenterServicePresCir(3):" + ex.Message); }
  524. outPar = JsonHelper.Compress(joRtn);
  525. return joRtn;
  526. }
  527. finally
  528. {
  529. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  530. //this.saveCenterLog(JsonHelper.Compress(data), outPar, JsonHelper.Compress(data), outPar);
  531. }
  532. }
  533. /// <summary>
  534. /// 医保电子处方流转调用服务
  535. /// </summary>
  536. /// <param name="data"></param>
  537. /// <returns></returns>
  538. private JObject invokeEPCenterService(string data)
  539. {
  540. string postContent = "";
  541. JObject joRtn = new JObject();
  542. try
  543. {
  544. string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  545. string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  546. //内容类型
  547. //Signer signer = new Signer();
  548. //signer.Key = Global.inf.privateKey; //应用编码
  549. //signer.Secret = Global.inf.secretKey; //secretKey 私钥
  550. //HttpRequest Resquest = new HttpRequest("POST", new Uri(Global.curEvt.URL));
  551. //Resquest.headers.Add("charset", "UTF-8");
  552. //Resquest.headers.Add("x-hw-id", signer.Key);
  553. //Resquest.headers.Add("x-tif-timestamp", timestamp);
  554. //Resquest.headers.Add("x-tif-passid", signer.Key);
  555. //Resquest.headers.Add("x-tif-nonce", nonce);
  556. //Resquest.body = signData;
  557. //HttpWebRequest req = signer.Sign(Resquest);
  558. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  559. req.Method = "POST";
  560. req.ContentType = "application/json;charset=utf8";
  561. req.Timeout = 5 * 10000;
  562. try
  563. {
  564. var writer = new StreamWriter(req.GetRequestStream());
  565. writer.Write(data);
  566. writer.Flush();
  567. HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
  568. StreamReader reader = new StreamReader(resp.GetResponseStream());
  569. string RtnStr = reader.ReadToEnd();
  570. joRtn = JObject.Parse(RtnStr);
  571. // 解密返回值
  572. EncryptHelper encrypt = new EncryptHelper(Global.inf.appId, Global.inf.secretKey, Global.inf.publicKey, Global.inf.privateKey);
  573. string encData = JsonHelper.getDestValue(joRtn, "encData");
  574. string signData = JsonHelper.getDestValue(joRtn, "signData");
  575. Global.writeLog("【密文出参】:\r\n" + RtnStr);
  576. if (!string.IsNullOrEmpty(encData) && !string.IsNullOrEmpty(signData))
  577. {
  578. joRtn.Remove("encData");
  579. joRtn.Remove("signData");
  580. joRtn.Remove("data");
  581. //解密
  582. string decData = encrypt.decrypt(encData);
  583. // 验签
  584. JsonConvert.DefaultSettings = () => new JsonSerializerSettings
  585. {
  586. FloatParseHandling = FloatParseHandling.Decimal
  587. };
  588. joRtn.Add("data", JToken.FromObject(JsonConvert.DeserializeObject(decData)));
  589. bool rtn = encrypt.verify(joRtn, signData);
  590. if (rtn)
  591. {
  592. Global.writeLog("【明文出参】:\r\n" + decData);
  593. joRtn = JObject.Parse(decData);
  594. joRtn.Add("code", 0);
  595. joRtn.Add("message", "成功");
  596. }
  597. else
  598. {
  599. Global.writeLog("验签失败,请核查!");
  600. }
  601. }
  602. return joRtn;
  603. }
  604. catch (WebException e)
  605. {
  606. HttpWebResponse resp = (HttpWebResponse)e.Response;
  607. if (resp != null)
  608. {
  609. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常(a)", new StreamReader(resp.GetResponseStream()).ReadToEnd() + "异常内容:" + e.Message);
  610. }
  611. else
  612. {
  613. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常(b)", e.Message);
  614. }
  615. }
  616. }
  617. catch (Exception ex)
  618. {
  619. postContent = "调用中心服务异常" + ex.Message;
  620. joRtn.Add("infcode", -1);
  621. joRtn.Add("err_msg", "invokeCenterService(Exception_Last):" + ex.Message);
  622. return joRtn;
  623. }
  624. }
  625. #endregion
  626. }
  627. }