using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MedicalInsurance.Helper; using MedicalInsurance.Common; namespace ChengDuMedInsu2 { /// /// 子业务的封装 /// class SubBusiness { #region ///对目录下载业务的封装 /// public string Download(string inParam) { string errorMessage = "", sRtn = "" ; try { CenterServices centerService = new CenterServices(); string strCenterRtn = centerService.Post(GlobalVariables.centerURL, inParam); JObject joCenterRtn = JObject.Parse(strCenterRtn); if (joCenterRtn["infcode"].ToString() != "0") { errorMessage = "下载异常:" + joCenterRtn["err_msg"].ToString(); return JsonHelper.getIrisReturnJson(-100, errorMessage, joCenterRtn).ToString(); } string filename = joCenterRtn["output"]["filename"].ToString(); string file_qury_no = joCenterRtn["output"]["file_qury_no"].ToString(); string data_cnt = joCenterRtn["output"]["data_cnt"].ToString(); dynamic jo9102InParam = new JObject(); dynamic jofsDownloadIn = new JObject(); jofsDownloadIn.filename = filename; jofsDownloadIn.file_qury_no = file_qury_no; jofsDownloadIn.fixmedins_code = GlobalVariables.hospitalNO; jo9102InParam.fsDownloadIn = jofsDownloadIn; string str9102Rtn = centerService.Download(GlobalVariables.centerURL, GlobalVariables.SetJsonParam("9102", jo9102InParam.ToString())); //解压缩 JObject jo9102Rtn = JObject.Parse(str9102Rtn); string zipFilePath = jo9102Rtn["filePath"].ToString(); string txtFileDir = System.Environment.CurrentDirectory + "\\Download"; string txtFilePath = txtFileDir + "\\" + filename.Substring(0, filename.Length - 4); if (File.Exists(txtFilePath)) { File.Delete(txtFilePath); } ZipFile.ExtractToDirectory(zipFilePath, txtFileDir); JObject joRtn = new JObject(); joRtn = JObject.Parse(str9102Rtn); joRtn["filePath"] = txtFilePath; sRtn = joRtn.ToString(); return sRtn; } catch (Exception ex) { JObject joRtn = new JObject(); joRtn["errorCode"] = -1; joRtn["errorMessage"] = ex.Message; sRtn = joRtn.ToString(); return sRtn; } finally { GlobalVariables.writeLog("SubBusiness.Download",inParam,sRtn); } } public string downDictionary(string inParam) { CenterServices centerService = new CenterServices(); string strCenterRtn = centerService.Post(GlobalVariables.centerURL, inParam); JObject joCenterRtn = JObject.Parse(strCenterRtn); return joCenterRtn.ToString(); } #endregion } }