/// <summary> /// 下载医院的匹配关系 /// </summary> /// <param name="hisData"></param> /// <returns></returns> public static RecieveHospitalMatchInfoResult DownLoadMatchInfo(DownLoadItem hisData) { string strParameter = Newtonsoft.Json.JavaScriptConvert.SerializeObject(hisData); Message recieveMsg = new Message(); recieveMsg.DES = false; recieveMsg.GZipCompress = false; recieveMsg.dataContent = strParameter; Message retMsg = new Message(); try { retMsg = ncmsInterface.downLoadMatchInfo(recieveMsg); if (retMsg.DES) { retMsg.dataContent = NccmFunction.decrypt(retMsg.dataContent, sKey); } if (retMsg.GZipCompress) { retMsg.dataContent = NccmFunction.gZipDeCompress(retMsg.dataContent); } Type type = typeof(RecieveHospitalMatchInfoResult); RecieveHospitalMatchInfoResult result = (RecieveHospitalMatchInfoResult)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(retMsg.dataContent, type); return(result); } catch (Exception err) { throw err; } }
/// <summary> /// 上传匹配信息 /// </summary> /// <param name="hisData"></param> /// <param name="upLoadfaildItems">返回的上传失败的记录</param> /// <param name="strMsg">返回的消息</param> /// <returns></returns> public static bool UploadMatchInfo(RecieveHospitalMatchInfo hisData, out ItemMatchInfo[] upLoadfaildItems, out string strMsg) { upLoadfaildItems = null; strMsg = ""; string strParameter = Newtonsoft.Json.JavaScriptConvert.SerializeObject(hisData); Message recieveMsg = new Message(); recieveMsg.DES = false; recieveMsg.GZipCompress = false; recieveMsg.dataContent = strParameter; Message retMsg = new Message(); try { retMsg = ncmsInterface.recieveHospitalMatchInfo(recieveMsg); if (retMsg.DES) { retMsg.dataContent = NccmFunction.decrypt(retMsg.dataContent, sKey); } if (retMsg.GZipCompress) { retMsg.dataContent = NccmFunction.gZipDeCompress(retMsg.dataContent); } Type type = typeof(RecieveHospitalMatchInfoResult); RecieveHospitalMatchInfoResult result = (RecieveHospitalMatchInfoResult)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(retMsg.dataContent, type); if (result.resultId) { upLoadfaildItems = result.itemMatchInfo; strMsg = result.resultString; return(true); } else { throw new Exception(result.resultString); } } catch (Exception err) { throw err; } }
/// <summary> /// 下载匹配信息 /// </summary> public static void DownLoadAndSaveMatchInfo() { List <ItemMatchInfo> matchList = new List <ItemMatchInfo>(); DownLoadItem hisData = new DownLoadItem(); JoinArea joinArea = new JoinArea(); joinArea.code = CURRENT_JOINAREA_CODE; joinArea.name = CURRENT_JOINAREA_NAME; DataClass dataClass = new DataClass(); dataClass.dataClassName = NcmsDataClass.新农合数据.ToString(); dataClass.dataClassValue = ((int)NcmsDataClass.新农合数据).ToString(); DataType dataType = new DataType(); dataType.dataTypeName = NcmsDataType.收费项目.ToString(); dataType.dataTypeValue = ((int)NcmsDataType.收费项目).ToString(); OperType operType = new OperType(); operType.operTypeName = NcmsOperType.查询.ToString(); operType.operTypeValue = ((int)NcmsOperType.查询).ToString(); Condition Content_type = new Condition(); Condition Approve_status = new Condition(); Condition Current_page = new Condition(); Condition Page_size = new Condition(); Content_type.condition_displayname = "项目类型"; Content_type.condition_name = "CONTENT_TYPE"; Content_type.condition_value = "1"; Approve_status.condition_displayname = "审核状态"; Approve_status.condition_name = "APPROVE_STATUS"; Approve_status.condition_value = "4"; int current_page = 1; Current_page.condition_displayname = "要下载的页码"; Current_page.condition_name = "CURRENT_PAGE"; Current_page.condition_value = current_page.ToString(); int pageSize = 100; Page_size.condition_displayname = "页面大小"; Page_size.condition_name = "PAGE_SIZE"; Page_size.condition_value = pageSize.ToString(); Condition[] cond = new Condition[] { Content_type, Approve_status, Current_page, Page_size }; hisData.joinArea = joinArea; hisData.dataClass = dataClass; hisData.dataType = dataType; hisData.operType = operType; hisData.conditions = cond; hisData.uploadorg = "400866951"; try { RecieveHospitalMatchInfoResult result = NccmInterfaces.DownLoadMatchInfo(hisData); if (result.resultId) { matchList = result.itemMatchInfo.ToList <ItemMatchInfo>(); current_page = 2; while (1 == 1) { //重新指定要下载的页 hisData.conditions[2].condition_value = current_page.ToString(); result = NccmInterfaces.DownLoadMatchInfo(hisData); if (result.itemMatchInfo == null) { break; } if (result.resultId) { //追加到List for (int i = 0; i < result.itemMatchInfo.Length; i++) { matchList.Add(result.itemMatchInfo[i]); } } else { throw new Exception(result.resultString); } current_page++; } //保存到数据库 try { oleDb.BeginTransaction(); HIS.SYSTEM.Core.BindEntity <Model.NCMS_MATCH_CATALOG> .CreateInstanceDAL(oleDb).Delete(""); foreach (ItemMatchInfo match in matchList) { Model.NCMS_MATCH_CATALOG model = new HIS.Model.NCMS_MATCH_CATALOG(); model.APPROVE_STATUS = match.approve_status; model.APPROVETIME = match.approveTime; model.HOSPITAL_CODE = match.hospital_code; model.IF_EQUAL = match.if_equal; model.MEDORG_CODE = match.medorg_code; model.NCMS_CODE = match.ncms_code; model.REGION_CODE = match.region_code; model.STATUS = match.status; model.TYPE = match.type; model.UPLOAD_TIME = match.upload_time; model.UPLOADER = match.uploader; HIS.SYSTEM.Core.BindEntity <Model.NCMS_MATCH_CATALOG> .CreateInstanceDAL(oleDb).Add(model); } oleDb.CommitTransaction(); } catch (Exception err) { oleDb.RollbackTransaction(); throw err; } } } catch (Exception err) { throw new Exception(err.Message); } }