/// <summary>
        /// 从指定的ftp服务器下载指定的文件到本地
        /// </summary>
        /// <param name="name">FTP名称</param>
        /// <param name="name">远程文件</param>
        /// <param name="name">本地文件</param>
        protected virtual bool DownloadFile(string name, string remoteFile, string localFile)
        {
            if (GlobalMethods.Misc.IsEmptyString(name))
            {
                return(false);
            }
            if (this.m_ftpAccessDict == null || this.m_ftpAccessDict.Count <= 0)
            {
                return(false);
            }
            if (!this.m_ftpAccessDict.ContainsKey(name))
            {
                return(false);
            }
            bool      success   = false;
            FtpAccess ftpAccess = this.m_ftpAccessDict[name];

            if (ftpAccess.OpenConnection())
            {
                string localDirectory = GlobalMethods.IO.GetFilePath(localFile);
                if (GlobalMethods.IO.CreateDirectory(localDirectory))
                {
                    success = ftpAccess.Download(remoteFile, localFile);
                }
            }
            ftpAccess.CloseConnection();
            return(false);
        }
예제 #2
0
 public void TestMethod3()
 {
     //日期判断
     FtpAccess ftpAccess = new FtpAccess();
     ftpAccess.FtpIP = "192.168.1.63";
     ftpAccess.FtpPort = 9000;
     ftpAccess.Password = "******";
     ftpAccess.UserName = "******";
     ftpAccess.FtpMode = FtpMode.PASV;
     ftpAccess.OpenConnection();
     string szLocalFile = @"D:\svn\MDP\MedDoc\2-SourceCode\Trunk\Debug\Documents\Temp\68360_34130_20160513153221_5116.xml";
     string szRemoteFile = "/MEDDOC/68360_34130_20160513153221_5116.xml";
     bool result = ftpAccess.Upload(szLocalFile, szRemoteFile);
     ftpAccess.CloseConnection();
 }
예제 #3
0
        public void TestMethod3()
        {
            //日期判断
            FtpAccess ftpAccess = new FtpAccess();

            ftpAccess.FtpIP    = "192.168.1.63";
            ftpAccess.FtpPort  = 9000;
            ftpAccess.Password = "******";
            ftpAccess.UserName = "******";
            ftpAccess.FtpMode  = FtpMode.PASV;
            ftpAccess.OpenConnection();
            string szLocalFile  = @"D:\svn\MDP\MedDoc\2-SourceCode\Trunk\Debug\Documents\Temp\68360_34130_20160513153221_5116.xml";
            string szRemoteFile = "/MEDDOC/68360_34130_20160513153221_5116.xml";
            bool   result       = ftpAccess.Upload(szLocalFile, szRemoteFile);

            ftpAccess.CloseConnection();
        }
예제 #4
0
        /// <summary>
        /// 获取FTP图片
        /// </summary>
        /// <param name="recPaperInfo"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public short GetImageFromFtp(RecPaper recPaperInfo, string fileName, ref string szLocalFile)
        {
            if (recPaperInfo == null)
            {
                return(SystemData.ReturnValue.FAILED);
            }
            FtpAccess recPaperFtpAccess = base.GetRecPaperFtpAccess();

            try
            {
                if (recPaperInfo == null)
                {
                    return(SystemData.ReturnValue.PARAM_ERROR);
                }
                if (!recPaperFtpAccess.OpenConnection())
                {
                    return(SystemData.ReturnValue.FAILED);
                }
                string szRemoteFilePath = GetRecPaperRemoteDir(recPaperInfo) + fileName;
                szLocalFile = this.GetImageLocalFile(fileName);
                if (!recPaperFtpAccess.ResExists(szRemoteFilePath, false))
                {
                    return(SystemData.ReturnValue.FAILED);
                }
                if (!recPaperFtpAccess.Download(szRemoteFilePath, szLocalFile))
                {
                    szLocalFile = "";
                    return(SystemData.ReturnValue.FAILED);
                }
            }
            finally
            {
                if (recPaperFtpAccess != null)
                {
                    recPaperFtpAccess.CloseConnection();
                }
            }
            return(SystemData.ReturnValue.OK);
        }