Beispiel #1
0
        private void FtpDownload(M_MyJob myJob)
        {
            //文件路径
            string filePath = Path.GetDirectoryName(myJob.FilePath).Replace("\\", "//");
            //文件名
            string fileName = Path.GetFileName(myJob.FilePath);
            //复制文件到系统路径
            string copyPath = string.Format(@"{0}\SowerTestClient\Paper\Download\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName);
            //下载文件保存路径
            string savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);

            FtpWeb ftpWeb = CommonUtil.GetFtpWeb();

            if (ftpWeb != null)
            {
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "作业下载进度:");
            }

            //复制作业到系统目录
            File.Copy(savePath, copyPath, true);
            //删除下载文件
            File.Delete(savePath);
            //设置已下载状态
            dgvResult.SelectedRows[0].Cells["JobDownLoadState"].Value = "已下载";
            tsbMessage.Text = "作业下载进度:";
            tsbBar.Value    = 0;
            //下载账套文件
            if (ftpWeb != null && myJob.RequireEnvFile.ToLower() == "true" && myJob.IsUpload.ToLower() == "true" && cbIsDownAccount.Checked == true)
            {
                filePath = Path.GetDirectoryName(myJob.EnvFilePath).Replace("\\", "//");
                fileName = myJob.EnvFileName;
                copyPath = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, fileName);
                savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "帐套下载进度:");
                //复制作业到系统目录
                DirFileHelper.Copy(savePath, copyPath);
                //删除临时下载文件
                DirFileHelper.DeleteFile(savePath);
                tsbMessage.Text = "帐套下载进度:";
                tsbBar.Value    = 0;
                dgvResult.SelectedRows[0].Cells["AccountDownLoadState"].Value = "已下载";
            }
            //下载视频文件
            if (ftpWeb != null && myJob.IsUploadVideoFile == true && string.IsNullOrEmpty(myJob.VideoFilePath) == false && cbIsDownVideo.Checked == true)
            {
                filePath = Path.GetDirectoryName(myJob.VideoFilePath).Replace("\\", "//");
                fileName = myJob.VideoFileName;
                copyPath = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(myJob.VideoFilePath));
                savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "视频下载进度:");
                //复制作业到系统目录
                ZipFileTools.UnZipSZL(savePath, copyPath);
                //删除临时下载文件
                DirFileHelper.DeleteFile(savePath);
                tsbMessage.Text = "视频下载进度:";
                tsbBar.Value    = 0;
                dgvResult.SelectedRows[0].Cells["VideoDownLoadState"].Value = "已下载";
            }
        }
Beispiel #2
0
        private static bool Download(string remoteDir, string localDir)
        {
            var ftp = new FtpWeb(
                DbFactory.FTPSetting.Server,
                DbFactory.FTPSetting.Port,
                DbFactory.FTPSetting.UserID,
                DbFactory.FTPSetting.Password);

            string[] files;
            if (!ftp.DirectoryListSimple(remoteDir, out files))
            {
                return(false);
            }

            if (!Directory.Exists(localDir))
            {
                Directory.CreateDirectory(localDir);
            }

            foreach (var file in files)
            {
                ftp.Download(remoteDir + file, localDir + file);
            }
            return(true);
        }
