InvokeHelper.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  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. }
  274. /// <summary>
  275. /// 调用医保动态库文件下载函数 CM 20220925
  276. /// </summary>
  277. /// <param name="fixmedins_code"></param>
  278. /// <param name="infosyscode"></param>
  279. /// <param name="infosyssign"></param>
  280. /// <param name="inputData"></param>
  281. /// <param name="outputData"></param>
  282. /// <param name="pErrMsg"></param>
  283. /// <returns>0或小于0</returns>
  284. private int invokeDownloadFileByDLL(string fixmedins_code, string infosyscode, string infosyssign, string inputData, ref string outputData, ref string pErrMsg)
  285. {
  286. pErrMsg = "";
  287. outputData = "";
  288. try
  289. {
  290. StringBuilder errmsgSb = new StringBuilder(4096);
  291. StringBuilder outSb = new StringBuilder(40960);
  292. int pRtn = DownloadFile(fixmedins_code, infosyscode, infosyssign, inputData, outSb, errmsgSb);
  293. if (pRtn < 0)
  294. {
  295. pErrMsg = errmsgSb.ToString();
  296. return -1;
  297. }
  298. else
  299. {
  300. outputData = outSb.ToString();
  301. }
  302. return pRtn;
  303. }
  304. catch (Exception ex)
  305. {
  306. pErrMsg = "invokeInitByDLL.DownloadFile 异常:" + ex.Message;
  307. return -1;
  308. }
  309. finally
  310. {
  311. Global.writeLog("invokeInitByDLL.DownloadFile 医保动态库文件下载函数", inputData, outputData);
  312. }
  313. }
  314. /// <summary>
  315. /// 这个是调用业务服务的invokeCenterService
  316. /// </summary>
  317. /// <param name="funNO"></param>
  318. /// <param name="data"></param>
  319. /// <returns></returns>
  320. public JObject invokeCenterService(string funNO, JObject data)
  321. {
  322. JObject joRtn = new JObject();
  323. string outPar = ""; Boolean bDownLoad = false;
  324. int iInt = 0;
  325. try
  326. {
  327. Global.curEvt.URL = Global.inf.centerURL;
  328. if (bDownLoad == false)
  329. {
  330. string outData = "", errMsg = "";
  331. iInt = InvokeInitByDLL(ref errMsg);
  332. if (iInt == 0)
  333. {
  334. iInt = invokeBusiessByDLL(data.ToString(), ref outData, ref errMsg);
  335. joRtn = JObject.Parse(outData);
  336. return joRtn;
  337. }
  338. else
  339. {
  340. joRtn.Add("infcode", -1);
  341. joRtn.Add("err_msg", "医保动态库初始化失败invokeInitByDLL:" + errMsg);
  342. outPar = JsonHelper.Compress(joRtn);
  343. return joRtn;
  344. }
  345. }
  346. else
  347. {
  348. joRtn = invokeCenterService(data.ToString());
  349. outPar = JsonHelper.Compress(joRtn);
  350. return joRtn;
  351. }
  352. }
  353. catch (Exception ex)
  354. {
  355. if (joRtn["infcode"] == null)
  356. { joRtn.Add("infcode", -1); }
  357. if (joRtn["err_msg"] == null)
  358. { joRtn.Add("err_msg", "invokeCenterService(2):" + ex.Message); }
  359. outPar = JsonHelper.Compress(joRtn);
  360. return joRtn;
  361. }
  362. finally
  363. {
  364. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  365. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  366. }
  367. }
  368. /// <summary>
  369. /// 这个是下载目录用的invokeCenterService
  370. /// </summary>
  371. /// <param name="funNO"></param>
  372. /// <param name="data"></param>
  373. /// <returns></returns>
  374. public JObject invokeCenterService(string funNO, string data)
  375. {
  376. JObject joRtn = new JObject();
  377. int iInt = 0;
  378. String outPar = ""; Boolean bDownLoad = false;
  379. try
  380. {
  381. //Global.inf.centerURL = @"http://10.114.177.55:8080/eapdomain/callService";
  382. Global.curEvt.URL = Global.inf.centerURL ;
  383. List<string> infList = new List<string> { "6201", "6202", "6203", "6301", "6401" };
  384. if (infList.Contains(funNO))
  385. {
  386. Global.writeLog(Global.curEvt.path + @"\CenterServiceURL.ini");
  387. IniFile urlIni = new IniFile(Global.curEvt.path + @"\CenterServiceURL.ini");
  388. Global.curEvt.URL = urlIni.ReadValue("URL", funNO);
  389. Global.inf.centerURL = Global.curEvt.URL;
  390. }
  391. if (funNO != "9101") //文件下载通过DLL调用
  392. {
  393. string outData = "", errMsg = "";
  394. iInt = InvokeInitByDLL(ref errMsg);
  395. if (iInt == 0)
  396. {
  397. iInt = invokeBusiessByDLL(data.ToString(), ref outData, ref errMsg);
  398. joRtn = JObject.Parse(outData);
  399. return joRtn;
  400. }
  401. else
  402. {
  403. joRtn.Add("infcode", -1);
  404. joRtn.Add("err_msg", "医保动态库初始化失败invokeInitByDLL:" + errMsg);
  405. outPar = JsonHelper.Compress(joRtn);
  406. return joRtn;
  407. }
  408. }
  409. else
  410. {
  411. joRtn = invokeCenterService(data);
  412. outPar = JsonHelper.Compress(joRtn);
  413. return joRtn;
  414. }
  415. }
  416. catch (Exception ex)
  417. {
  418. if (joRtn["infcode"] == null)
  419. { joRtn.Add("infcode", -1); }
  420. if (joRtn["err_msg"] == null)
  421. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  422. outPar = JsonHelper.Compress(joRtn);
  423. return joRtn;
  424. }
  425. finally
  426. {
  427. Global.writeLog("服务商ID:" + Global.inf.BusinessID + ",社会统一信用代码:" + Global.inf.CreditID);
  428. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  429. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  430. }
  431. }
  432. /// <summary>
  433. /// 移动
  434. /// </summary>
  435. /// <param name="funNO"></param>
  436. /// <param name="data"></param>
  437. /// <returns></returns>
  438. public JObject invokeMPService(string funNO, string data)
  439. {
  440. JObject joRtn = new JObject();
  441. int iInt = 0;
  442. String outPar = ""; Boolean bDownLoad = false;
  443. try
  444. {
  445. Global.curEvt.URL = Global.inf.centerURL;
  446. List<string> infList = new List<string> { "6201", "6202", "6203", "6301", "6401" };
  447. if (infList.Contains(funNO))
  448. {
  449. IniFile urlIni = new IniFile(Global.curEvt.path + @"\CenterServiceURL.ini");
  450. Global.curEvt.URL = urlIni.ReadValue("URL", funNO);
  451. Global.inf.centerURL = Global.curEvt.URL;
  452. }
  453. joRtn = invokeCenterService(data);
  454. outPar = JsonHelper.Compress(joRtn);
  455. return joRtn;
  456. }
  457. catch (Exception ex)
  458. {
  459. if (joRtn["infcode"] == null)
  460. { joRtn.Add("infcode", -1); }
  461. if (joRtn["err_msg"] == null)
  462. { joRtn.Add("err_msg", "invokeCenterService(3):" + ex.Message); }
  463. outPar = JsonHelper.Compress(joRtn);
  464. return joRtn;
  465. }
  466. finally
  467. {
  468. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  469. this.saveCenterLog(JsonHelper.Compress(data), joRtn.ToString(), JsonHelper.Compress(data), joRtn.ToString());
  470. }
  471. }
  472. /// <summary>
  473. /// 设置医保动态库目录
  474. /// </summary>
  475. /// <param name="sPath"></param>
  476. /// <param name="pErrMsg"></param>
  477. /// <returns></returns>
  478. private void invokeSetDirByOCX(ref string pErrMsg)
  479. {
  480. try
  481. {
  482. //chsinterfaceyn.chsdllClass InterfaceBase_Yn = new chsinterfaceyn.chsdllClass();
  483. //InterfaceBase_Yn.SetDir(IntPath);
  484. }
  485. catch (Exception ex)
  486. {
  487. pErrMsg = "invokeInitByDLL.SetDir 异常:" + ex.Message;
  488. MessageBox.Show(pErrMsg);
  489. }
  490. finally
  491. {
  492. Global.writeLog("invokeInitByDLL.SetDir设置医保动态库目录(" + IntPath + ")", "", pErrMsg);
  493. }
  494. }
  495. /// <summary>
  496. /// 医保目录txt文件下载
  497. /// </summary>
  498. /// <param name="data"></param>
  499. /// <returns></returns>
  500. public JObject DownloadCenterFile(string data)
  501. {
  502. string error = string.Empty; int errorCode = 0;
  503. string sRtn = "";
  504. try
  505. {
  506. JObject jsonInParam = JObject.Parse(data);
  507. string fileName = (string)jsonInParam["input"]["fsDownloadIn"]["filename"];
  508. string filePath = Global.curEvt.path + "\\Download\\" + fileName;
  509. //MessageBox.Show("9102下载文件入参:"+jsonInParam.ToString());
  510. //如果不存在目录,则创建目录
  511. if (!Directory.Exists(Global.curEvt.path + "\\Download"))
  512. {
  513. //创建文件夹
  514. DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\Download");
  515. }
  516. if (File.Exists(filePath))
  517. {
  518. File.Delete(filePath);
  519. }
  520. FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
  521. //创建一个HTTP请求
  522. //Global.curEvt.URL = Global.inf.centerURL + "/hsa-fsi-9102";
  523. Global.curEvt.URL = Global.inf.centerURL;
  524. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  525. //Post请求方式
  526. request.Method = "POST";
  527. string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  528. string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  529. string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  530. string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  531. string BusinessID = Global.inf.BusinessID; //服务商ID
  532. //内容类型
  533. request.ContentType = "application/json";
  534. //昆明增加头部信息
  535. string sTemp = timestamp + BusinessID + nonce;
  536. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  537. string signature = Encrypt.SHA256EncryptStr(sTemp);
  538. request.Headers.Add("hsf_signature", signature);
  539. request.Headers.Add("hsf_timestamp", timestamp);
  540. request.Headers.Add("hsf_nonce", nonce);
  541. request.Headers.Add("fixmedins_code", InsuHosID);
  542. request.Headers.Add("infosyscode", CreditID);
  543. //设置参数,并进行URL编码
  544. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  545. byte[] payload;
  546. //将Json字符串转化为字节
  547. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  548. //设置请求的ContentLength
  549. request.ContentLength = payload.Length;
  550. Stream writer;
  551. try
  552. {
  553. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  554. }
  555. catch (Exception)
  556. {
  557. writer = null;
  558. errorCode = -100;
  559. error = "连接服务器失败!";
  560. }
  561. //将请求参数写入流
  562. writer.Write(payload, 0, payload.Length);
  563. writer.Close();//关闭请求流
  564. // String strValue = "";//strValue为http响应所返回的字符流
  565. //发送请求并获取相应回应数据
  566. HttpWebResponse response = request.GetResponse() as HttpWebResponse;
  567. //直到request.GetResponse()程序才开始向目标网页发送Post请求
  568. Stream responseStream = response.GetResponseStream();
  569. //创建本地文件写入流
  570. byte[] bArr = new byte[1024];
  571. int iTotalSize = 0;
  572. int size = responseStream.Read(bArr, 0, (int)bArr.Length);
  573. while (size > 0)
  574. {
  575. iTotalSize += size;
  576. fs.Write(bArr, 0, size);
  577. size = responseStream.Read(bArr, 0, (int)bArr.Length);
  578. }
  579. fs.Close();
  580. responseStream.Close();
  581. dynamic joReturn = new JObject();
  582. joReturn.errorCode = errorCode;
  583. joReturn.errorMessage = error;
  584. joReturn.filePath = filePath;
  585. sRtn = joReturn.ToString();
  586. return joReturn;
  587. }
  588. catch (Exception ex)
  589. {
  590. errorCode = -100;
  591. error = ex.Message;
  592. dynamic joReturn = new JObject();
  593. joReturn.errorCode = errorCode;
  594. joReturn.errorMessage = error;
  595. sRtn = joReturn.ToString();
  596. return joReturn;
  597. }
  598. finally
  599. {
  600. Global.writeLog("DownloadCenterFile" +"(" + Global.curEvt.URL + ")", data, sRtn);
  601. }
  602. }
  603. /// <summary>
  604. /// 调用医保动态库初始化 CM 20220925
  605. /// </summary>
  606. /// <param name="fixmedins_code"></param>
  607. /// <param name="infosyscode"></param>
  608. /// <param name="infosyssign"></param>
  609. /// <param name="url"></param>
  610. /// <param name="pErrMsg"></param>
  611. /// <returns>0或小于0</returns>
  612. private int invokeInitByOCX(string fixmedins_code, string infosyscode, string infosyssign, string url, ref string pErrMsg)
  613. {
  614. //pErrMsg = "";
  615. JObject joRtn = new JObject();
  616. try
  617. {
  618. //chsinterfaceyn.chsdllClass InterfaceBase_Yn = new chsinterfaceyn.chsdllClass();
  619. //string pRtn = InterfaceBase_Yn.Init(fixmedins_code, infosyscode, infosyssign, url);
  620. //joRtn = JObject.Parse(pRtn);
  621. if (joRtn["infcode"].ToString() != "0")
  622. {
  623. pErrMsg = joRtn["err_msg"].ToString();
  624. return -1;
  625. }
  626. else
  627. {
  628. return 0;
  629. }
  630. }
  631. catch (Exception ex)
  632. {
  633. pErrMsg = "invokeInitByDLL.Init 异常:" + ex.Message;
  634. return -1;
  635. }
  636. finally
  637. {
  638. Global.writeLog("invokeInitByDLL.Init医保动态库初始化(" + url + ")", "", pErrMsg);
  639. }
  640. }
  641. /// <summary>
  642. /// 调用医保动态库通用业务函数 CM 20220925
  643. /// </summary>
  644. /// <param name="fixmedins_code"></param>
  645. /// <param name="infosyscode"></param>
  646. /// <param name="infosyssign"></param>
  647. /// <param name="inputData"></param>
  648. /// <param name="outputData"></param>
  649. /// <param name="pErrMsg"></param>
  650. /// <returns>0或小于0</returns>
  651. private int invokeBusiessByOCX(string fixmedins_code, string infosyscode, string infosyssign, string inputData, ref string outputData, ref string pErrMsg)
  652. {
  653. pErrMsg = "";
  654. outputData = "";
  655. JObject joRtn = new JObject();
  656. try
  657. {
  658. try
  659. {
  660. //chsinterfaceyn.chsdllClass InterfaceBase_Yn1 = new chsinterfaceyn.chsdllClass();
  661. //InterfaceBase_Yn1.SetDir(IntPath);
  662. }
  663. catch (Exception ex)
  664. {
  665. pErrMsg = "invokeInitByDLL.SetDir 异常:" + ex.Message;
  666. MessageBox.Show(pErrMsg);
  667. }
  668. finally
  669. {
  670. Global.writeLog("invokeInitByDLL.SetDir设置医保动态库目录(" + IntPath + ")", "", pErrMsg);
  671. }
  672. inputData = inputData.Replace("\n", "").Replace("\t", "").Replace("\r", "");
  673. //chsinterfaceyn.chsdllClass InterfaceBase_Yn = new chsinterfaceyn.chsdllClass();
  674. //调用业务函数
  675. //string pRtn =InterfaceBase_Yn.BusinessHandleW(fixmedins_code, infosyscode, infosyssign, inputData);
  676. //string pRtn = InterfaceBase_Yn.UploadFile(fixmedins_code, infosyscode, infosyssign, Global.inf.fileName,inputData);
  677. //joRtn = JObject.Parse(pRtn);
  678. if (joRtn["infcode"].ToString() != "0")
  679. {
  680. pErrMsg = joRtn["err_msg"].ToString();
  681. //outputData = pRtn;
  682. return -1;
  683. }
  684. else
  685. {
  686. //outputData = pRtn;
  687. return 0;
  688. }
  689. }
  690. catch (Exception ex)
  691. {
  692. pErrMsg = "invokeInitByDLL.BusinessHandle 异常:" + ex.Message;
  693. return -1;
  694. }
  695. finally
  696. {
  697. Global.writeLog("invokeInitByDLL.BusinessHandle医保动态库通用业务函数", inputData, outputData);
  698. }
  699. }
  700. /// <summary>
  701. /// 医保动态库下载目录文件
  702. /// </summary>
  703. /// <param name="data"></param>
  704. /// <returns></returns>
  705. public JObject DownloadCenterFileByDll(string data)
  706. {
  707. string error = string.Empty; int errorCode = 0;
  708. string sRtn = "";
  709. try
  710. {
  711. JObject jsonInParam = JObject.Parse(data);
  712. string fileName = (string)jsonInParam["input"]["fsDownloadIn"]["filename"];
  713. string filePath = Global.curEvt.path + "\\Download\\" + fileName;
  714. //如果不存在目录,则创建目录
  715. if (!Directory.Exists(Global.curEvt.path + "\\Download"))
  716. {
  717. //创建文件夹
  718. DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\Download");
  719. }
  720. if (File.Exists(filePath))
  721. {
  722. File.Delete(filePath);
  723. }
  724. FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
  725. //创建一个HTTP请求
  726. //Global.curEvt.URL = Global.inf.centerURL + "/hsa-fsi-9102";
  727. Global.curEvt.URL = Global.inf.centerURL;
  728. int iRes = invokeDownloadFileByDLL(Global.inf.hospitalNO, Global.inf.CreditID, Global.inf.BusinessID, data.ToString(),ref sRtn, ref error);
  729. if (iRes == 0)
  730. {
  731. dynamic joReturn = new JObject();
  732. joReturn.errorCode = errorCode;
  733. joReturn.errorMessage = error;
  734. joReturn.filePath = filePath;
  735. sRtn = joReturn.ToString();
  736. return joReturn;
  737. }
  738. else
  739. {
  740. errorCode = -100;
  741. dynamic joReturn = new JObject();
  742. joReturn.errorCode = errorCode;
  743. joReturn.errorMessage = error;
  744. sRtn = joReturn.ToString();
  745. return joReturn;
  746. }
  747. }
  748. catch (Exception ex)
  749. {
  750. errorCode = -100;
  751. error = ex.Message;
  752. dynamic joReturn = new JObject();
  753. joReturn.errorCode = errorCode;
  754. joReturn.errorMessage = error;
  755. sRtn = joReturn.ToString();
  756. return joReturn;
  757. }
  758. finally
  759. {
  760. Global.writeLog("DownloadCenterFile" + "(" + Global.curEvt.URL + ")", data, sRtn);
  761. }
  762. }
  763. /// <summary>
  764. /// 保存中心交易日志到数据库
  765. /// </summary>
  766. /// <param name="inParam"></param>
  767. /// <param name="outParam"></param>
  768. /// <param name="inParamPlain"></param>
  769. /// <param name="outParamPlain"></param>
  770. private void saveCenterLog(string inParam, string outParam, string inParamPlain, string outParamPlain)
  771. {
  772. dynamic joIris = new JObject();
  773. string sRtn = "";
  774. try
  775. {
  776. //解析postContent,插入医保交易日志表
  777. JObject joIn = new JObject(JObject.Parse(inParam));
  778. JObject joOut = new JObject(JObject.Parse(outParam));
  779. JObject joInPlain = new JObject(JObject.Parse(inParamPlain));
  780. JObject joOutPlain = new JObject(JObject.Parse(outParamPlain));
  781. JArray jaParams = new JArray();
  782. JObject joParam = new JObject();
  783. joParam.Add("inParam", JObject.FromObject(joIn));
  784. joParam.Add("outParam", JObject.FromObject(joOut));
  785. joParam.Add("inParamPlain", JObject.FromObject(joInPlain));
  786. joParam.Add("outParamPlain", JObject.FromObject(joOutPlain));
  787. joParam.Add("HospitalDr", Global.inf.hospitalDr);
  788. joParam.Add("InterfaceDr", Global.inf.interfaceDr);
  789. joParam.Add("updateUserID", Global.user.ID);
  790. joParam.Add("psn_no", Global.pat.psn_no);
  791. jaParams.Add(joParam);
  792. joIris.code = "09010021";
  793. joIris.Add("params", jaParams);
  794. //InvokeHelper invoker = new InvokeHelper();
  795. sRtn = invokeInsuService(joIris.ToString(), "保存日志到数据库").ToString();
  796. }
  797. catch (Exception ex)
  798. {
  799. sRtn = JsonHelper.setExceptionJson(-100, "保存日志异常", ex.Message).ToString();
  800. Global.writeLog_Iris("保存日志异常:" + sRtn.ToString());
  801. }
  802. }
  803. /// <summary>
  804. /// 医保电子处方流转调用服务
  805. /// </summary>
  806. /// <param name="data"></param>
  807. /// <returns></returns>
  808. private JObject invokeCenterServicePresCir(string data)
  809. {
  810. string postContent = "";
  811. JObject joRtn = new JObject();
  812. try
  813. {
  814. //创建一个HTTP请求
  815. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global.curEvt.URL);
  816. //Post请求方式
  817. request.Method = "POST";
  818. string nonce = Guid.NewGuid().ToString(); //非重复的随机字符串(十分钟内不能重复)
  819. string timestamp = TimeStamp.get13().ToString(); //当前时间戳(秒)
  820. string BusinessID = Global.inf.BusinessID; //服务商ID
  821. string InsuHosID = Global.inf.hospitalNO; //医疗机构ID
  822. string CreditID = Global.inf.CreditID; //服务商统一社会信用代码
  823. //内容类型
  824. request.ContentType = "application/json";
  825. //昆明增加头部信息
  826. string sTemp = timestamp + BusinessID + nonce;
  827. //Sha256 加密生成的签名 signature = sha256(hsf_timestamp + infosyssign + hsf_nonce)
  828. string signature = Encrypt.SHA256EncryptStr(sTemp);
  829. request.Headers.Add("hsf_signature", signature);
  830. request.Headers.Add("hsf_timestamp", timestamp);
  831. request.Headers.Add("hsf_nonce", nonce);
  832. request.Headers.Add("fixmedins_code", InsuHosID);
  833. request.Headers.Add("infosyscode", CreditID);
  834. //设置参数,并进行URL编码
  835. string paraUrlCoded = data;//System.Web.HttpUtility.UrlEncode(jsonParas);
  836. byte[] payload;
  837. //将Json字符串转化为字节
  838. payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
  839. //设置请求的ContentLength
  840. request.ContentLength = payload.Length;
  841. //发送请求,获得请求流
  842. Stream writer;
  843. writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
  844. //将请求参数写入流
  845. writer.Write(payload, 0, payload.Length);
  846. writer.Close();//关闭请求流
  847. // String strValue = "";//strValue为http响应所返回的字符流
  848. HttpWebResponse response;
  849. try
  850. {
  851. //获得响应流
  852. response = (HttpWebResponse)request.GetResponse();
  853. }
  854. catch (WebException ex)
  855. {
  856. response = ex.Response as HttpWebResponse;
  857. return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", ex.Message);
  858. }
  859. Stream s = response.GetResponseStream();
  860. StreamReader sRead = new StreamReader(s);
  861. postContent = sRead.ReadToEnd();
  862. sRead.Close();
  863. joRtn = JObject.Parse(postContent);//返回Json数据
  864. return joRtn;
  865. }
  866. catch (Exception ex)
  867. {
  868. postContent = "调用中心服务异常" + ex.Message;
  869. joRtn.Add("infcode", -1);
  870. joRtn.Add("err_msg", "invokeCenterService(1):" + ex.Message);
  871. return joRtn;
  872. }
  873. }
  874. /// </summary>
  875. /// <param name="funNO"></param>
  876. /// <param name="data"></param>
  877. /// <returns></returns>
  878. public JObject invokeCenterServicePresCir(string funNO, string data)
  879. {
  880. JObject joRtn = new JObject();
  881. string outPar = "";
  882. try
  883. {
  884. if (funNO == "7101")
  885. {
  886. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/uploadChk";
  887. }
  888. else if (funNO == "7102")
  889. {
  890. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxFixmedinsSign";
  891. }
  892. else if (funNO == "7103")
  893. {
  894. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxFileUpld";
  895. }
  896. else if (funNO == "7104")
  897. {
  898. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxUndo";
  899. }
  900. else if (funNO == "7105")
  901. {
  902. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/hospRxDetlQuery";
  903. }
  904. else if (funNO == "7106")
  905. {
  906. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxChkInfoQuery";
  907. }
  908. else if (funNO == "7107")
  909. {
  910. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxSetlInfoQuery";
  911. }
  912. else if (funNO == "7108")
  913. {
  914. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxChkInfoCallback";
  915. }
  916. else if (funNO == "7109")
  917. {
  918. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/rxSetlInfoCallback";
  919. }
  920. else if (funNO == "7211")
  921. {
  922. Global.curEvt.URL = Global.inf.PresCir.url + "/epc/api/fixmedins/circDrugQuery";
  923. }
  924. else
  925. {
  926. Global.curEvt.URL = Global.inf.centerURL;
  927. }
  928. //Global.curEvt.URL = Global.inf.centerURL;
  929. joRtn = invokeCenterServicePresCir(data);
  930. outPar = JsonHelper.Compress(joRtn);
  931. return joRtn;
  932. }
  933. catch (Exception ex)
  934. {
  935. if (joRtn["infcode"] == null)
  936. { joRtn.Add("infcode", -1); }
  937. if (joRtn["err_msg"] == null)
  938. { joRtn.Add("err_msg", "invokeCenterServicePresCir(3):" + ex.Message); }
  939. outPar = JsonHelper.Compress(joRtn);
  940. return joRtn;
  941. }
  942. finally
  943. {
  944. Global.writeLog(funNO + "(" + Global.curEvt.URL + ")", JsonHelper.Compress(data), joRtn.ToString());
  945. //this.saveCenterLog(JsonHelper.Compress(data), outPar, JsonHelper.Compress(data), outPar);
  946. }
  947. }
  948. /**********************************************************调用DLL方式**************************************************************/
  949. public int InvokeInitByDLL(ref string pErrMsg)
  950. {
  951. //string pErrMsg = "";
  952. int pRtn =-1;
  953. JObject joRtn = new JObject();
  954. try
  955. {
  956. StringBuilder outSb = new StringBuilder(40960);
  957. pRtn = Init(Global.inf.hospitalNO, Global.inf.CreditID, Global.inf.BusinessID, Global.inf.centerURL, outSb);
  958. if (pRtn != 0)
  959. {
  960. pErrMsg = outSb.ToString();
  961. return -1;
  962. }
  963. else
  964. {
  965. return 0;
  966. }
  967. }
  968. catch (Exception ex)
  969. {
  970. pErrMsg = "invokeInitByDLL.Init 异常:" + ex.Message;
  971. return -1;
  972. }
  973. finally
  974. {
  975. Global.writeLog("InvokeInitByDLL(" + Global.inf.centerURL + ")", Global.inf.CreditID +":" + Global.inf.BusinessID,pRtn.ToString() + pErrMsg);
  976. }
  977. }
  978. private int invokeBusiessByDLL(string inputData, ref string outputData, ref string pErrMsg)
  979. {
  980. pErrMsg = "";
  981. outputData = "";
  982. JObject joRtn = new JObject();
  983. try
  984. {
  985. inputData = inputData.Replace("\n", "").Replace("\t", "").Replace("\r", "");
  986. StringBuilder errmsgSb = new StringBuilder(4096);
  987. StringBuilder outSb = new StringBuilder(40960);
  988. //调用业务函数
  989. int pRtn = BusinessHandle(Global.inf.hospitalNO, Global.inf.CreditID, Global.inf.BusinessID, inputData, outSb, errmsgSb);
  990. if (pRtn != 0)
  991. {
  992. outputData = outSb.ToString();
  993. pErrMsg = errmsgSb.ToString();
  994. return -1;
  995. }
  996. else
  997. {
  998. outputData = outSb.ToString();
  999. return 0;
  1000. }
  1001. }
  1002. catch (Exception ex)
  1003. {
  1004. pErrMsg = "invokeInitByDLL.BusinessHandle 异常:" + ex.Message;
  1005. return -1;
  1006. }
  1007. finally
  1008. {
  1009. Global.writeLog("CreditID11", Global.inf.CreditID, Global.inf.BusinessID);
  1010. Global.writeLog("invokeInitByDLL.BusinessHandle医保动态库通用业务函数", inputData, outputData);
  1011. }
  1012. }
  1013. private int invokeBusiessWByDLL(string inputData, ref string outputData, ref string pErrMsg)
  1014. {
  1015. pErrMsg = "";
  1016. outputData = "";
  1017. JObject joRtn = new JObject();
  1018. try
  1019. {
  1020. //inputData = inputData.Replace("\n", "").Replace("\t", "").Replace("\r", "");
  1021. StringBuilder errmsgSb = new StringBuilder(4096);
  1022. StringBuilder outSb = new StringBuilder(40960);
  1023. StringBuilder sbHospitalNO = new StringBuilder(Global.inf.hospitalNO);
  1024. StringBuilder sbCreditID = new StringBuilder(Global.inf.CreditID);
  1025. StringBuilder sbBusinessID = new StringBuilder(Global.inf.BusinessID);
  1026. StringBuilder sbInput = new StringBuilder(inputData);
  1027. //调用业务函数
  1028. int pRtn = BusinessHandleW(sbHospitalNO, sbCreditID, sbBusinessID, sbInput, outSb, errmsgSb);
  1029. if (pRtn != 0)
  1030. {
  1031. outputData = outSb.ToString();
  1032. pErrMsg = errmsgSb.ToString();
  1033. return -1;
  1034. }
  1035. else
  1036. {
  1037. outputData = outSb.ToString();
  1038. return 0;
  1039. }
  1040. }
  1041. catch (Exception ex)
  1042. {
  1043. pErrMsg = "invokeInitByDLL.BusinessHandle 异常:" + ex.Message;
  1044. return -1;
  1045. }
  1046. finally
  1047. {
  1048. Global.writeLog("CreditID12", Global.inf.CreditID, Global.inf.BusinessID);
  1049. Global.writeLog("invokeInitByDLL.BusinessHandleW医保动态库通用业务函数", inputData, outputData);
  1050. }
  1051. }
  1052. private int invokeUploadFileByDLL(string inputData, ref string outputData, ref string pErrMsg)
  1053. {
  1054. pErrMsg = "";
  1055. outputData = "";
  1056. JObject joRtn = new JObject();
  1057. try
  1058. {
  1059. inputData = inputData.Replace("\n", "").Replace("\t", "").Replace("\r", "");
  1060. StringBuilder errmsgSb = new StringBuilder(4096);
  1061. StringBuilder outSb = new StringBuilder(40960);
  1062. //调用业务函数
  1063. int pRtn = UploadFile(Global.inf.hospitalNO, Global.inf.CreditID, Global.inf.BusinessID, Global.inf.fileName,inputData, outSb, errmsgSb);
  1064. if (pRtn != 0)
  1065. {
  1066. outputData = outSb.ToString();
  1067. pErrMsg = errmsgSb.ToString();
  1068. return -1;
  1069. }
  1070. else
  1071. {
  1072. outputData = outSb.ToString();
  1073. return 0;
  1074. }
  1075. }
  1076. catch (Exception ex)
  1077. {
  1078. pErrMsg = "invokeUploadFileByDLL.UploadFile 异常:" + ex.Message;
  1079. return -1;
  1080. }
  1081. finally
  1082. {
  1083. Global.writeLog("invokeUploadFileByDLL.UploadFile医保动态库上传业务函数", inputData, outputData);
  1084. }
  1085. }
  1086. }
  1087. }