InvokeHelper.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  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 AnHuiMI.Forms;
  27. using AnHuiMI.Common;
  28. using static System.Net.WebRequestMethods;
  29. using File = System.IO.File;
  30. using GMCrypto.Lib;
  31. namespace PTMedicalInsurance.Helper
  32. {
  33. public class InvokeHelper
  34. {
  35. private string serviceURL;
  36. private string authorization;
  37. ComputerInfo comp = new ComputerInfo();
  38. /// <summary>
  39. /// 初始化函数
  40. /// </summary>
  41. /// <param name="fixmedins_code"></param>
  42. /// <param name="infosyscode"></param>
  43. /// <param name="infosyssign"></param>
  44. /// <param name="url"></param>
  45. /// <param name="pErrMsg"></param>
  46. /// <returns></returns>
  47. [DllImport("CHSInterface.dll", EntryPoint = "Init", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] //, ExactSpelling = false, CallingConvention = CallingConvention.StdCall
  48. static extern int Init(string fixmedins_code, string infosyscode, string infosyssign, string url, StringBuilder pErrMsg);
  49. /// <summary>
  50. /// 文件下载函数
  51. /// </summary>
  52. /// <param name="fixmedins_code"></param>
  53. /// <param name="infosyscode"></param>
  54. /// <param name="infosyssign"></param>
  55. /// <param name="inputData"></param>
  56. /// <param name="outputData"></param>
  57. /// <param name="pErrMsg"></param>
  58. /// <returns></returns>
  59. [DllImport("CHSInterface.dll", EntryPoint = "DownloadFile", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] //, ExactSpelling = false, CallingConvention = CallingConvention.StdCall
  60. static extern int DownloadFile(string fixmedins_code, string infosyscode, string infosyssign, string inputData, StringBuilder outputData, StringBuilder pErrMsg);
  61. /// <summary>
  62. /// 文件上传函数
  63. /// </summary>
  64. /// <param name="fixmedins_code"></param>
  65. /// <param name="infosyscode"></param>
  66. /// <param name="infosyssign"></param>
  67. /// <param name="inputData"></param>
  68. /// <param name="outputData"></param>
  69. /// <param name="pErrMsg"></param>
  70. /// <returns></returns>
  71. [DllImport("CHSInterface.dll", EntryPoint = "UploadFile", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] //, ExactSpelling = false, CallingConvention = CallingConvention.StdCall
  72. static extern int UploadFile(string fixmedins_code, string infosyscode, string infosyssign, string fileName,string inputData, StringBuilder outputData, StringBuilder pErrMsg);
  73. /// <summary>
  74. /// 通用业务函数
  75. /// </summary>
  76. /// <param name="fixmedins_code"></param>
  77. /// <param name="infosyscode"></param>
  78. /// <param name="infosyssign"></param>
  79. /// <param name="inputData"></param>
  80. /// <param name="outputData"></param>
  81. /// <param name="errmsg"></param>
  82. /// <returns></returns>
  83. [DllImport("CHSInterface.dll", EntryPoint = "BusinessHandle", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] //, ExactSpelling = false, CallingConvention = CallingConvention.StdCall
  84. static extern int BusinessHandle(string fixmedins_code, string infosyscode, string infosyssign, string inputData, StringBuilder outputData, StringBuilder errmsg);
  85. /// <summary>
  86. /// 通用业务函数
  87. /// </summary>
  88. /// <param name="fixmedins_code"></param>
  89. /// <param name="infosyscode"></param>
  90. /// <param name="infosyssign"></param>
  91. /// <param name="inputData"></param>
  92. /// <param name="outputData"></param>
  93. /// <param name="errmsg"></param>
  94. /// <returns></returns>
  95. [DllImport("CHSInterface.dll", EntryPoint = "BusinessHandleW", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] //, ExactSpelling = false, CallingConvention = CallingConvention.StdCall
  96. static extern int BusinessHandleW(StringBuilder fixmedins_code, StringBuilder infosyscode, StringBuilder infosyssign, StringBuilder inputData, StringBuilder outputData, StringBuilder errmsg);
  97. public InvokeHelper()
  98. {
  99. LoadCenterURL(false);
  100. }
  101. private void LoadCenterURL(bool reload)
  102. {
  103. IniFile ini = new IniFile(Global.curEvt.path + @"\CenterServiceURL.ini");
  104. Global.inf.uploadURL = tools.getDestPosStrBySpliter(Global.inf.centerURL2, 1);
  105. Global.inf.downURL = tools.getDestPosStrBySpliter(Global.inf.centerURL2, 2);
  106. Global.inf.ecURL = tools.getDestPosStrBySpliter(Global.inf.centerURL2, 3);
  107. if (reload)
  108. {
  109. Global.inf.mobilePayURL = ini.ReadValue("CENTER", "mobilePay");
  110. Global.inf.ecPrescURL = ini.ReadValue("CENTER", "prescription");
  111. // 移动支付
  112. if (string.IsNullOrEmpty(Global.inf.mobilePayURL))
  113. {
  114. Global.inf.mobilePayURL = "http://10.66.159.55:7080";
  115. }
  116. // 电子处方
  117. if (string.IsNullOrEmpty(Global.inf.ecPrescURL))
  118. {
  119. Global.inf.ecPrescURL = "http://10.123.185.12:8080/epc/api";
  120. }
  121. }
  122. }
  123. #region iris
  124. /// <summary>
  125. /// iris服务调用的封装
  126. /// </summary>
  127. /// <param name="data"></param>
  128. /// <returns></returns>
  129. public JObject invokeIrisService(string data, string serviceDesc)
  130. {
  131. string rtn = "", url = "";
  132. JObject joRtn = new JObject();
  133. try
  134. {
  135. //先根据用户请求的uri构造请求地址
  136. url = serviceURL;
  137. ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  138. ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  139. //创建Web访问对象
  140. HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
  141. //把用户传过来的数据转成“UTF-8”的字节流
  142. byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(data);
  143. //添加头部信息
  144. myRequest.Method = "POST";
  145. myRequest.ContentLength = buf.Length;
  146. myRequest.ContentType = "application/json";
  147. myRequest.Headers.Add("Authorization", authorization);
  148. myRequest.MaximumAutomaticRedirections = 1;
  149. myRequest.AllowAutoRedirect = true;
  150. //发送请求
  151. Stream stream = myRequest.GetRequestStream();
  152. stream.Write(buf, 0, buf.Length);
  153. stream.Close();
  154. //获取接口返回值
  155. //通过Web访问对象获取响应内容
  156. HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
  157. rtn = getResponseData(myResponse);
  158. joRtn = JObject.Parse(rtn);
  159. return joRtn;
  160. }
  161. catch (Exception ex)
  162. {
  163. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  164. rtn = JsonConvert.SerializeObject(joRtn);
  165. return joRtn;
  166. }
  167. }
  168. /// <summary>
  169. /// HIS服务调用的封装
  170. /// </summary>
  171. /// <param name="data"></param>
  172. /// <returns></returns>
  173. ///
  174. public JObject invokeHISService(string data, string serviceDesc)
  175. {
  176. JObject joRtn = new JObject();
  177. try
  178. {
  179. //先根据用户请求的uri构造请求地址
  180. serviceURL = string.Format("{0}/{1}", Global.hisConfig.ip, Global.hisConfig.url);
  181. authorization = Global.hisConfig.authorization;
  182. joRtn = invokeIrisService(data, serviceDesc);
  183. return joRtn;
  184. }
  185. catch (Exception ex)
  186. {
  187. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  188. return joRtn;
  189. }
  190. finally
  191. {
  192. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), JsonHelper.Compress(joRtn));
  193. }
  194. }
  195. /// <summary>
  196. /// 医保平台服务调用的封装
  197. /// </summary>
  198. /// <param name="data"></param>
  199. /// <returns></returns>
  200. public JObject invokeInsuService(string data, string serviceDesc)
  201. {
  202. string rtn = "";
  203. JObject joRtn = new JObject();
  204. try
  205. {
  206. //先根据用户请求的uri构造请求地址
  207. serviceURL = string.Format("{0}/{1}", Global.insuConfig.ip, Global.insuConfig.url);
  208. authorization = Global.insuConfig.authorization;
  209. joRtn = invokeIrisService(data, serviceDesc);
  210. rtn = JsonConvert.SerializeObject(joRtn);
  211. //if (serviceDesc == "插入签到信息")
  212. //{
  213. // MessageBox.Show("插入签到信息入参:" + data +"|返回值:"+ rtn.ToString()+"|"+ Global.insuConfig.url);
  214. //}
  215. return joRtn;
  216. }
  217. catch (Exception ex)
  218. {
  219. joRtn = JsonHelper.setExceptionJson(-1, serviceDesc, ex.Message);
  220. rtn = JsonConvert.SerializeObject(joRtn);
  221. return joRtn;
  222. }
  223. finally
  224. {
  225. Global.writeLog_Iris(serviceDesc + "(" + serviceURL + ")" + "Authorization:" + (authorization), JsonHelper.Compress(data), rtn);
  226. }
  227. }
  228. #endregion
  229. #region 医保核心业务
  230. /// <summary>
  231. /// 医保中心Post服务调用封装
  232. /// </summary>
  233. /// <param name="data"></param>
  234. /// <returns></returns>
  235. private JObject invokeCenterService(string data)
  236. {
  237. string postContent = "";
  238. JObject joRtn = new JObject();
  239. try
  240. {
  241. //Global.writeLog(string.Format("调用中心{0}接口入参:{1}",data, Global.curEvt.URL));
  242. //创建一个HTTP请求
  243. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  244. //Post请求方式
  245. request.Method = "POST";
  246. //string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  247. //string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  248. //string BusinessID = Global.inf.BusinessID; //服务商ID
  249. //string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  250. //string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  251. //内容类型
  252. request.ContentType = "application/json;charset=UTF-8";
  253. //昆明增加头部信息
  254. //string sTemp = timestamp + BusinessID + nonce;
  255. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  256. //string signature = Encrypt.SHA256EncryptStr(sTemp);
  257. //request.Headers.Add("hsf_signature", signature);
  258. //request.Headers.Add("hsf_timestamp", timestamp);
  259. //request.Headers.Add("hsf_nonce", nonce);
  260. //request.Headers.Add("fixmedins_code", InsuHosID);
  261. //request.Headers.Add("infosyscode", CreditID);
  262. //设置参数,并进行URL编码
  263. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  264. byte[] payload;
  265. //将Json字符串转化为字节
  266. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  267. //设置请求的ContentLength
  268. request.ContentLength = payload.Length;
  269. //发送请求,获得请求流
  270. Stream writer;
  271. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  272. //将请求参数写入流
  273. writer.Write(payload, 0, payload.Length);
  274. writer.Close();//关闭请求流
  275. // String strValue = "";//strValue为http响应所返回的字符流
  276. HttpWebResponse response = null;
  277. try
  278. {
  279. //获得响应流
  280. response = (HttpWebResponse)request.GetResponse();
  281. }
  282. catch (WebException ex)
  283. {
  284. // return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  285. HttpWebResponse res = (HttpWebResponse)ex.Response;
  286. Stream myResponseStream = res.GetResponseStream();
  287. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
  288. string retString = myStreamReader.ReadToEnd();
  289. return JsonHelper.setExceptionJson(-99, "获得响应流异常", retString);
  290. }
  291. postContent = getResponseData(response);
  292. joRtn = JObject.Parse(postContent);//返回Json数据
  293. if (joRtn.ContainsKey("body"))
  294. {
  295. joRtn = (JObject)joRtn.GetValue("body");
  296. }
  297. return joRtn;
  298. }
  299. catch (Exception ex)
  300. {
  301. postContent = "调用中心服务异常" + ex.Message;
  302. joRtn.Add("infcode", -1);
  303. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  304. return joRtn;
  305. }
  306. }
  307. /// <summary>
  308. /// 医保中心慢特病Post服务调用封装
  309. /// </summary>
  310. /// <param name="data"></param>
  311. /// <returns></returns>
  312. private JObject invokeCenterServiceMB(string data)
  313. {
  314. string postContent = "";
  315. JObject joRtn = new JObject();
  316. try
  317. {
  318. //Global.writeLog(string.Format("调用中心{0}接口入参:{1}",data, Global.curEvt.URL));
  319. //创建一个HTTP请求
  320. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  321. //Post请求方式
  322. request.Method = "POST";
  323. //string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  324. //string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  325. //string BusinessID = Global.inf.BusinessID; //服务商ID
  326. //string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  327. //string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  328. //内容类型
  329. request.ContentType = "application/json;charset=UTF-8";
  330. //昆明增加头部信息
  331. //string sTemp = timestamp + BusinessID + nonce;
  332. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  333. //string signature = Encrypt.SHA256EncryptStr(sTemp);
  334. //request.Headers.Add("hsf_signature", signature);
  335. //request.Headers.Add("hsf_timestamp", timestamp);
  336. //request.Headers.Add("hsf_nonce", nonce);
  337. //request.Headers.Add("fixmedins_code", InsuHosID);
  338. //request.Headers.Add("infosyscode", CreditID);
  339. //设置参数,并进行URL编码
  340. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  341. byte[] payload;
  342. //将Json字符串转化为字节
  343. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  344. //设置请求的ContentLength
  345. request.ContentLength = payload.Length;
  346. //发送请求,获得请求流
  347. Stream writer;
  348. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  349. //将请求参数写入流
  350. writer.Write(payload, 0, payload.Length);
  351. writer.Close();//关闭请求流
  352. // String strValue = "";//strValue为http响应所返回的字符流
  353. HttpWebResponse response = null;
  354. try
  355. {
  356. //获得响应流
  357. response = (HttpWebResponse)request.GetResponse();
  358. }
  359. catch (WebException ex)
  360. {
  361. // return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  362. HttpWebResponse res = (HttpWebResponse)ex.Response;
  363. Stream myResponseStream = res.GetResponseStream();
  364. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
  365. string retString = myStreamReader.ReadToEnd();
  366. return JsonHelper.setExceptionJson(-99, "获得响应流异常", retString);
  367. }
  368. postContent =SMUtil.AESDecrypt(getResponseData(response), Global.inf.MBkey); //解密后转换Json
  369. joRtn = JObject.Parse(postContent);//返回Json数据
  370. if (joRtn.ContainsKey("body"))
  371. {
  372. joRtn = (JObject)joRtn.GetValue("body");
  373. }
  374. return joRtn;
  375. }
  376. catch (Exception ex)
  377. {
  378. postContent = "调用中心服务异常" + ex.Message;
  379. joRtn.Add("infcode", -1);
  380. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  381. return joRtn;
  382. }
  383. }
  384. /// <summary>
  385. /// 这个是调用业务服务的invokeCenterService
  386. /// </summary>
  387. /// <param name="funNO"></param>
  388. /// <param name="data"></param>
  389. /// <returns></returns>
  390. public JObject invokeCenterService(string funNO, JObject data)
  391. {
  392. JObject joRtn = new JObject();
  393. string outPar = "";
  394. try
  395. {
  396. // 动态调试模式
  397. if (Global.curEvt.enabledDebug)
  398. {
  399. CenterResult center = new CenterResult();
  400. center.setTradeNo(funNO);
  401. if (center.ShowDialog() == DialogResult.OK)
  402. {
  403. outPar = center.returnData;
  404. return JObject.Parse(outPar);
  405. }
  406. }
  407. setCenterURL(funNO);
  408. joRtn = invokeCenterService(data.ToString());
  409. outPar = JsonHelper.Compress(joRtn);
  410. return joRtn;
  411. }
  412. catch (Exception ex)
  413. {
  414. if (joRtn["infcode"] == null)
  415. { joRtn.Add("infcode", -1); }
  416. if (joRtn["err_msg"] == null)
  417. { joRtn.Add("err_msg", "invokeCenterService(2):" + ex.Message); }
  418. outPar = JsonHelper.Compress(joRtn);
  419. return joRtn;
  420. }
  421. finally
  422. {
  423. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  424. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  425. }
  426. }
  427. /// <summary>
  428. /// 这个是下载目录用的invokeCenterService
  429. /// </summary>
  430. /// <param name="funNO"></param>
  431. /// <param name="data"></param>
  432. /// <returns></returns>
  433. public JObject invokeCenterService(string funNO, string data)
  434. {
  435. JObject joRtn = new JObject();
  436. try
  437. {
  438. // 动态调试模式
  439. if (Global.curEvt.enabledDebug)
  440. {
  441. CenterResult center = new CenterResult();
  442. center.setTradeNo(funNO);
  443. if (center.ShowDialog() == DialogResult.OK)
  444. {
  445. string outPar = center.returnData;
  446. return JObject.Parse(outPar);
  447. }
  448. }
  449. setCenterURL(funNO);
  450. joRtn = invokeCenterService(data);
  451. return joRtn;
  452. }
  453. catch (Exception ex)
  454. {
  455. if (joRtn["infcode"] == null)
  456. { joRtn.Add("infcode", -1); }
  457. if (joRtn["err_msg"] == null)
  458. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  459. return joRtn;
  460. }
  461. finally
  462. {
  463. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  464. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  465. }
  466. }
  467. /// <summary>
  468. /// 这个是合肥慢病用药查询用的invokeCenterService
  469. /// </summary>
  470. /// <param name="funNO"></param>
  471. /// <param name="data"></param>
  472. /// <returns></returns>
  473. public JObject invokeMBCenterService(string funNO, string data)
  474. {
  475. JObject joRtn = new JObject();
  476. try
  477. {
  478. // 动态调试模式
  479. if (Global.curEvt.enabledDebug)
  480. {
  481. CenterResult center = new CenterResult();
  482. center.setTradeNo(funNO);
  483. if (center.ShowDialog() == DialogResult.OK)
  484. {
  485. string outPar = center.returnData;
  486. return JObject.Parse(outPar);
  487. }
  488. }
  489. Global.curEvt.URL = "http://10.67.241.148:8080/api/definition/send";
  490. joRtn = invokeCenterServiceMB(data);
  491. return joRtn;
  492. }
  493. catch (Exception ex)
  494. {
  495. if (joRtn["infcode"] == null)
  496. { joRtn.Add("infcode", -1); }
  497. if (joRtn["err_msg"] == null)
  498. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  499. return joRtn;
  500. }
  501. finally
  502. {
  503. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  504. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  505. }
  506. }
  507. /// <summary>
  508. /// 这个是下载目录用的invokeCenterService
  509. /// </summary>
  510. /// <param name="funNO"></param>
  511. /// <param name="data"></param>
  512. /// <returns></returns>
  513. public JObject invokeCenterServiceF(string funNO, string data)
  514. {
  515. JObject joRtn = new JObject();
  516. try
  517. {
  518. // 动态调试模式
  519. if (Global.curEvt.enabledDebug)
  520. {
  521. CenterResult center = new CenterResult();
  522. center.setTradeNo(funNO);
  523. if (center.ShowDialog() == DialogResult.OK)
  524. {
  525. string outPar = center.returnData;
  526. return JObject.Parse(outPar);
  527. }
  528. }
  529. Global.curEvt.URL = comp.getFunNoInsuURL(funNO);
  530. //setCenterURL(funNO);
  531. joRtn = invokeCenterService(data);
  532. return joRtn;
  533. }
  534. catch (Exception ex)
  535. {
  536. if (joRtn["infcode"] == null)
  537. { joRtn.Add("infcode", -1); }
  538. if (joRtn["err_msg"] == null)
  539. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  540. return joRtn;
  541. }
  542. finally
  543. {
  544. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  545. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  546. }
  547. }
  548. #endregion
  549. private string getResponseData(HttpWebResponse response) {
  550. string data = "";
  551. if (response != null)
  552. {
  553. Stream s = response.GetResponseStream();
  554. StreamReader sRead = new StreamReader(s);
  555. data = sRead.ReadToEnd();
  556. sRead.Close();
  557. response.Close();
  558. }
  559. return data;
  560. }
  561. /// <summary>
  562. /// 调用医保动态库文件下载函数 CM 20220925
  563. /// </summary>
  564. /// <param name="fixmedins_code"></param>
  565. /// <param name="infosyscode"></param>
  566. /// <param name="infosyssign"></param>
  567. /// <param name="inputData"></param>
  568. /// <param name="outputData"></param>
  569. /// <param name="pErrMsg"></param>
  570. /// <returns>0或小于0</returns>
  571. private int invokeDownloadFileByDLL(string fixmedins_code, string infosyscode, string infosyssign, string inputData, ref string outputData, ref string pErrMsg)
  572. {
  573. pErrMsg = "";
  574. outputData = "";
  575. try
  576. {
  577. StringBuilder errmsgSb = new StringBuilder(4096);
  578. StringBuilder outSb = new StringBuilder(40960);
  579. int pRtn = DownloadFile(fixmedins_code, infosyscode, infosyssign, inputData, outSb, errmsgSb);
  580. if (pRtn < 0)
  581. {
  582. pErrMsg = errmsgSb.ToString();
  583. return -1;
  584. }
  585. else
  586. {
  587. outputData = outSb.ToString();
  588. }
  589. return pRtn;
  590. }
  591. catch (Exception ex)
  592. {
  593. pErrMsg = "invokeInitByDLL.DownloadFile 异常:" + ex.Message;
  594. return -1;
  595. }
  596. finally
  597. {
  598. Global.writeLog("invokeInitByDLL.DownloadFile 医保动态库文件下载函数", inputData, outputData);
  599. }
  600. }
  601. private void setCenterURL(string funNo)
  602. {
  603. string prefix = Global.inf.centerURL;
  604. // 环境
  605. LoadCenterURL(true);
  606. switch (funNo)
  607. {
  608. //case "4101A":
  609. case "3101":
  610. case "3102":
  611. case "3103":
  612. prefix = "http://10.66.155.173:8086/1.0.0/hsa-fsi-";
  613. break;
  614. case "10001":
  615. prefix = "http://10.67.187.46:8000/v1/pb/op/opRiskTips";
  616. break;
  617. default:
  618. prefix = Global.inf.centerURL;
  619. break;
  620. }
  621. //移动支付
  622. if (funNo.StartsWith("62") || funNo.StartsWith("63") || funNo.StartsWith("64"))
  623. {
  624. prefix = Global.inf.mobilePayURL; //测试
  625. }
  626. Global.curEvt.URL = prefix + funNo;
  627. }
  628. #region 移动支付
  629. /// <summary>
  630. /// 移动
  631. /// </summary>
  632. /// <param name="funNO"></param>
  633. /// <param name="data"></param>
  634. /// <returns></returns>
  635. ///
  636. public JObject invokeMPService(string funNO, string data)
  637. {
  638. return invokeMPService(funNO,JObject.Parse(data));
  639. }
  640. public JObject invokeMPService(string funNO, JObject joInput)
  641. {
  642. JObject joRtn = new JObject();
  643. String outPar = "";
  644. try
  645. {
  646. LoadCenterURL(true);
  647. string url = "";
  648. switch (funNO)
  649. {
  650. case "6201":
  651. url = "/org/local/api/hos/uldFeeInfo";
  652. break;
  653. case "6202":
  654. url = "/org/local/api/hos/pay_order";
  655. break;
  656. case "6203":
  657. url = "/org/local/api/hos/refund_Order";
  658. break;
  659. case "6301":
  660. url = "/org/local/api/hos/query_order_info";
  661. break;
  662. case "6401":
  663. url = "/org/local/api/hos/revoke_order";
  664. break;
  665. default:
  666. break;
  667. }
  668. EncryptHelper encrypt = new EncryptHelper();
  669. string data = JsonHelper.setMPCenterInpar(funNO, joInput);
  670. // 移动支付地址
  671. Global.curEvt.URL = Global.inf.mobilePayURL + url;
  672. // 动态调试模式
  673. if (Global.curEvt.enabledDebug)
  674. {
  675. CenterResult center = new CenterResult();
  676. center.setTradeNo(funNO);
  677. if (center.ShowDialog() == DialogResult.OK)
  678. {
  679. outPar = center.returnData;
  680. return JObject.Parse(outPar);
  681. }
  682. }
  683. try
  684. {
  685. joRtn = invokeCenterService(data);
  686. Global.writeLog(funNO + "【密文出参】:\r\n" + joRtn.ToString());
  687. string encData = JsonHelper.getDestValue(joRtn, "encData");
  688. string signData = JsonHelper.getDestValue(joRtn, "signData");
  689. if (!string.IsNullOrEmpty(encData) && !string.IsNullOrEmpty(signData))
  690. {
  691. joRtn.Remove("encData");
  692. joRtn.Remove("signData");
  693. joRtn.Remove("data");
  694. //解密
  695. string decData = encrypt.decrypt(encData);
  696. // 验签
  697. JsonConvert.DefaultSettings = () => new JsonSerializerSettings
  698. {
  699. FloatParseHandling = FloatParseHandling.Decimal
  700. };
  701. joRtn.Add("data", JToken.FromObject(JsonConvert.DeserializeObject(decData)));
  702. bool rtn = encrypt.verify(joRtn, signData);
  703. if (rtn)
  704. {
  705. Global.writeLog("验签通过!");
  706. }
  707. else
  708. {
  709. Global.writeLog("验签失败,请核查!");
  710. }
  711. if (!string.IsNullOrEmpty(decData))
  712. {
  713. Global.writeLog(funNO + "【明文出参】:\r\n" + decData);
  714. joRtn = JObject.Parse(decData);
  715. joRtn.Add("success", "True");
  716. }
  717. }
  718. return joRtn;
  719. }
  720. finally
  721. {
  722. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  723. }
  724. }
  725. catch (Exception ex)
  726. {
  727. if (joRtn["success"] == null)
  728. { joRtn.Add("success", "false"); }
  729. if (joRtn["message"] == null)
  730. { joRtn.Add("message", "invokeCenterService(3):" + ex.Message); }
  731. if (joRtn["infcode"] == null)
  732. { joRtn.Add("infcode", -1); }
  733. if (joRtn["err_msg"] == null)
  734. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  735. outPar = JsonHelper.Compress(joRtn);
  736. return joRtn;
  737. }
  738. finally
  739. {
  740. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", joInput.ToString(), joRtn.ToString());
  741. this.saveCenterLog(joInput.ToString(), joRtn.ToString(), joInput.ToString(), joRtn.ToString());
  742. }
  743. }
  744. #endregion
  745. #region 处方流转
  746. /// <summary>
  747. /// 医保电子处方流转调用服务
  748. /// </summary>
  749. /// <param name="data"></param>
  750. /// <returns></returns>
  751. private JObject invokeCenterServicePresCir(string data)
  752. {
  753. string postContent = "";
  754. JObject joRtn = new JObject();
  755. try
  756. {
  757. Global.writeLog(string.Format("调用中心{0}接口入参:{1}", data, Global.curEvt.URL));
  758. //创建一个HTTP请求
  759. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  760. //Post请求方式
  761. request.Method = "POST";
  762. //string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  763. //string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  764. //string BusinessID = Global.inf.BusinessID; //服务商ID
  765. //string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  766. //string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  767. //内容类型
  768. request.ContentType = "application/json;charset=UTF-8";
  769. //昆明增加头部信息
  770. //string sTemp = timestamp + BusinessID + nonce;
  771. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  772. //string signature = Encrypt.SHA256EncryptStr(sTemp);
  773. //request.Headers.Add("hsf_signature", signature);
  774. //request.Headers.Add("hsf_timestamp", timestamp);
  775. //request.Headers.Add("hsf_nonce", nonce);
  776. //request.Headers.Add("fixmedins_code", InsuHosID);
  777. //request.Headers.Add("infosyscode", CreditID);
  778. //设置参数,并进行URL编码
  779. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  780. byte[] payload;
  781. //将Json字符串转化为字节
  782. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  783. //设置请求的ContentLength
  784. request.ContentLength = payload.Length;
  785. //发送请求,获得请求流
  786. Stream writer;
  787. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  788. //将请求参数写入流
  789. writer.Write(payload, 0, payload.Length);
  790. writer.Close();//关闭请求流
  791. // String strValue = "";//strValue为http响应所返回的字符流
  792. HttpWebResponse response = null;
  793. try
  794. {
  795. //获得响应流
  796. response = (HttpWebResponse)request.GetResponse();
  797. }
  798. catch (WebException ex)
  799. {
  800. // return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  801. HttpWebResponse res = (HttpWebResponse)ex.Response;
  802. Stream myResponseStream = res.GetResponseStream();
  803. StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
  804. string retString = myStreamReader.ReadToEnd();
  805. return JsonHelper.setExceptionJson(-99, "获得响应流异常", retString);
  806. }
  807. postContent = getResponseData(response);
  808. joRtn = JObject.Parse(postContent);//返回Json数据
  809. if (joRtn.ContainsKey("body"))
  810. {
  811. joRtn = (JObject)joRtn.GetValue("body");
  812. }
  813. return joRtn;
  814. }
  815. catch (Exception ex)
  816. {
  817. postContent = "调用中心服务异常" + ex.Message;
  818. joRtn.Add("infcode", -1);
  819. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  820. return joRtn;
  821. }
  822. }
  823. /// <summary>
  824. /// 医保电子处方调用中心接口
  825. /// </summary>
  826. /// <param name="funNO"></param>
  827. /// <param name="data"></param>
  828. /// <returns></returns>
  829. public JObject invokeCenterServicePresCir(string funNO, string data)
  830. {
  831. JObject joRtn = new JObject();
  832. string outPar = "";
  833. try
  834. {
  835. if (funNO == "7101")
  836. {
  837. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/uploadChk";
  838. }
  839. else if (funNO == "7102")
  840. {
  841. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxFixmedinsSign";
  842. }
  843. else if (funNO == "7103")
  844. {
  845. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxFileUpld";
  846. }
  847. else if (funNO == "7104")
  848. {
  849. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxUndo";
  850. }
  851. else if (funNO == "7105")
  852. {
  853. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/hospRxDetlQuery";
  854. }
  855. else if (funNO == "7106")
  856. {
  857. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxChkInfoQuery";
  858. }
  859. else if (funNO == "7107")
  860. {
  861. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxSetlInfoQuery";
  862. }
  863. else if (funNO == "7108")
  864. {
  865. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxChkInfoCallback";
  866. }
  867. else if (funNO == "7109")
  868. {
  869. Global.curEvt.URL = Global.inf.presCenterURL + "/fixmedins/rxSetlInfoCallback";
  870. }
  871. else
  872. {
  873. Global.curEvt.URL = Global.inf.centerURL;
  874. }
  875. //Global.curEvt.URL = Global.inf.centerURL;
  876. joRtn = invokeCenterServicePresCir(data);
  877. outPar = JsonHelper.Compress(joRtn);
  878. return joRtn;
  879. }
  880. catch (Exception ex)
  881. {
  882. if (joRtn["infcode"] == null)
  883. { joRtn.Add("infcode", -1); }
  884. if (joRtn["err_msg"] == null)
  885. { joRtn.Add("err_msg", "invokeCenterServicePresCir(3):" + ex.Message); }
  886. outPar = JsonHelper.Compress(joRtn);
  887. return joRtn;
  888. }
  889. finally
  890. {
  891. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  892. //this.saveCenterLog(JsonHelper.Compress(data), outPar, JsonHelper.Compress(data), outPar);
  893. }
  894. }
  895. #endregion
  896. /// <summary>
  897. /// 医保目录txt文件下载
  898. /// </summary>
  899. /// <param name="data"></param>
  900. /// <returns></returns>
  901. public JObject DownloadCenterFile(string data)
  902. {
  903. string error = string.Empty; int errorCode = 0;
  904. string sRtn = "";
  905. try
  906. {
  907. JObject jsonInParam = JObject.Parse(data);
  908. // 去除外wrapper层便于通用
  909. Utils.removeWrapper(jsonInParam);
  910. string fileName = (string)jsonInParam["input"]["fsDownloadIn"]["filename"];
  911. string filePath = Global.curEvt.path + "\\Download\\" + fileName;
  912. //如果不存在目录,则创建目录
  913. if (!Directory.Exists(Global.curEvt.path + "\\Download"))
  914. {
  915. //创建文件夹
  916. DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\Download");
  917. }
  918. if (File.Exists(filePath))
  919. {
  920. File.Delete(filePath);
  921. }
  922. FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
  923. //创建一个HTTP请求
  924. Global.curEvt.URL = Global.inf.downURL;
  925. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  926. //Post请求方式
  927. request.Method = "POST";
  928. //string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  929. //string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  930. //string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  931. //string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  932. //string BusinessID = Global.inf.BusinessID; //服务商ID
  933. //内容类型
  934. request.ContentType = "application/json";
  935. //昆明增加头部信息
  936. //string sTemp = timestamp + BusinessID + nonce;
  937. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  938. //string signature = Encrypt.SHA256EncryptStr(sTemp);
  939. //request.Headers.Add("hsf_signature", signature);
  940. //request.Headers.Add("hsf_timestamp", timestamp);
  941. //request.Headers.Add("hsf_nonce", nonce);
  942. //request.Headers.Add("fixmedins_code", InsuHosID);
  943. //request.Headers.Add("infosyscode", CreditID);
  944. //设置参数,并进行URL编码
  945. string paraUrlCoded = JsonHelper.toJsonString(jsonInParam);
  946. byte[] payload;
  947. //将Json字符串转化为字节
  948. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  949. //设置请求的ContentLength
  950. request.ContentLength = payload.Length;
  951. Stream writer;
  952. try
  953. {
  954. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  955. }
  956. catch (Exception)
  957. {
  958. writer = null;
  959. errorCode = -100;
  960. error = "连接服务器失败!";
  961. }
  962. //将请求参数写入流
  963. writer.Write(payload, 0, payload.Length);
  964. writer.Close();//关闭请求流
  965. // String strValue = "";//strValue为http响应所返回的字符流
  966. //发送请求并获取相应回应数据
  967. HttpWebResponse response = request.GetResponse() as HttpWebResponse;
  968. //直到request.GetResponse()程序才开始向目标网页发送Post请求
  969. Stream responseStream = response.GetResponseStream();
  970. //创建本地文件写入流
  971. byte[] bArr = new byte[1024];
  972. int iTotalSize = 0;
  973. int size = responseStream.Read(bArr, 0, (int)bArr.Length);
  974. while (size > 0)
  975. {
  976. iTotalSize += size;
  977. fs.Write(bArr, 0, size);
  978. size = responseStream.Read(bArr, 0, (int)bArr.Length);
  979. }
  980. fs.Close();
  981. responseStream.Close();
  982. dynamic joReturn = new JObject();
  983. joReturn.errorCode = errorCode;
  984. joReturn.errorMessage = error;
  985. joReturn.filePath = filePath;
  986. sRtn = joReturn.ToString();
  987. return joReturn;
  988. }
  989. catch (Exception ex)
  990. {
  991. errorCode = -100;
  992. error = ex.Message;
  993. dynamic joReturn = new JObject();
  994. joReturn.errorCode = errorCode;
  995. joReturn.errorMessage = error;
  996. sRtn = joReturn.ToString();
  997. return joReturn;
  998. }
  999. finally
  1000. {
  1001. Global.writeLog("DownloadCenterFile" +"(" + Global.inf.downURL + ")", data, sRtn);
  1002. }
  1003. }
  1004. /// <summary>
  1005. /// 保存中心交易日志到数据库
  1006. /// </summary>
  1007. /// <param name="inParam"></param>
  1008. /// <param name="outParam"></param>
  1009. /// <param name="inParamPlain"></param>
  1010. /// <param name="outParamPlain"></param>
  1011. private void saveCenterLog(string inParam, string outParam, string inParamPlain, string outParamPlain)
  1012. {
  1013. dynamic joIris = new JObject();
  1014. string sRtn = "";
  1015. try
  1016. {
  1017. //解析postContent,插入医保交易日志表
  1018. JObject joInParam = new JObject(JObject.Parse(inParam));
  1019. //解包
  1020. JObject joIn = Utils.removeWrapper(joInParam);
  1021. JObject joOut = new JObject(JObject.Parse(outParam));
  1022. JObject joInPlain = new JObject(JObject.Parse(inParamPlain));
  1023. JObject joOutPlain = new JObject(JObject.Parse(outParamPlain));
  1024. JArray jaParams = new JArray();
  1025. JObject joParam = new JObject();
  1026. joParam.Add("inParam", JObject.FromObject(joIn));
  1027. joParam.Add("outParam", JObject.FromObject(joOut));
  1028. joParam.Add("inParamPlain", JObject.FromObject(joInPlain));
  1029. joParam.Add("outParamPlain", JObject.FromObject(joOutPlain));
  1030. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  1031. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  1032. joParam.Add("updateUserID", Global.user.ID);
  1033. joParam.Add("psn_no", Global.pat.psn_no);
  1034. jaParams.Add(joParam);
  1035. joIris.code = "09010021";
  1036. joIris.Add("params", jaParams);
  1037. //InvokeHelper invoker = new InvokeHelper();
  1038. sRtn = invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  1039. }
  1040. catch (Exception ex)
  1041. {
  1042. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  1043. Global.writeLog_Iris("保存日志异常:" + sRtn.ToString());
  1044. }
  1045. }
  1046. #region 调用一码付
  1047. public JObject invokeOneCodePayService(string funNO, string data)
  1048. {
  1049. return invokeOneCodePayService(funNO, JObject.Parse(data));
  1050. }
  1051. public JObject invokeOneCodePayService(string funNO, JObject joInput)
  1052. {
  1053. JObject joRtn = new JObject();
  1054. String outPar = "";
  1055. try
  1056. {
  1057. string url = "";
  1058. switch (funNO)
  1059. {
  1060. case "QuerySignedPayStatus":
  1061. url = "/cfc/api/signedQuery";
  1062. break;
  1063. case "GetPayCert":
  1064. url = "/cfc/api/genPayCert";
  1065. break;
  1066. default:
  1067. break;
  1068. }
  1069. //EncryptHelper encrypt = new EncryptHelper();
  1070. string data = JsonHelper.setOneCodePayInpar(joInput);
  1071. // 一码付地址
  1072. Global.curEvt.URL = Global.inf.oneCodePay.url + url;
  1073. string outputData = "", errMsg = "";
  1074. // 动态调试模式
  1075. if (Global.curEvt.enabledDebug)
  1076. {
  1077. CenterResult center = new CenterResult();
  1078. center.setTradeNo(funNO);
  1079. if (center.ShowDialog() == DialogResult.OK)
  1080. {
  1081. outPar = center.returnData;
  1082. return JObject.Parse(outPar);
  1083. }
  1084. }
  1085. try
  1086. {
  1087. //InvokeRestCenter oneCodePayRest = new InvokeRestCenter();
  1088. //int iInt = oneCodePayRest.Business(data, ref outputData, ref errMsg);
  1089. //joRtn = JObject.Parse(outputData);
  1090. joRtn = invokeCenterService(data);
  1091. return joRtn;
  1092. }
  1093. finally
  1094. {
  1095. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  1096. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  1097. }
  1098. }
  1099. catch (Exception ex)
  1100. {
  1101. if (joRtn["code"] == null)
  1102. { joRtn.Add("code", -1); }
  1103. if (joRtn["message"] == null)
  1104. { joRtn.Add("message", "invokeOneCodePayService:" + ex.Message); }
  1105. outPar = JsonHelper.Compress(joRtn);
  1106. return joRtn;
  1107. }
  1108. finally
  1109. {
  1110. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", joInput.ToString(), joRtn.ToString());
  1111. this.saveCenterLog(joInput.ToString(), joRtn.ToString(), joInput.ToString(), joRtn.ToString());
  1112. }
  1113. }
  1114. #endregion
  1115. }
  1116. }