InvokeHelper.cs 51 KB

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