private void SaveToHIS(DataTable bljc, PathHISJK.ODBCHelper bb) { string blh = bljc.Rows[0]["F_BLH"] == null ? "" : bljc.Rows[0]["F_BLH"].ToString().Trim(); string sqxh = bljc.Rows[0]["F_SQXH"] == null ? "" : bljc.Rows[0]["F_SQXH"].ToString().Trim(); string xm = bljc.Rows[0]["F_XM"] == null ? "" : bljc.Rows[0]["F_XM"].ToString().Trim(); string xb = bljc.Rows[0]["F_XB"] == null ? "" : bljc.Rows[0]["F_XB"].ToString().Trim(); string bbmc = bljc.Rows[0]["F_BBMC"] == null ? "" : bljc.Rows[0]["F_BBMC"].ToString().Trim(); string rysj = bljc.Rows[0]["F_RYSJ"] == null ? "" : bljc.Rows[0]["F_RYSJ"].ToString().Trim(); string blzd = bljc.Rows[0]["F_BLZD"] == null ? "" : bljc.Rows[0]["F_BLZD"].ToString().Trim(); string bgys = bljc.Rows[0]["F_BGYS"] == null ? "" : bljc.Rows[0]["F_BGYS"].ToString().Trim(); string shys = bljc.Rows[0]["F_SHYS"] == null ? "" : bljc.Rows[0]["F_SHYS"].ToString().Trim(); string bgrq = bljc.Rows[0]["F_BGRQ"] == null ? "" : bljc.Rows[0]["F_BGRQ"].ToString().Trim(); mdjpg xx = new mdjpg(); string bglj = ""; xx.BMPTOJPG(blh, ref bglj, "CG", "0"); string ftpserver = f.ReadString("hisftp", "ftpip", "").Replace("\0", ""); string ftpuser = f.ReadString("hisftp", "user", "ZKFTP").Replace("\0", ""); string ftppwd = f.ReadString("hisftp", "pwd", "ZKFTP").Replace("\0", ""); string txpath = f.ReadString("hisftp", "txpath", "PACSDATA").Replace("\0", ""); string ftppath = Path.Combine(ftpserver, txpath); if (bglj != "") { FtpWeb fw = new FtpWeb(ftpserver, txpath, ftpuser, ftppwd); string status = ""; fw.Upload(@"C:\temp\" + blh + @"\" + blh + @"_1.jpg", "", out status); string insertsql = string.Format("insert into dbo.T_SYN_ZK_CHECK(PACS_CheckID,CISID,PatientNameChinese,PatientSex,PatientBirthday,StudyType,StudyBodyPart,ClinicDiagnose,ClinicSymptom,ClinicAdvice,IMGStrings,StudyState,Check_Doc,Check_Date,Report_Doc,Report_Date,Audit_Doc,Audit_Date) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')", blh, sqxh, xm, xb, "", "GJ", bbmc, blzd, rysj, "", blh + @"_1.jpg", 5, "", "", bgys, bgrq, shys, bgrq); OdbcCommand cmd = bb.GetOdbcStringCommond(insertsql); if (msg == "1") { MessageBox.Show(cmd.Connection.ConnectionString); } bb.ExecuteNonQuery(cmd); } }
public string CaQZ(string blh, string bglx, string bgxh, string debug, DataTable dt_cg, string yhmc, string bgzt) { string msg = f.ReadString("savetohis", "camsg", "0").Replace("\0", ""); string logname = "CAZGQJK"; dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); string blbh = blh; if (bglx == "bc" || bglx == "bd") { blbh = blh + bglx + bgxh; } try { if (debug == "1") { log.WriteMyLog("开始签字。。。", logname); } DataTable dt_bd = new DataTable(); DataTable dt_bc = new DataTable(); //补充审核 string sql_str = ""; if (bglx == "bc") { sql_str = "select * from T_BCBG where F_BLH='" + blh + "' and F_BC_BGZT='已审核' and F_BC_BGXH='" + bgxh + "'"; dt_bc = aa.GetDataTable(sql_str, "bcbg"); if (dt_bc.Rows.Count <= 0) { log.WriteMyLog("未查询到此补充报告" + blbh, logname); return("0"); } } //小冰冻审核 if (bglx == "bd") { sql_str = "select * from T_BDBG where F_BLH='" + blh + "' and F_BD_BGZT='已审核' and F_BD_BGXH='" + bgxh + "'"; dt_bd = aa.GetDataTable(sql_str, "bdbg"); if (dt_bd.Rows.Count <= 0) { log.WriteMyLog("未查询到此冰冻报告" + blbh, logname); return("0"); } } string TimeSign_XML = ""; //时间戳服务地址 string yztime = f.ReadString("CA", "yztime", "0"); if (yztime == "1") { string timeip = f.ReadString("CA", "timeip_web", "http://172.20.89.23:8080/xjcaTimestamp/services/sign"); string hash = blbh + "^" + dt_cg.Rows[0]["F_XM"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_NL"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_XM"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_BRBH"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_SQXH"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_ZYH"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_MZH"].ToString().Trim() + "^" + dt_cg.Rows[0]["F_SFZH"].ToString().Trim(); if (debug == "1") { log.WriteMyLog("验证时间戳:" + blbh + "\n" + hash, logname); } //返回值时间戳xml(TimeSign_XML)需要写人数据库 StringBuilder md5 = new StringBuilder(Getmd5(hash)); try { TimeSign_XML = XJCA_TimeSign(timeip, blbh, md5); } catch (Exception ee2) { if (msg == "1") { MessageBox.Show("CA签名:时间戳验证失败:" + ee2.Message); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "时间戳验证失败:" + ee2.Message, "ZGQJK", "CA签名"); log.WriteMyLog("CA签名:时间戳验证失败:" + ee2.Message, logname); return("0"); } if (debug == "1") { log.WriteMyLog("CA签名:TimeSign_XML:" + TimeSign_XML, logname); } if (debug == "1") { log.WriteMyLog("CA签名:时间戳完成", logname); } } //签章---------------------------------- if (debug == "1") { log.WriteMyLog("CA签名:开始签章。。。", logname); } //签章原文 string xmlstr = ""; string bgwy = ""; if (bglx == "cg" || bglx == "") { xmlstr = xmlstr + "<F_BLZD><![CDATA[" + dt_cg.Rows[0]["F_BLZD"].ToString() + "]]></F_BLZD>"; xmlstr = xmlstr + "<F_BGYS>" + dt_cg.Rows[0]["F_BGYS"].ToString() + "</F_BGYS>"; xmlstr = xmlstr + "<F_SHYS>" + dt_cg.Rows[0]["F_SHYS"].ToString() + "</F_SHYS>"; xmlstr = xmlstr + "<F_BGRQ>" + dt_cg.Rows[0]["F_BGRQ"].ToString() + "</F_BGRQ>"; xmlstr = xmlstr + "<F_SPARE5>" + dt_cg.Rows[0]["F_spare5"].ToString() + "</F_SPARE5>"; xmlstr = xmlstr + "<F_BGLX>" + "cg1" + "</F_BGLX>"; } if (bglx == "bc" && dt_bc.Rows.Count > 0) { xmlstr = xmlstr + "<F_BLZD><![CDATA[" + dt_bc.Rows[0]["F_BCZD"].ToString() + "]]></F_BLZD>"; xmlstr = xmlstr + "<F_BGYS>" + dt_bc.Rows[0]["F_BC_BGYS"].ToString() + "</F_BGYS>"; xmlstr = xmlstr + "<F_SHYS>" + dt_bc.Rows[0]["F_BC_SHYS"].ToString() + "</F_SHYS>"; xmlstr = xmlstr + "<F_BGRQ>" + dt_bc.Rows[0]["F_BC_BGRQ"].ToString() + "</F_BGRQ>"; xmlstr = xmlstr + "<F_SPARE5>" + dt_bc.Rows[0]["F_BC_spare5"].ToString() + "</F_SPARE5>"; xmlstr = xmlstr + "<F_BGLX>" + "bc" + bgxh + "</F_BGLX>"; } if (bglx == "bd") { xmlstr = xmlstr + "<F_BLZD><![CDATA[" + dt_bd.Rows[0]["F_BDZD"].ToString() + "]]></F_BLZD>"; xmlstr = xmlstr + "<F_BGYS>" + dt_bd.Rows[0]["F_BD_BGYS"].ToString() + "</F_BGYS>"; xmlstr = xmlstr + "<F_SHYS>" + dt_bd.Rows[0]["F_BD_SHYS"].ToString() + "</F_SHYS>"; xmlstr = xmlstr + "<F_BGRQ>" + dt_bd.Rows[0]["F_BD_BGRQ"].ToString() + "</F_BGRQ>"; xmlstr = xmlstr + "<F_SPARE5>" + dt_bd.Rows[0]["F_BD_BGRQ"].ToString() + "</F_SPARE5>"; xmlstr = xmlstr + "<F_BGLX>" + "bd" + dt_bd.Rows[0]["F_BD_BGXH"].ToString() + "</F_BGLX>"; } if (xmlstr == "") { log.WriteMyLog("CA签名:签章数据内容为空,请重新审核", logname); if (msg == "1") { MessageBox.Show("CA签名失败:签章数据内容为空"); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "签章数据内容为空", "ZGQJK", "CA签名"); return("0"); } string bgyw = ""; bgyw = "<BL>"; bgyw = bgyw + "<F_BLBH>" + blbh + "</F_BLBH>"; bgyw = bgyw + "<F_BLH>" + blh + "</F_BLH>"; bgyw = bgyw + "<F_XM>" + blh + "</F_XM>"; bgyw = bgyw + "<F_XB>" + blh + "</F_XB>"; bgyw = bgyw + "<F_NL>" + blh + "</F_NL>"; bgyw = bgyw + "<F_ZYH>" + blh + "</F_ZYH>"; bgyw = bgyw + "<F_MZH>" + blh + "</F_MZH>"; bgyw = bgyw + "<F_SQXH>" + blh + "</F_SQXH>"; bgyw = bgyw + "<F_YZID>" + blh + "</F_YZID>"; bgyw = bgyw + "<F_BRBH>" + blh + "</F_BRBH>"; bgyw = bgyw + "<F_SFZH>" + blh + "</F_SFZH>"; bgyw = bgyw + "<F_SDRQ>" + blh + "</F_SDRQ>"; bgyw = bgyw + "<F_CH>" + blh + "</F_CH>"; bgyw = bgyw + xmlstr + "</BL>"; if (debug == "1") { log.WriteMyLog("CA签名:签章内容:" + bgyw, logname); } try { int len = 0; StringBuilder signxml = new StringBuilder(100000); bool qzrtn = XJCA_SignSeal(Getmd5(bgyw), signxml, ref len); if (debug == "1") { log.WriteMyLog("CA签名:" + signxml.ToString(), logname); } if (!qzrtn) { log.WriteMyLog("CA签名:数字签名失败,请重新审核" + qzrtn, logname); if (msg == "1") { MessageBox.Show("CA签名:数字签名失败,请重新审核" + qzrtn); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:数字签名失败" + qzrtn, "ZGQJK", "CA签名"); return("0"); } else { string sign = signxml.ToString().Trim(); if (sign == "") { log.WriteMyLog("CA签名:KEY密码验证失败:签名失败", logname); if (msg == "1") { MessageBox.Show("CA签名:KEY密码验证失败:签名失败"); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:KEY密码验证失败:签名失败", "ZGQJK", "CA签名"); return("0"); } if (sign.Split(',')[0].Trim() == "") { log.WriteMyLog("CA签名:KEY密码验证失败:签名失败", logname); if (msg == "1") { MessageBox.Show("CA签名失败:KEY密码验证失败:签名失败"); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:KEY密码验证失败:签名失败", "ZGQJK", "CA签名"); return("0"); } if (debug == "1") { log.WriteMyLog("CA签名:签字通过,解析返回值", logname); } try { // 签章返回的信息signxml 包含签章数据,证书内容,证书id,以“,”隔开,保存签章数据和证书id string[] getsignxml = signxml.ToString().Split(','); //签章数据 string signxml_str = getsignxml[0]; //证书内容 string cert = getsignxml[1]; //证书id string certID = getsignxml[2]; //将signxml,,TimeSign_XML等返回值 存入数据库------------- try { string sqlstr = "insert into T_CAXX(F_blbh,blh,RQ,KeyName,bgnr,TimeSign_XML,signxml,cert,certID) values ('" + blbh + "','" + blh + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + yhmc + "','" + bgyw + "','" + TimeSign_XML + "','" + signxml.ToString() + "','" + cert + "','" + certID + "') "; int x = SQL_ExecuteNonQuery(sqlstr); if (x <= 0) { log.WriteMyLog("CA签名:写入数据库T_SZQM失败", logname); if (msg == "1") { MessageBox.Show("CA签名:写入数据库T_SZQM失败"); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:写入数据库T_SZQM失败", "ZGQJK", "CA签名"); return("0"); } else { if (debug == "1") { log.WriteMyLog("CA签名:插入T_SZQM完成", logname); } if (bglx == "cg") { aa.ExecuteSQL("update T_JCXX set F_SZQZ='1' where F_BLH='" + blh + "'"); } if (bglx == "bc") { aa.ExecuteSQL("update T_BCBG set F_SZQZ='1' where F_BLH='" + blh + "' and F_bc_bgxh='" + bgxh + "'"); } if (bglx == "bd") { aa.ExecuteSQL("update T_BDBG set F_SZQZ='1' where F_BLH='" + blh + "' and F_bd_bgxh='" + bgxh + "'"); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:签名成功", "ZGQJK", "CA签名"); } } catch (Exception ee7) { log.WriteMyLog("CA签名:写入数据库异常:" + ee7.Message, logname); if (msg == "1") { MessageBox.Show("CA签名:写入数据库异常:" + ee7.Message); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:写入数据库异常:" + ee7.Message, "ZGQJK", "CA签名"); return("0"); } } catch (Exception ee8) { log.WriteMyLog("CA签名:解析签名数据异常:" + ee8.Message, logname); if (msg == "1") { MessageBox.Show("CA签名:解析签名数据异常:" + ee8.Message); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:解析签名数据异常:" + ee8.Message, "ZGQJK", "CA签名"); return("0"); } } log.WriteMyLog("CA签名:签名完成", logname); } catch (Exception ee9) { log.WriteMyLog("CA签名:签名异常:" + ee9.Message, logname); if (msg == "1") { MessageBox.Show("CA签名:签名异常:" + ee9.Message); } ZgqClass.BGHJ(blh, yhmc, "数字签名", "CA签名:签名异常:" + ee9.Message, "ZGQJK", "CA签名"); return("0"); } //---------------------------------------------- //----------------获取签章图片---------------------- //---------------------------------------------- string getbmpfs = f.ReadString("CA", "getbmpfs", "2").Replace("\0", "").Trim(); string upbmpfs = f.ReadString("CA", "upbmpfs", "0").Replace("\0", "").Trim(); string bmppath = ZgqClass.GetSz("view", "szqmlj", Application.StartupPath.ToString() + "\\rpt-szqm\\ysbmp").Replace("\0", ""); if (getbmpfs == "0") { goto GetEwm; } if (getbmpfs == "2") { if (File.Exists(bmppath + "\\" + yhmc + ".bmp")) { goto GetEwm; } } if (!Directory.Exists(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\")) { Directory.CreateDirectory(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\"); } if (debug == "1") { log.WriteMyLog("获取签章图片开始。。。", logname); } bool ss = XJCA_GetSealBMPB(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp", 1); // XJCA_ResetDevice(); if (ss) { if (!File.Exists(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp")) { log.WriteMyLog("获取签章图片失败" + Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp", logname); } if (debug == "1") { log.WriteMyLog("获取签章图片成功,开始上传。。", logname); } if (upbmpfs == "1") { if (debug == "1") { log.WriteMyLog("上传签名图片:" + Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp --->" + bmppath + yhmc + ".bmp", logname); } File.Copy(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp", bmppath + yhmc + ".bmp", true); if (!File.Exists(bmppath + yhmc + ".bmp")) { log.WriteMyLog("签章图片上传失败" + bmppath + yhmc + ".bmp", logname); return("0"); } if (debug == "1") { log.WriteMyLog("签章图片上传成功", logname); } return("1"); } if (upbmpfs == "2") { ///////上传签章图片至ftp--------------------- string ftpServerIP = f.ReadString("ftp", "ftpip", ""); string ftpUserID = f.ReadString("ftp", "user", ""); string ftpPassword = f.ReadString("ftp", "pwd", ""); string ftpszqmpath = f.ReadString("ca", "ftpszqmpath", "/pathsetup/pathqc/rpt-szqm/YSBMP/"); string ftpURI = "ftp://" + ftpServerIP + "/" + ftpszqmpath + "/"; string status = ""; FtpWeb fw = new FtpWeb(ftpServerIP, ftpszqmpath, ftpUserID, ftpPassword); fw.Upload(Application.StartupPath.ToString() + "\\rpt-szqm\\YSBMP\\" + yhmc + ".bmp", "", out status); if (status == "Error") { log.WriteMyLog("CA签名:签章图片上传失败,请重新审核", logname); return("0"); } if (debug == "1") { log.WriteMyLog("签章图片上传成功", logname); } } } else { if (debug == "1") { log.WriteMyLog("签章图片获取失败,请重新审核", logname); } return("1"); } /////验章 // XJCAverify.(M_signxml, M_signxml.Length, Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP", 7, 3, 3, 0); GetEwm: # region 获取二维码图片 string get2wm = f.ReadString("ca", "get2wm", "0").Replace("\0", ""); if (get2wm == "1") { if (!Directory.Exists(Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\")) { Directory.CreateDirectory(Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\"); } else { DirectoryInfo dir = new DirectoryInfo(Application.StartupPath.ToString() + @"\rpt-szqm\MakePdfFile\"); foreach (FileInfo ff in dir.GetFiles("*.*")) { ff.Delete(); } } StringBuilder M_signxml = new StringBuilder(blbh, 10000); XJCA_MakePdf417ToFile(M_signxml, M_signxml.Length, Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP", 7, 3, 3, 0); //XJCA_ResetDevice(); if (!File.Exists(Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP")) { log.WriteMyLog("二维码不存在" + Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP", logname); return("1"); } string up2wmfs = f.ReadString("ca", "up2wmfs", "1").Replace("\0", ""); if (up2wmfs == "1") { string ewmpath = f.ReadString("ca", "ewmpath", Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile").Replace("\0", ""); if (debug == "1") { log.WriteMyLog("上传二维码图片:" + Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP --->" + ewmpath + "\\" + blbh + "EWM.BMP", logname); } File.Copy(Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP", ewmpath + "\\" + blbh + "EWM.BMP", true); if (!File.Exists(ewmpath + "\\" + blbh + "EWM.BMP")) { log.WriteMyLog("二维码图片上传失败" + ewmpath + "\\" + blbh + "EWM.BMP", logname); return("0"); } if (debug == "1") { log.WriteMyLog("二维码图片上传成功", logname); } return("1"); } if (upbmpfs == "2") { ///////上传签章图片至ftp--------------------- string ftpServerIP = f.ReadString("ftp", "ftpip", ""); string ftpUserID = f.ReadString("ftp", "user", ""); string ftpPassword = f.ReadString("ftp", "pwd", ""); string ftpewmpath = f.ReadString("ca", "ftpewmpath", "/pathimages/szqm/MakePdfFile/"); string ftpURI = "ftp://" + ftpServerIP + "/" + ftpewmpath + "/"; string status = ""; FtpWeb fw = new FtpWeb(ftpServerIP, ftpewmpath, ftpUserID, ftpPassword); fw.Upload(Application.StartupPath.ToString() + "\\rpt-szqm\\MakePdfFile\\" + blbh + "EWM.BMP", "", out status); if (status == "Error") { log.WriteMyLog("二维码图片上传失败,请重新审核!", logname); return("0"); } if (debug == "1") { log.WriteMyLog("二维码图片上传成功", logname); } } } return("1"); } catch (Exception ee1) { log.WriteMyLog(ee1.Message, logname); return("0"); } #endregion }
public void pathtohis(string blh, string debug) { dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); msg = f.ReadString("savetohis", "msg", ""); DataTable jcxx = new DataTable(); try { jcxx = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "jcxx"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); return; } if (jcxx == null) { MessageBox.Show("病理数据库设置有问题!"); log.WriteMyLog("病理数据库设置有问题!"); return; } if (jcxx.Rows.Count < 1) { MessageBox.Show("病理号有错误!"); log.WriteMyLog("病理号有错误!"); return; } if (jcxx.Rows[0]["F_brlb"].ToString().Trim() != "体检") { //不检查审核状态 if (jcxx.Rows[0]["F_bgzt"].ToString().Trim() != "已审核") { return; } //string bgzt = dataGridView1.CurrentRow.Cells["报告状态"].Value.ToString().Trim(); if (jcxx.Rows[0]["F_brbh"].ToString().Trim() == "") { log.WriteMyLog(blh + ",无病人编号,不处理!"); return; } string brlb = ""; string brbh = ""; string brxb = ""; string zyh = ""; string yzid = ""; string shys = jcxx.Rows[0]["F_SHYS"].ToString().Trim(); string sdrq = jcxx.Rows[0]["F_sdrq"].ToString().Trim(); string bgrq = jcxx.Rows[0]["F_bgrq"].ToString().Trim(); brxb = jcxx.Rows[0]["F_xb"].ToString().Trim(); brxm = jcxx.Rows[0]["F_xm"].ToString().Trim(); brbh = jcxx.Rows[0]["F_brbh"].ToString().Trim(); // blh = jcxx.Rows[0]["F_blh"].ToString().Trim(); zyh = jcxx.Rows[0]["F_zyh"].ToString().Trim(); yzid = jcxx.Rows[0]["F_yzid"].ToString().Trim(); string his_blh = ""; if (jcxx.Rows[0]["F_brlb"].ToString().Trim() == "住院") { brlb = "1"; his_blh = jcxx.Rows[0]["F_zyh"].ToString().Trim(); //zybh = jcxx.Rows[0]["F_yzid"].ToString().Trim(); } else { if (jcxx.Rows[0]["F_brlb"].ToString().Trim() == "门诊") { brlb = "0"; his_blh = jcxx.Rows[0]["F_mzh"].ToString().Trim(); } //zybh = jcxx.Rows[0]["F_brbh"].ToString().Trim(); } bg01(brlb, brbh, blh, "1", his_blh, brxb, bgrq, yzid, sdrq, shys); } else { //------------------------------ // string msg = f.ReadString("savetohis", "msg", ""); //string odbcstr = f.ReadString("savetohis", "odbcsql", "Data Source=192.168.0.1;Initial Catalog=zonekingnet;User Id=sa;Password=zoneking;"); //获取sz.ini中设置的odbcsql string odbcstr = f.ReadString("savetohis", "odbcsql", "DSN=pathnet-tj;UID=sa;PWD=zoneking;"); //获取sz.ini中设置的odbcsql if (jcxx.Rows[0]["F_SQXH"].ToString().Trim() == "") { log.WriteMyLog("无体检号申请单号,不处理!"); return; } if (jcxx.Rows[0]["F_BGZT"].ToString().Trim() == "已审核") { string jpgname = ""; string ftpstatus = ""; mdjpg mdj = new mdjpg(); try { mdj.BMPTOJPG(blh, ref jpgname, "", ""); } catch (Exception ee) { MessageBox.Show(ee.ToString()); } if (msg == "1") { MessageBox.Show("生成jpg成功"); } //---上传jpg---------- //----------------上传签章jpg至ftp--------------------- string status = ""; string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string ftpServerIP = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpUserID = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftpPassword = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpRemotePath = f.ReadString("ftp", "bgjpgPath", "pathimages/bgjpg").Replace("\0", ""); string tjtxpath = f.ReadString("savetohis", "tjtxpath", "bgjpg"); string jpgpath = ""; if (ftps == "1") { FtpWeb fw = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); string ftpURI = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/"; try { //判断ftp上是否存在该jpg文件 if (fw.fileCheckExist(ftpURI, blh + "_1.jpg")) { //删除ftp上的jpg文件 fw.fileDelete(ftpURI, blh + "_1.jpg").ToString(); } //上传新生成的jpg文件 fw.Upload("C:\\temp\\" + blh + "\\" + blh + "_1.jpg", "", out status); if (status == "Error") { MessageBox.Show("报告jpg上传失败,请重新审核!"); return; } } catch { if (msg == "1") { MessageBox.Show("上传报告jpg文件异常"); } return; } } else { if (tjtxpath == "") { log.WriteMyLog("sz.ini txpath图像目录未设置"); return; } try { File.Copy(ftplocal + "\\" + blh + "\\" + blh + "_1.jpg", tjtxpath + "\\" + blh + "_1.jpg", true); } catch (Exception ee) { log.WriteMyLog("源路径:" + ftplocal + "\\" + blh + "_1.jpg" + "\n" + " 目标路径:" + tjtxpath + "\\" + blh + "_1.jpg"); log.WriteMyLog("复制文件异常!" + ee.ToString()); return; } } if (msg == "1") { MessageBox.Show("上传报告jpg文件完成"); } try { if (System.IO.Directory.Exists(@"c:\temp\" + blh)) { System.IO.Directory.Delete(@"c:\temp\" + blh, true); } } catch { log.WriteMyLog("删除临时目录" + blh + "失败"); return; } ////////////////////////////////////////////////////////// ///////回写体检数据库-T_SYN_TCT_CHECK//////////////////////////////////// string tj_blzd = jcxx.Rows[0]["F_blzd"].ToString().Trim(); string tj_jcsj = jcxx.Rows[0]["F_rysj"].ToString().Trim(); string tj_ysyj = jcxx.Rows[0]["F_BZ"].ToString().Trim(); DataTable TJ_bljc = new DataTable(); TJ_bljc = aa.GetDataTable(" select * from T_TBS_BG where F_blh='" + blh + "'", "blxx"); if (TJ_bljc.Rows.Count > 0) { if (jcxx.Rows[0]["F_blk"].ToString().Trim() == "TCT体检" || jcxx.Rows[0]["F_blk"].ToString().Trim() == "TCT") { tj_jcsj = "标本满意度:" + TJ_bljc.Rows[0]["F_TBS_BBMYD"].ToString().Trim() + "\n" + TJ_bljc.Rows[0]["f_tbs_xbl"].ToString().Trim() + "\n"; tj_jcsj = tj_jcsj + TJ_bljc.Rows[0]["F_TBS_XBXM1"].ToString().Trim() + "\n" + TJ_bljc.Rows[0]["F_TBS_XBXM2"].ToString().Trim() + "\n"; tj_jcsj = tj_jcsj + TJ_bljc.Rows[0]["F_TBS_XBXM3"].ToString().Trim() + "\n"; tj_jcsj = tj_jcsj + "病原微生物:" + TJ_bljc.Rows[0]["F_TBS_WSW6"].ToString().Trim() + "\n" + TJ_bljc.Rows[0]["F_TBS_WSW2"].ToString().Trim() + "\n" + TJ_bljc.Rows[0]["F_TBS_WSW1"].ToString().Trim() + "\n"; tj_jcsj = tj_jcsj + TJ_bljc.Rows[0]["F_TBS_WSW3"].ToString().Trim() + "\n" + TJ_bljc.Rows[0]["F_TBS_BDXM1"].ToString().Trim() + "\n"; //////////////////////////////////// tj_blzd = "诊断:" + TJ_bljc.Rows[0]["F_TBSZD"].ToString().Trim() + "\n" + "炎症程度:" + TJ_bljc.Rows[0]["F_TBS_YZCD"].ToString().Trim(); if (TJ_bljc.Rows[0]["F_TBS_BCYJ1"].ToString().Trim() != "") { tj_ysyj = tj_ysyj + "补充意见1:" + TJ_bljc.Rows[0]["F_TBS_BCYJ1"].ToString().Trim() + "\n"; } if (TJ_bljc.Rows[0]["F_TBS_BCYJ2"].ToString().Trim() != "") { tj_ysyj = tj_ysyj + "补充意见2:" + TJ_bljc.Rows[0]["F_TBS_BCYJ2"].ToString().Trim() + "\n"; } } } tj_blzd = tj_blzd + "\n" + tj_ysyj; if (msg == "1") { MessageBox.Show(tj_jcsj); MessageBox.Show(tj_blzd); } string cmdtxt = @"insert into T_SYN_TCT_CHECK(PACS_CheckID,CISID,PACSItemCode,PatientNameChinese,PatientSex,StudyType,StudyBodyPart,ClinicDiagnose,ClinicSymptom,ClinicAdvice,IMGStrings,StudyState,Check_Doc,Check_Date,Report_Doc,Report_Date,Audit_Doc,Audit_Date) values(" + "'" + jcxx.Rows[0]["F_SQXH"].ToString().Trim() + "','" + jcxx.Rows[0]["F_BRBH"].ToString().Trim() + "','" + jcxx.Rows[0]["F_YZID"].ToString().Trim() + "','" + jcxx.Rows[0]["F_XM"].ToString().Trim() + "','" + jcxx.Rows[0]["F_XB"].ToString().Trim() + "'," + "'BL','" + jcxx.Rows[0]["F_bbmc"].ToString().Trim() + "','" + tj_blzd + "','" + tj_jcsj + "','','" + @"pathimages/bgjpg/" + blh + "_1.jpg" + "',5,'" + jcxx.Rows[0]["F_BGYS"].ToString().Trim() + "','" + jcxx.Rows[0]["F_SDRQ"].ToString().Trim() + "'," + "'" + jcxx.Rows[0]["F_bgys"].ToString().Trim() + "','" + jcxx.Rows[0]["F_bgrq"].ToString().Trim() + "','" + jcxx.Rows[0]["F_shys"].ToString().Trim() + "','" + jcxx.Rows[0]["F_SPARE5"].ToString().Trim() + "')"; // int x = SQL_ExecuteNonQuery(odbcstr, cmdtxt, msg); int x = Odbc_ExecuteNonQuery(odbcstr, cmdtxt, msg); if (msg == "1") { MessageBox.Show("影响行数:" + x.ToString()); } if (x < 1) { log.WriteMyLog("回写体检接口失败。"); } else { aa.ExecuteSQL("update T_JCXX set F_SCBJ='1' where F_BLH='" + blh.Trim() + "'"); } } else { if (jcxx.Rows[0]["F_SCBJ"].ToString().Trim() == "1") { string cmdtxt = "delete from T_SYN_TCT_CHECK where PACS_CheckID='" + jcxx.Rows[0]["F_SQXH"].ToString().Trim() + "' and CISID='" + jcxx.Rows[0]["F_BRBH"].ToString().Trim() + "' and PACSItemCode='" + jcxx.Rows[0]["F_YZID"].ToString().Trim() + "'"; int x = Odbc_ExecuteNonQuery(odbcstr, cmdtxt, msg); } } } }
public static void downtx(string ftp_blh, string txml, odbcdb aa, ref string txlbs, ref string localpath) { //Çå¿Õc:\temp_srĿ¼ if (!System.IO.Directory.Exists(@"c:\temp\" + ftp_blh)) { System.IO.Directory.CreateDirectory(@"c:\temp\" + ftp_blh); } else { try { System.IO.Directory.Delete(@"c:\temp\" + ftp_blh, true); System.IO.Directory.CreateDirectory(@"c:\temp\" + ftp_blh); } catch (Exception e1) { MessageBox.Show(e1.Message.ToString()); } } localpath = @"c:\temp\" + ftp_blh; //ÏÂÔØFTP²ÎÊý string ftpserver = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpuser = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftppwd = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp\\").Replace("\0", ""); string ftpremotepath = f.ReadString("ftp", "ftpremotepath", "pathimages").Replace("\0", ""); string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string txpath = f.ReadString("txpath", "txpath", "").Replace("\0", ""); FtpWeb fw = new FtpWeb(ftpserver, ftpremotepath, ftpuser, ftppwd); //¹²ÏíĿ¼ string gxml = f.ReadString("txpath", "txpath", "").Replace("\0", ""); string gxuid = f.ReadString("txpath", "username", "").Replace("\0", ""); string gxpwd = f.ReadString("txpath", "password", "").Replace("\0", ""); DataTable txlb = aa.GetDataTable("select * from T_tx where F_blh='" + ftp_blh + "' and F_sfdy='1'", "txlb"); string txm = ""; if (ftps == "1")//FTPÏÂÔØ·½Ê½ { for (int i = 0; i < txlb.Rows.Count; i++) { txm = txlb.Rows[i]["F_txm"].ToString().Trim(); string ftpstatus = ""; try { fw.Download(localpath, txml + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), txlb.Rows[i]["F_txm"].ToString().Trim(), out ftpstatus); if (ftpstatus == "Error") { log.WriteMyLog("FTPÏÂÔØͼÏñ³ö´í£¡"); localpath = ""; return; } else { if (f.ReadInteger("TX", "ZOOM", 0) == 1) { int picx = f.ReadInteger("TX", "picx", 320); int picy = f.ReadInteger("TX", "picy", 240); try { prreport.txzoom(localpath + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), localpath + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), picx, picy); } catch (Exception ee2) { log.WriteMyLog("ѹËõͼÏñÒì³££º" + ee2.Message); } } txlbs = txlbs + "<Image INDEX=" + (char)34 + (i + 1).ToString() + (char)34 + ">" + localpath + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim() + "</Image>"; } } catch { log.WriteMyLog("FTPÏÂÔØͼÏñ³ö´í£¡"); } } } else //¹²ÏíÏÂÔØ·½Ê½ { if (txpath == "") { log.WriteMyLog("sz.ini txpathͼÏñĿ¼δÉèÖÃ"); return; } for (int i = 0; i < txlb.Rows.Count; i++) { txm = txlb.Rows[i]["F_txm"].ToString().Trim(); try { try { File.Copy(txpath + txml + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim(), localpath + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim(), true); if (f.ReadInteger("TX", "ZOOM", 0) == 1) { int picx = f.ReadInteger("TX", "picx", 320); int picy = f.ReadInteger("TX", "picy", 240); try { prreport.txzoom(localpath + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), localpath + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), picx, picy); } catch (Exception ee2) { log.WriteMyLog("ѹËõͼÏñÒì³££º" + ee2.Message); } } txlbs = txlbs + "<Image INDEX=" + (char)34 + (i + 1).ToString() + (char)34 + ">" + localpath + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim() + "</Image>"; } catch { } } catch { log.WriteMyLog("¹²ÏíĿ¼²»´æÔÚ£¡"); localpath = ""; return; } } } }
public void pathtohis(string blh, string yymc) { blhgy = blh; string msg = f.ReadString("savetohis", "msg", ""); string sfsctx = f.ReadString("savetohis", "sfsctx", ""); string odbcsql = f.ReadString("savetohis", "odbcsql", ""); if (odbcsql.Trim() != "") { orcon_str = odbcsql; } dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); DataTable bljc = new DataTable(); bljc = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "blxx"); if (bljc == null) { MessageBox.Show("病理数据库设置有问题!"); log.WriteMyLog("病理数据库设置有问题!"); return; } if (bljc.Rows.Count < 1) { MessageBox.Show("病理号有错误!"); log.WriteMyLog("病理号有错误!"); return; } if (bljc.Rows[0]["F_sqxh"].ToString().Trim() == "") { log.WriteMyLog("无申请序号(单据号),不处理!"); return; } //----------- int brlb = 0; switch (bljc.Rows[0]["F_brlb"].ToString().Trim()) { case "门诊": brlb = 1; break; case "急诊": brlb = 2; break; case "住院": brlb = 3; break; case "体检": brlb = 4; break; default: brlb = 0; break; } //--------------- if (bljc.Rows[0]["F_BGZT"].ToString().Trim() == "已审核") { ////-----------------查询---------- string select_to_his = "select * from ZEMR_PACS_REPORT where PACS_NO='" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "'"; OracleConnection orcon = new OracleConnection(orcon_str); OracleCommand orcom = new OracleCommand(select_to_his, orcon); bool x = false; try { orcon.Open(); OracleDataReader dr = orcom.ExecuteReader(); x = dr.HasRows; dr.Close(); orcom.Dispose(); } catch (Exception e) { log.WriteMyLog("查询状态出错:" + e.ToString()); orcom.Dispose(); orcon.Close(); return; } finally { orcom.Dispose(); orcon.Close(); } //-------------增加---------------- int count = 0; string Oraclestring = ""; decimal MODIFY_FLAG = 0; string blzd = "<desc note=\"检查描述\">" + bljc.Rows[0]["F_rysj"].ToString().Trim() + "</desc><diag note=\"诊断\">" + bljc.Rows[0]["F_BLZD"].ToString().Trim() + "</diag>"; MessageBox.Show(blzd.ToString()); ////----------------- MODIFY_FLAG = 1;重新审核—修改---------- //----------------- MODIFY_FLAG =0;审核—增加---------- // Byte[] blzdByte = System.Text.Encoding.ASCII.GetBytes(blzd);//把图片转成 Byte型 二进制流 Byte[] blzdByte = System.Text.Encoding.Default.GetBytes(blzd); if (x) { MODIFY_FLAG = 1; Oraclestring = @"update ZEMR_PACS_REPORT set INSPECT_CONTENT=:ZD,OPERATER='" + bljc.Rows[0]["F_BGYS"].ToString().Trim() + "',INSPECTOR='" + bljc.Rows[0]["F_SHYS"].ToString().Trim() + "',REPORT_TIME=to_date('" + DateTime.Parse(bljc.Rows[0]["F_BGRQ"].ToString().Trim()) + "','YYYY-MM-DD HH24:MI:SS'),LAST_MODIFY_TIME=to_date('" + DateTime.Parse(bljc.Rows[0]["F_BGRQ"].ToString().Trim()) + "','YYYY-MM-DD HH24:MI:SS')" + ", MODIFY_FLAG='" + MODIFY_FLAG + "',REMARK1='" + bljc.Rows[0]["F_SFFH"].ToString().Trim() + "',QUANTITY_FLAG='" + bljc.Rows[0]["F_YYX"].ToString().Trim() + "' where PACS_NO='" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "'"; } else { Oraclestring = @"insert into ZEMR_PACS_REPORT(PACS_NO,PATIENT_ID,EVENT_NO,PATIENT_TYPE,PACS_TYPE,PATIENT_NAME, PATIENT_SEX,PATIENT_AGE,IN_DEPT,BED,WARD,ADDRESS,TELEPHONE,MARRIAGE,PROFESSION,CHECKNO,BARCODE_ID, INSPECT_TYPE,INSPECT_SUB_TYPE,INSPECT_NAME,INSTRUMENT_NAME,INSPECT_CONTENT,APPLICANT,OPERATER, INSPECTOR,OPERATER_TIME,REPORT_TIME,LAST_MODIFY_TIME,MODIFY_FLAG,REMARK1,REMARK2,STATUS,APPLY_NO,QUANTITY_FLAG) values ('" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "','" + bljc.Rows[0]["F_BRBH"].ToString().Trim() + "','" + bljc.Rows[0]["F_ZYH"].ToString().Trim() + "','" + brlb + "'," + MODIFY_FLAG + ",'" + bljc.Rows[0]["F_XM"].ToString().Trim() + "','" + bljc.Rows[0]["F_XB"].ToString().Trim() + "','" + bljc.Rows[0]["F_NL"].ToString().Trim() + "','" + bljc.Rows[0]["F_SJKS"].ToString().Trim() + "','" + bljc.Rows[0]["F_CH"].ToString().Trim() + "','" + bljc.Rows[0]["F_BQ"].ToString().Trim() + "','" + bljc.Rows[0]["F_LXXX"].ToString().Trim() + "','" + "" + "','" + bljc.Rows[0]["F_HY"].ToString().Trim() + "','" + bljc.Rows[0]["F_ZY"].ToString().Trim() + "','" + bljc.Rows[0]["F_BLH"].ToString().Trim() + "','" + "" + "','" + bljc.Rows[0]["F_BLK"].ToString().Trim() + "','" + "" + "','" + "" + "','',:ZD,'" + bljc.Rows[0]["F_SJYS"].ToString().Trim() + "','" + bljc.Rows[0]["F_BGYS"].ToString().Trim() + "','" + bljc.Rows[0]["F_SHYS"].ToString().Trim() + "','" + "" + "',to_date('" + DateTime.Parse(bljc.Rows[0]["F_BGRQ"].ToString().Trim()) + "','YYYY-MM-DD HH24:MI:SS')," + "to_date('" + DateTime.Parse(bljc.Rows[0]["F_SPARE5"].ToString().Trim()) + "','YYYY-MM-DD HH24:MI:SS')," + MODIFY_FLAG + ",'" + bljc.Rows[0]["F_SFFH"].ToString().Trim() + "','" + "" + "'," + MODIFY_FLAG + ",'" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "','" + bljc.Rows[0]["F_YYX"].ToString().Trim() + "')"; } MessageBox.Show(Oraclestring); OracleCommand orcom_insert = new OracleCommand(); orcom_insert.Connection = orcon; orcom_insert.CommandText = Oraclestring; orcom_insert.Parameters.Add("ZD", System.Data.OracleClient.OracleType.Blob, blzdByte.Length); orcom_insert.Parameters["ZD"].Value = blzdByte; try { orcon.Open(); count = orcom_insert.ExecuteNonQuery(); orcom_insert.Dispose(); orcon.Close(); } catch (Exception ee) { log.WriteMyLog("回传报告出错:" + ee.ToString()); orcom_insert.Dispose(); orcon.Close(); return; } finally { orcom_insert.Dispose(); orcon.Close(); } //下面程序中图像信息 if (sfsctx.Trim() == "1")//FTP下载方式 { //下载FTP参数 string ftpserver = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpuser = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftppwd = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpremotepath = f.ReadString("ftp", "ftpremotepath", "pathimages").Replace("\0", ""); string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string txpath = f.ReadString("txpath", "txpath", "").Replace("\0", ""); FtpWeb fw = new FtpWeb(ftpserver, ftpremotepath, ftpuser, ftppwd); string txml = bljc.Rows[0]["F_txml"].ToString().Trim(); //下载图像 DataTable txlb = aa.GetDataTable("select top 4 * from V_dytx where F_blh='" + bljc.Rows[0]["F_BLH"].ToString().Trim() + "'", "txlb"); if (txlb.Rows.Count < 1) { log.WriteMyLog("该病人无图像,不上传"); return; } int i2 = 1; for (int i = 0; i < txlb.Rows.Count; i++) { if (i >= txlb.Rows.Count) { return; } bool tx_count = false; // string strcon11 = "server =.; uid =pathnet;pwd =4s3c2a1p;database =pathnet"; OracleConnection orcon_tx = new OracleConnection(orcon_str); try { //-----------判断该图片是否已上传-------------- string txOracle_select = @"select * from ZEMR_LIS_PACS_REPORT_IMAGE where IMAGE_ID='" + txlb.Rows[i]["F_txm"].ToString().Trim() + "'"; try { OracleCommand orcom_tx = new OracleCommand(txOracle_select, orcon_tx); orcon_tx.Open(); OracleDataReader Oracledr_select = orcom_tx.ExecuteReader(); tx_count = Oracledr_select.HasRows; orcom_tx.Dispose(); orcon_tx.Close(); } catch (Exception tx_e) { orcon_tx.Close(); log.WriteMyLog("判断该图片是否已上传错误" + tx_e.ToString()); return; } if (tx_count) { continue; } //-------------------------- i2 = i + 1; string ftpstatus = ""; fw.Download(ftplocal, txml + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), txlb.Rows[i]["F_txm"].ToString().Trim(), out ftpstatus); if (ftpstatus == "Error") { log.WriteMyLog("FTP下载图像出错!"); return; } //----------------加载图像--------------------- string imgPath = ftplocal + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim();//图片文件所在路径 FileStream file = new FileStream(imgPath, FileMode.Open, FileAccess.Read); Byte[] imgByte = new Byte[file.Length]; //把图片转成 Byte型 二进制流 file.Read(imgByte, 0, imgByte.Length); //把二进制流读入缓冲区 file.Close(); //===================上传图片===================== try { orcon_tx.Open(); string txOracle = @"insert into ZEMR_LIS_PACS_REPORT_IMAGE(REPORT_NO,REPORT_TYPE,IMAGE_ID,IMAGE_NAME, IMAGE_CONTENT,COMPRESSION,REMARK) values ('" + bljc.Rows[0]["F_SQXH"].ToString() + "',2,'" + txlb.Rows[i]["F_txm"].ToString().Trim() + "','" + txlb.Rows[i]["F_txm"].ToString().Trim() + "',:p,0,'')"; OracleCommand orcom_tx1 = new OracleCommand(); orcom_tx1.Connection = orcon_tx; orcom_tx1.CommandText = txOracle; orcom_tx1.Parameters.Add("p", System.Data.OracleClient.OracleType.Blob, imgByte.Length); orcom_tx1.Parameters["p"].Value = imgByte; int qw = orcom_tx1.ExecuteNonQuery(); orcom_tx1.Dispose(); orcon_tx.Close(); } catch (Exception orcom_tx_e) { orcon_tx.Close(); log.WriteMyLog("上传图片错误_1" + orcom_tx_e.ToString()); return; } } catch (Exception e_e) { orcon_tx.Close(); log.WriteMyLog("上传图片错误" + e_e.ToString()); return; } } } } }
public void pathtohis(string blh, string debug) { string msg = f.ReadString("savetohis", "debug", ""); dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); DataTable bljc = new DataTable(); bljc = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "bljc"); if (bljc == null) { MessageBox.Show("病理数据库设置有问题!"); log.WriteMyLog("病理数据库设置有问题!"); return; } if (bljc.Rows.Count < 1) { MessageBox.Show("病理号有错误!"); log.WriteMyLog("病理号有错误!"); return; } if (bljc.Rows[0]["F_BGZT"].ToString().Trim() == "已审核") { if (bljc.Rows[0]["F_brlb"].ToString().Trim() != "体检") { log.WriteMyLog("非体检病人,不处理!"); return; } if (bljc.Rows[0]["F_brbh"].ToString().Trim() == "") { log.WriteMyLog("无体检号,不处理!"); return; } string jpgname = ""; string ftpstatus = ""; //mdjpg mdj = new mdjpg(); //try //{ // mdj.BMPTOJPG(blh, ref jpgname, "", "", "rpt//szqm"); //} //catch (Exception ee) //{ // MessageBox.Show(ee.ToString()); //} mdjpg mdj = new mdjpg(); try { for (int x = 0; x < 3; x++) { if (!File.Exists("C:\\temp\\" + blh + "\\" + blh + "_1.jpg")) { mdj.BMPTOJPG(blh, ref jpgname, "rpt//szqm"); } else { break; } } } catch (Exception ee) { if (msg == "1") { MessageBox.Show("生成JPG异常:" + ee.Message); } log.WriteMyLog(blh + ",生成JPG异常:" + ee.Message); } if (!File.Exists("C:\\temp\\" + blh + "\\" + blh + "_1.jpg")) { if (msg == "1") { MessageBox.Show("未找到文件" + "C:\\temp\\" + blh + "\\" + blh + "_1.jpg"); } log.WriteMyLog(blh + ",未找到文件" + "C:\\temp\\" + blh + "\\" + blh + "_1.jpg"); return; } else { if (msg == "1") { MessageBox.Show("生成jpg成功"); } } //---上传jpg---------- //----------------上传签章jpg至ftp--------------------- string status = ""; string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string ftpServerIP = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpUserID = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftpPassword = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpRemotePath = f.ReadString("ftp", "bgjpgPath", "pathimages/bgjpg").Replace("\0", ""); string tjtxpath = f.ReadString("savetohis", "tjtxpath", "bgjpg"); if (ftps == "1") { FtpWeb fw = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); string ftpURI = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/"; try { //判断ftp上是否存在该jpg文件 if (fw.fileCheckExist(ftpURI, blh + "_1.jpg")) { //删除ftp上的jpg文件 fw.fileDelete(ftpURI, blh + "_1.jpg").ToString(); } //上传新生成的jpg文件 fw.Upload("C:\\temp\\" + blh + "\\" + blh + "_1.jpg", "", out status); if (status == "Error") { MessageBox.Show("报告jpg上传失败,请重新审核!"); return; } } catch { if (msg == "1") { MessageBox.Show("上传报告jpg文件异常"); } return; } } else { if (tjtxpath == "") { log.WriteMyLog("sz.ini txpath图像目录未设置"); return; } try { File.Copy(ftplocal + "\\" + blh + "\\" + blh + "_1.jpg", tjtxpath + "\\" + blh + "_1.jpg", true); } catch (Exception ee) { log.WriteMyLog("源路径:" + ftplocal + "\\" + blh + "_1.jpg" + "\n" + " 目标路径:" + tjtxpath + "\\" + "_1.jpg"); log.WriteMyLog("复制文件异常!" + ee.ToString()); return; } } if (msg == "1") { MessageBox.Show("上传报告jpg文件完成"); } try { if (System.IO.Directory.Exists(@"c:\temp\" + blh)) { System.IO.Directory.Delete(@"c:\temp\" + blh, true); } } catch { log.WriteMyLog("删除临时目录" + blh + "失败"); return; } } else { if (bljc.Rows[0]["F_brlb"].ToString().Trim() != "体检") { log.WriteMyLog("非体检病人,不处理!"); return; } if (bljc.Rows[0]["F_brbh"].ToString().Trim() == "") { log.WriteMyLog("无体检号,不处理!"); return; } if (bljc.Rows[0]["F_BGZT"].ToString().Trim() == "已写报告") { string status = ""; string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string ftpServerIP = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpUserID = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftpPassword = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpRemotePath = f.ReadString("ftp", "bgjpgPath", "pathimages/bgjpg").Replace("\0", ""); string tjtxpath = f.ReadString("savetohis", "tjtxpath", "bgjpg"); if (ftps == "1") { FtpWeb fw = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpPassword); string ftpURI = "ftp://" + ftpServerIP + "/" + ftpRemotePath + "/"; try { //判断ftp上是否存在该jpg文件 if (fw.fileCheckExist(ftpURI, blh + "_1.jpg")) { //删除ftp上的jpg文件 fw.fileDelete(ftpURI, blh + "_1.jpg").ToString(); } return; } catch { if (msg == "1") { MessageBox.Show("报告jpg文件删除异常"); } return; } } else { if (tjtxpath == "") { log.WriteMyLog("sz.ini txpath图像目录未设置"); return; } try { File.Delete(tjtxpath + "\\" + blh + "_1.jpg"); } catch (Exception ee) { log.WriteMyLog("删除jpg文件异常!" + ee.ToString()); return; } } } } }
public void pathtohis(string blh, string yymc) { blhgy = blh; string msg = f.ReadString("savetohis", "msg", ""); string sfsctx = f.ReadString("savetohis", "sfsctx", ""); string odbcsql = f.ReadString("savetohis", "odbcsql", ""); if (odbcsql.Trim() != "") { ConnectionString = odbcsql; } if (msg == "1") { MessageBox.Show(blh); } dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", ""); DataTable bljc = new DataTable(); bljc = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "blxx"); if (bljc == null) { MessageBox.Show("病理数据库设置有问题!"); log.WriteMyLog("病理数据库设置有问题!"); return; } if (bljc.Rows.Count < 1) { MessageBox.Show("病理号有错误!"); log.WriteMyLog("病理号有错误!"); return; } if (bljc.Rows[0]["F_sqxh"].ToString().Trim() == "") { log.WriteMyLog("无申请序号(单据号),不处理!"); return; } //----------- //--------------- if (bljc.Rows[0]["F_BGZT"].ToString().Trim() == "已审核") { string brbh = bljc.Rows[0]["F_brbh"].ToString().Trim(); if (msg == "1") { MessageBox.Show("报告已审核,准备上传"); } /////////////// string gs = ""; DataTable dt_blk = new DataTable(); dt_blk = aa.GetDataTable("select F_LISXH from T_BLK_CS where F_BLKMC='" + bljc.Rows[0]["F_BLK"].ToString().Trim() + "'", "blk"); if (dt_blk.Rows.Count > 0) { gs = dt_blk.Rows[0]["F_LISXH"].ToString().Trim(); } else { log.WriteMyLog("获取病例库对应格式错误!"); return; } if (gs == "") { log.WriteMyLog("获取病例库对应格式错误!"); return; } brbh = brbh.Substring(0, 8) + gs + brbh.Substring(8, 4); /////////////// ////string zm = bljc.Rows[0]["F_BLH"].ToString().Trim().Substring(0, 1); ////if (bljc.Rows[0]["F_BLK"].ToString().Trim()=="常规") //// brbh = "B" + brbh; ////else brbh = zm + brbh; ////-----------------查询---------- if (msg == "1") { MessageBox.Show("查询SAMPLE_RESULT"); } string select_to_his = "select * from dbo.SAMPLE_RESULT where id='" + brbh + "' and requisition_id='" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "'"; OleDbConnection orcon = new OleDbConnection(ConnectionString); OleDbCommand orcom = new OleDbCommand(select_to_his, orcon); bool x = false; try { orcon.Open(); OleDbDataReader dr = orcom.ExecuteReader(); x = dr.HasRows; dr.Close(); orcom.Dispose(); } catch (Exception e) { log.WriteMyLog("查询状态出错:" + e.ToString()); orcom.Dispose(); orcon.Close(); return; } finally { orcom.Dispose(); orcon.Close(); } if (msg == "1") { MessageBox.Show("查询SAMPLE_RESULT," + x.ToString()); } //-------------增加---------------- ////RESULT_ANALYZE 病理诊断 ////diagnosis_advice, 肉眼所见 ////assistant_info_1 镜下所见 ////assistant_info_2 特殊检查 ////assistant_info_3 标本满意度 ////assistant_info_4 反应性细胞变化 ////assistant_info_5 微生物项目 ////assistant_info_6 上皮细胞情况 ////assistant_info_7 报告医生 ////assistant_info_8 病理号 ////remark 备注 //RESULT_ANALYZE 病理诊断 string RESULT_ANALYZE = bljc.Rows[0]["F_blzd"].ToString().Trim(); //assistant_info_3 标本满意度 string assistant_info_3 = ""; //assistant_info_4 反应性细胞变化 string assistant_info_4 = ""; //assistant_info_5 微生物项目 string assistant_info_5 = ""; //assistant_info_6 上皮细胞情况 string assistant_info_6 = ""; //remark 备注 string remark = bljc.Rows[0]["F_bz"].ToString().Trim(); if (bljc.Rows[0]["F_blk"].ToString().Trim().Contains("TCT")) { DataTable tbs = new DataTable(); tbs = aa.GetDataTable("select * from T_TBS_BG where F_blh='" + blh + "'", "TBSbg"); if (tbs.Rows.Count > 0) { //assistant_info_2 = tbs.Rows[0]["F_TBS_JYFF"].ToString().Trim(); //assistant_info_3 = tbs.Rows[0]["F_TBS_jyff"].ToString().Trim(); assistant_info_3 = tbs.Rows[0]["F_TBS_BBMYD"].ToString().Trim() + " " + tbs.Rows[0]["F_TBS_XBL"].ToString().Trim() + " " + tbs.Rows[0]["F_TBS_XBXM1"].ToString().Trim() + " " + tbs.Rows[0]["F_TBS_XBXM2"].ToString().Trim() + " " + tbs.Rows[0]["F_TBS_XBXM3"].ToString().Trim(); assistant_info_4 = tbs.Rows[0]["F_TBS_BDXM1"].ToString().Trim() + "\r\n"; assistant_info_4 = assistant_info_4 + tbs.Rows[0]["F_TBS_BDXM2"].ToString().Trim() + "\r\n"; assistant_info_4 = assistant_info_4 + tbs.Rows[0]["F_TBS_BDXM3"].ToString().Trim() + "\r\n"; assistant_info_4 = assistant_info_4 + tbs.Rows[0]["F_TBS_YZCD"].ToString().Trim() + "\r\n"; assistant_info_5 = tbs.Rows[0]["F_TBS_WSW1"].ToString().Trim() + "\r\n"; assistant_info_5 = assistant_info_5 + tbs.Rows[0]["F_TBS_WSW2"].ToString().Trim() + "\r\n"; assistant_info_5 = assistant_info_5 + tbs.Rows[0]["F_TBS_WSW3"].ToString().Trim() + "\r\n"; assistant_info_5 = assistant_info_5 + tbs.Rows[0]["F_TBS_WSW4"].ToString().Trim() + "\r\n"; assistant_info_5 = assistant_info_5 + tbs.Rows[0]["F_TBS_WSW5"].ToString().Trim() + "\r\n"; assistant_info_5 = assistant_info_5 + tbs.Rows[0]["F_TBS_WSW6"].ToString().Trim(); assistant_info_6 = tbs.Rows[0]["F_TBS_BDXM4"].ToString().Trim() + "\r\n"; assistant_info_6 = assistant_info_6 + tbs.Rows[0]["F_TBS_BDXM5"].ToString().Trim(); RESULT_ANALYZE = tbs.Rows[0]["F_TBSZD"].ToString().Trim(); remark = tbs.Rows[0]["F_TBS_BCYJ1"].ToString().Trim(); } } int ITEM_NUM = 0; if (bljc.Rows[0]["F_blk"].ToString().Trim() == "免疫组化") { DataTable myzh_num = new DataTable(); myzh_num = aa.GetDataTable("select count(*) from T_TJYZ where F_blh='" + blh + "'", "myzh_num"); ITEM_NUM = int.Parse(myzh_num.Rows[0][0].ToString()); } //////////////////// //执行语句 if (msg == "1") { MessageBox.Show("拼接执行语句"); } string Oraclestring = ""; if (x) { Oraclestring = @"update dbo.SAMPLE_RESULT set RESULT_ANALYZE ='" + RESULT_ANALYZE.Trim() + "',remark ='" + remark.Trim() + "',diagnosis_advice='" + bljc.Rows[0]["F_rysj"].ToString().Trim() + "',assistant_info_1='" + bljc.Rows[0]["F_jxsj"].ToString().Trim() + "',assistant_info_2='" + bljc.Rows[0]["F_tsjc"].ToString().Trim() + "',assistant_info_3='" + assistant_info_3.Trim() + "',assistant_info_4='" + assistant_info_4.Trim() + "',assistant_info_5='" + assistant_info_5.Trim() + "',assistant_info_6='" + assistant_info_6.Trim() + "',assistant_info_7='" + bljc.Rows[0]["F_SHYS"].ToString().Trim() + "',assistant_info_8='" + bljc.Rows[0]["F_BLH"].ToString().Trim() + "',ITEM_NUM='" + ITEM_NUM + "',sample_name='" + bljc.Rows[0]["F_bbmc"].ToString().Trim() + "',lczd='" + bljc.Rows[0]["F_lczd"].ToString().Trim() + "' ,SAMPLE_NUMBER='" + bljc.Rows[0]["F_bblx"].ToString().Trim() + "',mcyj= '" + bljc.Rows[0]["F_mcyj"].ToString().Trim() + "',recivedate='" + bljc.Rows[0]["F_SDRQ"].ToString().Trim() + "',report_person='" + bljc.Rows[0]["F_BGYS"].ToString().Trim() + "',is_jj='" + bljc.Rows[0]["F_SFJJ"].ToString().Trim() + "' where id='" + brbh + "' and requisition_id='" + bljc.Rows[0]["F_SQXH"].ToString().Trim() + "'"; } else { //RESULT_ANALYZE 病理诊断 // diagnosis_advice, 肉眼所见 //assistant_info_1 镜下所见 //assistant_info_2 特殊检查 //assistant_info_3 检验方法 //assistant_info_4 标本满意度 //assistant_info_5 病原体 //assistant_info_6 炎症程度 //assistant_info_7 报告医生 //assistant_info_8 病理号 //remark 备注 Oraclestring = @"insert into dbo.SAMPLE_RESULT(id,requisition_id,RESULT_ANALYZE,remark,diagnosis_advice,assistant_info_1,assistant_info_2,assistant_info_3,assistant_info_4,assistant_info_5,assistant_info_6,assistant_info_7,assistant_info_8,ITEM_NUM,sample_name,lczd,SAMPLE_NUMBER,mcyj,recivedate,report_person,is_jj) values ('" + brbh.Trim() + "','" + bljc.Rows[0]["F_sqxh"].ToString().Trim() + "','" + RESULT_ANALYZE.Trim() + "','" + remark.Trim() + "','" + bljc.Rows[0]["F_rysj"].ToString().Trim() + "','" + bljc.Rows[0]["F_jxsj"].ToString().Trim() + "','" + bljc.Rows[0]["F_tsjc"].ToString().Trim() + "','" + assistant_info_3.Trim() + "','" + assistant_info_4.Trim() + "','" + assistant_info_5.Trim() + "','" + assistant_info_6.Trim() + "','" + bljc.Rows[0]["F_SHYS"].ToString().Trim() + "','" + bljc.Rows[0]["F_BLH"].ToString().Trim() + "','" + ITEM_NUM + "','" + bljc.Rows[0]["F_bbmc"].ToString().Trim() + "','" + bljc.Rows[0]["F_lczd"].ToString().Trim() + "','" + bljc.Rows[0]["F_bblx"].ToString().Trim() + "','" + bljc.Rows[0]["F_mcyj"].ToString().Trim() + "','" + bljc.Rows[0]["F_SDRQ"].ToString().Trim() + "','" + bljc.Rows[0]["F_BGYS"].ToString().Trim() + "','" + bljc.Rows[0]["F_SFJJ"].ToString().Trim() + "')"; } if (Oraclestring.Trim() == "") { MessageBox.Show("插入语句不能为空"); return; } if (msg == "1") { MessageBox.Show("执行语句:" + Oraclestring); log.WriteMyLog("执行语句:" + Oraclestring); } OleDbCommand orcom_insert = new OleDbCommand(Oraclestring, orcon); int z = -1; try { orcon.Open(); z = orcom_insert.ExecuteNonQuery(); orcom_insert.Dispose(); orcon.Close(); } catch (Exception ee) { log.WriteMyLog("回传报告出错:" + ee.ToString()); orcom_insert.Dispose(); orcon.Close(); return; } finally { orcom_insert.Dispose(); orcon.Close(); } if (msg == "1") { MessageBox.Show("数据库写入完成,返回:" + z.ToString()); } ////下面程序中图像信息 if (sfsctx.Trim() == "1") //FTP下载方式 { //下载FTP参数 string ftpserver = f.ReadString("ftp", "ftpip", "").Replace("\0", ""); string ftpuser = f.ReadString("ftp", "user", "ftpuser").Replace("\0", ""); string ftppwd = f.ReadString("ftp", "pwd", "ftp").Replace("\0", ""); string ftplocal = f.ReadString("ftp", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpremotepath = f.ReadString("ftp", "ftpremotepath", "").Replace("\0", ""); string ftps = f.ReadString("ftp", "ftp", "").Replace("\0", ""); string txpath = f.ReadString("txpath", "txpath", "").Replace("\0", ""); FtpWeb fw = new FtpWeb(ftpserver, ftpremotepath, ftpuser, ftppwd); string txml = bljc.Rows[0]["F_txml"].ToString().Trim(); //下载图像 DataTable txlb = aa.GetDataTable("select top 4 * from V_dytx where F_blh='" + bljc.Rows[0]["F_BLH"].ToString().Trim() + "'", "txlb"); if (txlb.Rows.Count < 1) { log.WriteMyLog("该病人无图像,不上传"); return; } int i2 = 1; for (int i = 0; i < txlb.Rows.Count; i++) { if (i >= txlb.Rows.Count) { return; } try { //-------------------------- i2 = i + 1; string ftpstatus = ""; fw.Download(ftplocal, txml + "/" + txlb.Rows[i]["F_txm"].ToString().Trim(), txlb.Rows[i]["F_txm"].ToString().Trim(), out ftpstatus); if (ftpstatus == "Error") { log.WriteMyLog("FTP下载图像出错!"); return; } //===================上传图片===================== //---上传jpg---------- //----------------上传签章jpg至ftp--------------------- //上传FTP参数 string status = ""; string ftpServerIP_up = f.ReadString("ftpup", "ftpip", "").Replace("\0", ""); string ftpUserID_up = f.ReadString("ftpup", "user", "ftpuser").Replace("\0", ""); string ftpPassword_up = f.ReadString("ftpup", "pwd", "ftp").Replace("\0", ""); string ftplocal_up = f.ReadString("ftpup", "ftplocal", "c:\\temp").Replace("\0", ""); string ftpRemotePath_up = f.ReadString("ftpup", "ftpremotepath", "pathimages").Replace("\0", ""); FtpWeb fw_up = new FtpWeb(ftpServerIP_up, ftpRemotePath_up, ftpUserID_up, ftpPassword_up); string ml1 = bljc.Rows[0]["F_brbh"].ToString().Trim().Substring(0, 4); string ml2 = bljc.Rows[0]["F_brbh"].ToString().Trim().Substring(4, 2); string ml3 = bljc.Rows[0]["F_brbh"].ToString().Trim().Substring(6, 2); string bh = bljc.Rows[0]["F_brbh"].ToString().Trim().Substring(8, 4); string ftpURI = "ftp://" + ftpServerIP_up + "/" + ftpRemotePath_up; try { //判断目录是否存在 if (!fw_up.fileCheckExist(ftpURI + "/" + ml1, ml1)) { //目录不存在,创建 string stat = ""; fw_up.Makedir(ml1, out stat); } if (!fw_up.fileCheckExist(ftpURI + "/" + ml2, ml2)) { //目录不存在,创建 string stat = ""; fw_up.Makedir(ml1 + "/" + ml2, out stat); } if (!fw_up.fileCheckExist(ftpURI + "/" + ml2 + "/" + ml3, ml3)) { //目录不存在,创建 string stat = ""; fw_up.Makedir(ml1 + "/" + ml2 + "/" + ml3, out stat); } //-------------- string jpgname = gs + "000000" + bh + "0" + (i + 1).ToString() + ".jpg"; //判断ftp上是否存在该jpg文件 if (fw_up.fileCheckExist(ftpURI + "/" + ml1 + "/" + ml2 + "/" + ml3 + "/", jpgname)) { //删除ftp上的jpg文件 fw_up.fileDelete(ftpURI + "/" + ml1 + "/" + ml2 + "/" + ml3, jpgname).ToString(); } //上传新生成的jpg文件 string errMsg = ""; fw_up.Upload("C:\\temp\\" + txlb.Rows[i]["F_txm"].ToString().Trim(), ml1 + "/" + ml2 + "/" + ml3, jpgname, out status, ref errMsg); if (status == "Error") { MessageBox.Show("jpg上传失败,请重新审核\r\n" + errMsg); } try { if (System.IO.Directory.Exists(@"c:\temp\" + blh)) { System.IO.Directory.Delete(@"c:\temp\" + blh, true); } } catch { log.WriteMyLog("删除临时目录" + blh + "失败"); } } catch { MessageBox.Show("上传jpg文件异常"); } } catch { MessageBox.Show("上传jpg文件异常"); } } } } }