InvokeHelper.cs 49 KB

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