/// <summary> /// 写入freezer临床数据和添加FTP /// </summary> /// <param name="datadic"></param> /// <param name="imgguid"></param> /// <returns></returns> public string Import_TestData(Dictionary<string, string> datadic, string imgguid, string PatientName, string keshi) { string res = ""; //获取账号密码 Dictionary<string, string> logDic = new Dictionary<string, string>();//操作日志记录 Dictionary<string, string> importResult = new Dictionary<string, string>();//返回信息 List<Dictionary<string, string>> dataDicList = new List<Dictionary<string, string>>();//存放临床数据 if (datadic.Count > 0) { dataDicList.Add(datadic); if (dataDicList.Count > 0) { FreezerProUtility.Fp_Common.UnameAndPwd up = GetUp(); string improtTestDataResult = ImportTestData(dataDicList, up, keshi); if (improtTestDataResult.Contains("\"status\":\"DONE\"") && improtTestDataResult.Contains("\"success\":true,")) { //导入成功--保存数据到本地数据库 RuRo.Model.TB_CONSENT_FORM model = new Model.TB_CONSENT_FORM(); model.Path = datadic["图片网络链接地址"]; model.PatientID = Convert.ToInt32(datadic["Sample Source"]); model.Consent_From = imgguid; model.PatientName = PatientName; RuRo.BLL.TB_CONSENT_FORM bll = new BLL.TB_CONSENT_FORM(); bll.Add(model); RuRo.Common.CookieHelper.ClearCookie("uid"); RuRo.Common.CookieHelper.ClearCookie("pname"); res = "导入知情同意书成功,图片地址:" + datadic["图片网络链接地址"]; return res; } else { res = "系统不存在此样品源,导入失败,请录入样品源后重新上传!"; return res; } } else { res = "导入系统失败,请检查网络是否通畅"; } } return res; }
//存放FTP的话把这个加到文件里面 //<add key="FTPFolder" value="192.168.1.101"/> //<add key="FTPFolder2" value="192.168.1.101:23"/> //<add key="FTPUser" value="admin"/> //<add key="FTPPWD" value="admin123"/> //<add key="FTPPort" value="23"/> public void ProcessRequest(HttpContext context) { //不知道为什么获取不到 //HttpPostedFile file = context.Request.Files["userFile"]; #region 获取基本参数 string filePath = context.Request["imgpath"]; string strUid = context.Request.Params["suid"].ToString(); string strName = context.Request.Params["spname"].ToString(); string strdate = context.Request.Params["timedate"].ToString(); string keshi = GetKeshi(); string strPy = keshicode(keshi);//将科室转化 Dictionary<string, string> dickeshi = new Dictionary<string, string>(); dickeshi.Add("keshi", keshi); dickeshi.Add("SP", strPy); //FileUpload myfile = new FileUpload(); HttpPostedFile myfile = context.Request.Files["imgpath"]; #endregion Dictionary<string, string> dicdata = new Dictionary<string, string>(); string path = @"Consentimg\"; myfile.SaveAs(path); RuRo.Common.Filehleper.DirFileHelper.CreateDir(path); string mes = ""; if (strUid == "" || strdate == "") { mes = "请检查日期是否选择"; context.Response.Write(mes); } else { #region 上传 try { #region 将图片保存到本地 生成编码 再判断是否存在 DateTime dt = new DateTime(); dt = Convert.ToDateTime(strdate); string date = dt.ToString("yyyyMMdd"); string fileName = Path.GetFileName(filePath); string[] SplitFileName = fileName.Split('.'); string mapPath = context.Server.MapPath("~"); string savePath = mapPath + @"\" + path + dickeshi["SP"].ToString() + "_" + strUid + "-" + date + "." + SplitFileName[1];//设置路径+(文件名称:path + strUid + date +"."+ SplitFileName[1]) string imgName = dickeshi["SP"].ToString() + "_" + strUid + "-" + date + "." + SplitFileName[1];//获取文件名称 string imgGuid = dickeshi["SP"].ToString() + "_" + strUid + "-" + date;//生成唯一标识 //判断数据是否存在 BLL.TB_CONSENT_FORM bll = new BLL.TB_CONSENT_FORM(); string strJson = bll.Sel_TB_CONSENT_FORM_Count_Bll(strUid, imgGuid); if (strJson == "") { try { Bitmap map = new Bitmap(filePath); //map.Save(savePath); long quality = long.Parse(System.Configuration.ConfigurationManager.AppSettings["ImgQuality"]); Common.ImageHelper.ImageClass img = new Common.ImageHelper.ImageClass(); //压缩图片并保存 img.Compress(filePath, savePath, map.Width, map.Height, quality); //map.Clone(); map.Dispose(); } catch (System.Exception ex) { Common.LogHelper.WriteError("MAP文件未找到"); } //上传到指定的FTP空间 mes = Sel_Folder(dt, savePath, imgName, dickeshi); if (mes.Contains("Download")) { //写入Freezerpro文件和数据库 dicdata = Set_dataDic(strUid, mes); mes = Import_TestData(dicdata, imgGuid, strName, dickeshi["keshi"].ToString()); //清空Consentimg目录下的图片 if (RuRo.Common.Filehleper.DirFileHelper.IsExistDirectory(mapPath + "\\" + path)) { RuRo.Common.Filehleper.DirFileHelper.DeleteDirectory(mapPath + "\\" + path); } context.Response.Write(mes); } else { //context.Response.Write(mes); //context.Response.End(); //写日志 RuRo.Model.TB_SAMPLE_LOG log_model = new Model.TB_SAMPLE_LOG(); log_model.MSG = "知情同意书管理:" + mes; RuRo.BLL.TB_SAMPLE_LOG log_bll = new BLL.TB_SAMPLE_LOG(); log_bll.Add(log_model); //返回消息 context.Response.Write(mes); context.Response.End(); } } else { mes = "该知情同意书已经存在"; context.Response.Write(mes); } #endregion //将图片保存到FTP操作 } catch (Exception e) { mes = e.ToString(); context.Response.Write(mes); } #endregion } }