Beispiel #3
0
        private bool DownLoadFile(string copyPath)
        {
            bool downResult      = false;
            bool downMyJobResult = false;

            string downLoadUrl = string.Empty;
            string filePath    = string.Empty;
            string fileName    = string.Empty;
            string savePath    = string.Empty;

            string ftpFilePath   = "C:\\data\\";
            string ftpServerIp   = UserConfigSettings.Instance.ReadSetting("题库地址");
            string ftpRemotePath = UserConfigSettings.Instance.ReadSetting("题库目录");
            string ftpPort       = UserConfigSettings.Instance.ReadSetting("端口号");
            string ftpUserId     = UserConfigSettings.Instance.ReadSetting("ftp用户名");
            string ftpPassword   = UserConfigSettings.Instance.ReadSetting("ftp密码");
            bool   anonymous     = bool.Parse(UserConfigSettings.Instance.ReadSetting("匿名"));
            FtpWeb ftpWeb        = new FtpWeb(ftpServerIp, ftpRemotePath, ftpUserId, ftpPassword, ftpPort, 10000, false, anonymous);

            M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;

            try
            {
                btnDownLoad.Enabled = false;
                //下载地址
                downLoadUrl = fileHost.Replace(@"\", @"/") + resource.RSPath;
                //文件路径
                filePath = resource.RSPath;
                //文件名
                fileName = Path.GetFileName(filePath);
                //下载文件保存路径
                savePath = string.Format("C:\\{0}_{1}", PublicClass.StudentCode, fileName);
                //下载作业
                //downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:");
                ftpWeb.Download(ftpFilePath, resource.RSPath, "", tsbBar, tsbMessage, "下载进度:");

                if (downResult)
                {
                    //解压资源到目录
                    ZipFileTools.UnZipSZL(savePath, copyPath);
                    //删除下载文件
                    File.Delete(savePath);
                    //设置已下载状态
                    dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载";
                    downMyJobResult = true;
                }
            }
            catch (Exception ex)
            {
                PublicClass.ShowMessageOk(ex.Message);
                downMyJobResult = false;
            }
            finally
            {
                btnDownLoad.Enabled = true;
            }

            return(downMyJobResult);
        }
Beispiel #4
0
        public string cdicom(string blh, DataTable bljc, sqldb aa, ref string dcmlb)
        {
            string ftplocal = @"c:\temp_sr\" + blh;

            try
            {
                System.IO.Directory.CreateDirectory(ftplocal);
            }
            catch
            { }
            IniFiles2 f = new IniFiles2(Application.StartupPath + "\\sz.ini");

            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_sr").Replace("\0", "");
            string    ftpremotepath = f.ReadString("ftp", "ftpremotepath", "pathimages").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='" + blh + "' and (F_pacs IS NULL OR f_PACS<>'3')", "txlb");

            for (int i = 0; i < txlb.Rows.Count; i++)
            {
                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("图像下载失败!");
                    return("");
                }
            }



            //DataTable txb = aa.GetDataTable("select top 4 * from V_dytx where F_blh='" + blh + "'", "txb");
            for (int i = 0; i < txlb.Rows.Count; i++)
            {
                string      dcmname = @"c:\temp_sr\" + blh + @"\" + i.ToString() + ".dcm";
                dicomfilezh df      = new dicomfilezh();

                df.createdicom(blh, aa, @"c:\temp_sr\" + blh + @"\" + txlb.Rows[i]["F_txm"].ToString().Trim(), ref dcmname, "");

                if (dcmname == "")
                {
                    log.WriteMyLog("重新生成一次!");
                    df.createdicom(blh, aa, @"c:\temp_sr\" + blh + @"\" + txlb.Rows[i]["F_txm"].ToString().Trim(), ref dcmname, "");
                }
                if (dcmname != "")
                {
                    aa.ExecuteSQL("update T_tx set F_pacs='" + dcmname + "' where F_id='" + txlb.Rows[i]["F_id"].ToString().Trim() + "'");
                    dcmlb = dcmlb + dcmname + "^";
                }
            }
            return("true");
        }
Beispiel #5
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            string bb            = "/huizhi/0531/容器及换热器/0531-D-2200-EQ-LS020-2001A$4376885.xls";
            string ftpServerIP   = "10.151.131.53";
            string ftpRemotePath = "";
            string ftpUserID     = "CPMSPowerOn";
            string ftpURI        = "Cpms20150610";
            FtpWeb Fw            = new FtpWeb(ftpServerIP, ftpRemotePath, ftpUserID, ftpURI);

            string filePath   = "D:";
            string fileName   = bb.Substring(bb.LastIndexOf(@"/") + 1, bb.Length - bb.LastIndexOf(@"/") - 1);
            string ftpaddress = Fw.ftpURI + bb;

            Fw.Download(filePath, fileName, ftpaddress);
        }
Beispiel #6
0
        public bool psdicomfile(string blh)
        {
            bool      dicom    = true;
            IniFiles2 f        = new IniFiles2(Application.StartupPath + "\\sz.ini");
            string    ftplocal = f.ReadString("Dicom", "local", @"c:\temp\").Replace("\0", "") + blh;

            try
            {
                dbbase.odbcdb aa = new odbcdb("DSN=pathnet;UID=pathnet;PWD=4s3c2a1p", "", "");

                DataTable txlb          = aa.GetDataTable("select top 4 * from V_dytx where F_blh='" + blh + "'", "dytx");
                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    ftpremotepath = f.ReadString("ftp", "ftpremotepath", "pathimages").Replace("\0", "");
                FtpWeb    fw            = new FtpWeb(ftpserver, ftpremotepath, ftpuser, ftppwd);

                if (System.IO.Directory.Exists(ftplocal))
                {
                }
                else
                {
                    System.IO.Directory.CreateDirectory(ftplocal);
                }
                DataTable bljc = aa.GetDataTable("select * from T_jcxx where F_blh='" + blh + "'", "bljc");

                string txml  = bljc.Rows[0]["F_txml"].ToString().Trim();
                int    count = 0;
                log.WriteMyLog(blh + ",开始FTP图像下载");
                for (int i = 0; i < txlb.Rows.Count; i++)
                {
                    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(blh + ",图像下载失败!" + txlb.Rows[i]["F_txm"].ToString().Trim());
                        System.IO.Directory.Delete(ftplocal, true);
                        return(false);
                    }
                    log.WriteMyLog(blh + ",图像下载成功" + txlb.Rows[i]["F_txm"].ToString().Trim());

                    string bmpmc = ftplocal + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim();
                    string dcmmc = ftplocal + "\\" + txlb.Rows[i]["F_txm"].ToString().Trim().Replace(".", "") + ".dcm";

                    dicomfile xx     = new dicomfile();
                    string    errMsg = xx.createdicom(blh, aa, bmpmc, ref dcmmc);
                    if (errMsg != "true")
                    {
                        log.WriteMyLog("[生成idcom文件失败]" + errMsg);
                    }
                    else
                    {
                        log.WriteMyLog("[生成idcom文件名]" + dcmmc);
                    }
                    if (dcmmc != "")
                    {
                        Process prc = new Process();
                        prc.StartInfo.FileName               = @"cmd.exe";
                        prc.StartInfo.UseShellExecute        = false;
                        prc.StartInfo.RedirectStandardInput  = true;
                        prc.StartInfo.RedirectStandardOutput = true;
                        prc.StartInfo.RedirectStandardError  = true;
                        prc.StartInfo.CreateNoWindow         = true;

                        prc.Start();

                        string server = f.ReadString("Dicom", "server", "194.1.13.169").Replace("\0", "");
                        string port   = f.ReadString("Dicom", "port", "5500").Replace("\0", "");
                        string Aec    = f.ReadString("Dicom", "Aec", "KC_IPEX_P001").Replace("\0", "");

                        string dos_cmd = @"storescu -aet LGPACS -aec " + Aec + " " + server + " " + port + " " + dcmmc;

                        prc.StandardInput.WriteLine(dos_cmd);

                        prc.StandardInput.Close();

                        string output = prc.StandardOutput.ReadToEnd();
                        //string output = prc.StandardOutput.ReadLine();


                        prc.WaitForExit();
                        string err = errcode(output);
                        if (err != "")
                        {
                            log.WriteMyLog(txlb.Rows[i]["F_txm"].ToString().Trim() + ",发送失败" + err + " " + output);
                        }
                        else
                        {
                            log.WriteMyLog(txlb.Rows[i]["F_txm"].ToString().Trim() + ",发送成功 " + output);
                            count = count + 1;
                        }
                    }
                    else
                    {
                        log.WriteMyLog(blh + ",医院名称为空不处理");
                        return(false);
                    }
                }
                //  System.IO.Directory.Delete(ftplocal, true);
                if (count == txlb.Rows.Count)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ee)
            {
                log.WriteMyLog(blh + ",程序异常:" + ee.Message);
                //  System.IO.Directory.Delete(ftplocal, true);
                return(false);
            }
        }
Beispiel #7
0
        public void UploadPic(List <T_TX> txList, T_JCXX jcxx, string fileId)
        {
            var targetServerDir = $"{DateTime.Now.ToString("yyyy")}\\{DateTime.Now.ToString("MM")}\\{DateTime.Now.ToString("dd")}\\{fileId}";
            var pisServerDir    = jcxx.F_TXML;
            var localdir        = $"Pics\\" + targetServerDir;

            for (int i = 0; i < txList.Count; i++)
            {
                var upFilePath         = targetServerDir + "\\";
                var serverFileFullName = pisServerDir + "\\" + txList[i].F_TXM.Trim();
                var localFileFullName  = localdir + "\\" + txList[i].F_TXM.Trim();

                //下载图片
                string ftpstatus = "";
                if (!Directory.Exists(localdir))
                {
                    Directory.CreateDirectory(localdir);
                }
                try
                {
                    ftpPis.Download(localdir, serverFileFullName, txList[i].F_TXM.Trim(), out ftpstatus);
                    if (ftpstatus == "Error")
                    {
                        throw new Exception("下载图片失败");
                    }
                }
                catch (Exception e)
                {
                    log.WriteMyLog("下载ftp图片失败,病理号:" + jcxx.F_BLH +
                                   "\r\n失败原因:" + e);
                    continue;
                }


                //上传到目标ftp
                string ftpstatusUP = "";
                try
                {
                    ftpUp.Makedir("BL", out ftpstatusUP);
                    ftpUp.Makedir("BL\\" + upFilePath, out ftpstatusUP);
                    ftpUp.Upload(localFileFullName, targetServerDir, out ftpstatusUP);
                    if (ftpstatusUP == "Error")
                    {
                        throw new Exception("Error");
                    }
                }
                catch (Exception e)
                {
                    log.WriteMyLog("上传ftp图片失败,病理号:" + jcxx.F_BLH +
                                   "\r\n失败原因:" + e);
                    continue;
                }

                //上传完成后删除本地图片
                try
                {
                    File.Delete(localFileFullName);
                }
                catch
                {
                }
            }
        }
Beispiel #8
0
 /// <summary>
 /// 下载题库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDown_Click(object sender, EventArgs e)
 {
     #region 局部变量
     string topicFileName      = string.Empty;
     string topicFilePath      = string.Empty;
     string topicEnvFilePath   = string.Empty;
     string topicVideoFilePath = string.Empty;
     string requireEnvFile     = string.Empty;
     string envFileName        = string.Empty;
     string envFilePath        = string.Empty;
     string videoFileName      = string.Empty;
     string videoFilePath      = string.Empty;
     string envFileExt         = string.Empty;
     string copyEnvPath        = string.Empty;
     string copyVideoPath      = string.Empty;
     string filePath           = string.Empty;
     string fileTPath          = string.Empty;
     string fileExt            = string.Empty;
     string fileName           = string.Empty;
     string copyPath           = string.Empty;
     string copyTPath          = string.Empty;
     string connection         = string.Empty;
     string connectionT        = string.Empty;
     string errorMessage       = string.Empty;
     FtpWeb ftpWeb             = null;
     #endregion
     try
     {
         btnDown.Enabled = false;
         if (dgvDownTopicDB.SelectedRows.Count == 0)
         {
             return;
         }
         M_TopicDB topicDB = dgvDownTopicDB.SelectedRows[0].DataBoundItem as M_TopicDB;
         #region 检测本地是否存在题库文件
         string path = string.Format(@"{0}\data\{1}_{2}.sdbt", Application.StartupPath, PublicClass.StudentCode, topicDB.TopicDBName);
         if (File.Exists(path))
         {
             M_SubjectProp subject = bSubjectProp.GetSubjectProp(string.Format("{0}_{1}.sdbt", PublicClass.StudentCode, topicDB.TopicDBName));
             if (subject.TopicDBVersion == topicDB.TopicDBVersion && subject.TopicDBCode == topicDB.TopicDBCode)
             {
                 PublicClass.ShowErrorMessageOk("您已经下载过这个题库文件,不能重复下载。");
                 return;
             }
         }
         #endregion
         #region 初始化变量
         topicFileName  = Path.GetFileName(topicDB.TopicDBPath);
         topicFilePath  = Path.GetDirectoryName(topicDB.TopicDBPath).Replace("\\", "//");
         requireEnvFile = string.IsNullOrEmpty(topicDB.RequireEnvFile) == true ? "false" : topicDB.RequireEnvFile.ToLower();
         filePath       = string.Format("{0}\\{1}", Globals.DownLoadDir, topicFileName);
         fileTPath      = string.Format("{0}\\{1}t", Globals.DownLoadDir, topicFileName);
         fileExt        = string.IsNullOrEmpty(topicDB.TopicDBPath) == true ? "" : Path.GetExtension(topicDB.TopicDBPath).ToLower();
         fileName       = string.Format("{0}{1}", topicDB.TopicDBName, fileExt);
         copyPath       = string.Format(@"{0}\data\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
         copyTPath      = string.Format(@"{0}\data\{1}_{2}t", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
         connection     = string.Format(@"data source={0};password={1};polling=false;failifmissing=true", filePath, PublicClass.PasswordTopicDB);
         connectionT    = string.Format(@"data source={0};polling=false;failifmissing=true", fileTPath);
         #endregion
         //下载题库文件
         ftpWeb = CommonUtil.GetFtpWeb();
         if (ftpWeb != null)
         {
             ftpWeb.Download(Globals.DownLoadDir, topicFileName, topicFilePath, proDown, lblDown, "题库下载进度:");
         }
         else
         {
             Msg.ShowInformation("FTP地址不可用,请返回登陆界面进行配置。");
             return;
         }
         //下载账套文件
         if (ftpWeb != null && requireEnvFile == "true" && topicDB.IsUploadEnvFile == true && !string.IsNullOrEmpty(topicDB.EnvFilePath))
         {
             envFileName      = Path.GetFileName(topicDB.EnvFilePath);
             envFilePath      = string.Format("{0}\\{1}", Globals.DownLoadDir, envFileName);
             copyEnvPath      = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, envFileName);
             topicEnvFilePath = Path.GetDirectoryName(topicDB.EnvFilePath).Replace("\\", "//");
             ftpWeb.Download(Globals.DownLoadDir, envFileName, topicEnvFilePath, proDown, lblDown, "账套下载进度:");
         }
         //下载视频文件
         if (ftpWeb != null && topicDB.IsUploadVideoFile == true && !string.IsNullOrEmpty(topicDB.VideoFilePath))
         {
             videoFileName      = Path.GetFileName(topicDB.VideoFilePath);
             videoFilePath      = string.Format("{0}\\{1}", Globals.DownLoadDir, videoFileName);
             copyVideoPath      = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(videoFileName));
             topicVideoFilePath = Path.GetDirectoryName(topicDB.VideoFilePath).Replace("\\", "//");
             ftpWeb.Download(Globals.DownLoadDir, videoFileName, topicVideoFilePath, proDown, lblDown, "视频下载进度:");
         }
         #region 验证题库文件
         if (fileExt != ".sdb" && fileExt != ".srk")
         {
             Msg.ShowError("该文件不是有效的题库文件,请重新添加!");
             return;
         }
         if (File.Exists(copyTPath) && File.Exists(copyPath))
         {
             if (!Msg.AskQuestion("该题库文件已经存在,确定要覆盖吗?"))
             {
                 return;
             }
         }
         if (File.Exists(filePath))
         {
             CommonUtil.ShowProcessing("正在验证题库,请稍候...", this, (obj) =>
             {
                 //复制一个.sdbt文件
                 DirFileHelper.CopyFile(filePath, fileTPath);
                 //修改.sdbt文件密码
                 bool updateResult = key3.ChangePassWordByGB2312(fileTPath, PublicClass.PassWordTopicDB_SDB, "");
                 if (updateResult)
                 {
                     SQLiteConnection conn = new SQLiteConnection(connectionT);
                     conn.Open();
                     if (ConnectionState.Open == conn.State)
                     {
                         //更改题库密码
                         conn.ChangePassword(PublicClass.PasswordTopicDB);
                         //复制题库到系统目录
                         DirFileHelper.CopyFile(filePath, copyPath);
                         DirFileHelper.CopyFile(fileTPath, copyTPath);
                         //复制账套到系统目录
                         if (requireEnvFile == "true" && topicDB.IsUploadEnvFile == true && !string.IsNullOrEmpty(topicDB.EnvFilePath))
                         {
                             DirFileHelper.CopyFile(envFilePath, copyEnvPath);
                         }
                         //复制视频到系统目录
                         if (topicDB.IsUploadVideoFile == true && !string.IsNullOrEmpty(topicDB.VideoFilePath))
                         {
                             ZipFileTools.UnZipSZL(videoFilePath, copyVideoPath);
                         }
                         conn.Close();
                     }
                     conn.Dispose();
                     conn = null;
                     DirFileHelper.DeleteFile(filePath);
                     DirFileHelper.DeleteFile(fileTPath);
                     DirFileHelper.DeleteFile(envFilePath);
                     DirFileHelper.DeleteFile(videoFilePath);
                 }
                 else
                 {
                     Msg.ShowError("该题库不是有效的题库文件!");
                 }
                 key3.Dispose();
             }, null);
         }
         #endregion
     }
     catch (SQLiteException se)
     {
         Msg.ShowError("无法打开题库文件,该题库不是有效的题库文件!");
         LogHelper.WriteLog(typeof(frmDownTopicDB), se);
         CommonUtil.WriteLog(se);
     }
     catch (WebException we)
     {
         Msg.ShowError("该题库文件不存在,请联系管理员重新上传。");
         LogHelper.WriteLog(typeof(frmDownTopicDB), we);
         CommonUtil.WriteLog(we);
     }
     catch (AggregateException ae)
     {
         Msg.ShowError("无法打开题库文件,该题库不是有效的题库文件!");
         LogHelper.WriteLog(typeof(frmDownTopicDB), ae);
         CommonUtil.WriteLog(ae);
     }
     catch (Exception ex)
     {
         PublicClass.ShowErrorMessageOk(ex.Message);
         LogHelper.WriteLog(typeof(frmDownTopicDB), ex);
         CommonUtil.WriteLog(ex);
     }
     finally
     {
         btnDown.Enabled = true;
     }
 }
Beispiel #9
0
        /// <summary>
        /// 病理图片上传到外部系统ftp,并获取病理图片xml字符串
        /// </summary>
        /// <param name="jcxx">检查信息表</param>
        /// <returns></returns>
        public string GetImageFile(T_JCXX jcxx)
        {
            var sqlWhere = $" F_BLH='{jcxx.F_BLH}' and F_SFDY='1' ";
            var txList   = new T_TX_DAL().GetList(sqlWhere);

            string imageFileString = "";

            #region ftp变量声明

            IniFiles f             = new IniFiles("sz.ini");
            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 ftpserver2     = f.ReadString("ftpup", "ftpip", "").Replace("\0", "");
            string ftpuser2       = f.ReadString("ftpup", "user", "ftpuser").Replace("\0", "");
            string ftppwd2        = f.ReadString("ftpup", "pwd", "ftp").Replace("\0", "");
            string ftplocal2      = f.ReadString("ftpup", "ftplocal", "c:\\temp").Replace("\0", "");
            string ftpremotepath2 = f.ReadString("ftpup", "ftpremotepath", "").Replace("\0", "");
            string ftps2          = f.ReadString("ftp", "ftp", "").Replace("\0", "");
            FtpWeb fwup           = new FtpWeb(ftpserver2, ftpremotepath2, ftpuser2, ftppwd2);

            string ftpPath  = $@"ftp:\\{ftpserver}\";  //这里要替换为本地配置文件的ftp路径
            string ftpPath2 = $@"ftp:\\{ftpserver2}\"; //这里要替换为本地配置文件的ftp路径

            #endregion

            for (int i = 0; i < txList.Count; i++)
            {
                var upFilePath = jcxx.F_TXML + "\\";
                var upFileName = upFilePath + txList[i].F_TXM.Trim();

                //下载图片
                string ftpstatus = "";
                if (!Directory.Exists(ftplocal + "\\" + upFilePath))
                {
                    Directory.CreateDirectory(ftplocal + "\\" + upFilePath);
                }
                try
                {
                    fw.Download(ftplocal + "\\" + upFilePath, upFileName, txList[i].F_TXM.Trim(), out ftpstatus);
                    if (ftpstatus == "Error")
                    {
                        throw new Exception("Error");
                    }
                }
                catch (Exception e)
                {
                    log.WriteMyLog("下载ftp图片失败,病理号:" + jcxx.F_BLH +
                                   "\r\n失败原因:" + e.Message);
                    continue;
                }


                //上传到目标ftp
                string ftpstatusUP = "";
                try
                {
                    fwup.Makedir("BL", out ftpstatusUP);
                    fwup.Makedir("BL\\" + upFilePath, out ftpstatusUP);
                    fwup.Upload(ftplocal + "\\" + upFileName, "BL\\" + upFilePath, out ftpstatusUP);
                    if (ftpstatusUP == "Error")
                    {
                        throw new Exception("Error");
                    }
                }
                catch (Exception e)
                {
                    log.WriteMyLog("上传ftp图片失败,病理号:" + jcxx.F_BLH +
                                   "\r\n失败原因:" + e.Message);
                    continue;
                }

                imageFileString +=
                    $@"<Path{i + 1}> {ftpPath2 + "BL\\" + upFileName} | 1 </Path{i + 1}>                                    ";
            }

            return(imageFileString);
        }