Ejemplo n.º 1
0
        private void GetIamgeFromFTP(List <string> imgPath)
        {
            FTPHelper ftpHelper = new FTPHelper();
            FTP       souFTp    = new FTP()
            {
                hostname = ConfigurationManager.AppSettings["FtpAddr"],
                username = ConfigurationManager.AppSettings["FtpUser"],
                password = ConfigurationManager.AppSettings["FtpPwd"],
                port     = ConfigurationManager.AppSettings["FtpPort"],
            };

            if (null != imgPath && imgPath.Count > 0)
            {
                foreach (var item in imgPath)
                {
                    try
                    {
                        string source = ftpHelper.DownloadFtp(tmpDir + "\\" + GetFileName(item), "", item, souFTp);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void UploadToFtp(string slbh, DOC_BINFILE item)
        {
            FTPHelper ftpHelper = new FTPHelper();
            FTP       souFTp    = new FTP()
            {
                hostname = ConfigurationManager.AppSettings["FCFtpIP"],
                username = ConfigurationManager.AppSettings["FCFtpUser"],
                password = ConfigurationManager.AppSettings["FCFtpPWD"],
                port     = ConfigurationManager.AppSettings["FCFtpPort"],
            };
            FTP tagFTP = new FTP()
            {
                hostname = ConfigurationManager.AppSettings["FtpAddr"],
                username = ConfigurationManager.AppSettings["FtpUser"],
                password = ConfigurationManager.AppSettings["FtpPwd"],
                port     = ConfigurationManager.AppSettings["FtpPort"]
            };

            string tmpPath  = ConfigurationManager.AppSettings["TmpPath"];
            string yearDir  = slbh.Substring(0, 4);
            string monthDir = slbh.Substring(4, 2);
            string dayDir   = slbh.Substring(6, 2);
            string sortDir  = slbh.Substring(8);

            string path = ftpDir + "/" + yearDir + "/" + monthDir + "/" + dayDir + "/" + sortDir;

            if (!ftpHelper.DirectoryExist(ftpDir + "/" + yearDir, tagFTP))
            {
                ftpHelper.MakeDir(ftpDir + "/" + yearDir, tagFTP);
            }
            if (!ftpHelper.DirectoryExist(ftpDir + "/" + yearDir + "/" + monthDir, tagFTP))
            {
                ftpHelper.MakeDir(ftpDir + "/" + yearDir + "/" + monthDir, tagFTP);
            }
            if (!ftpHelper.DirectoryExist(ftpDir + "/" + yearDir + "/" + monthDir + "/" + dayDir, tagFTP))
            {
                ftpHelper.MakeDir(ftpDir + "/" + yearDir + "/" + monthDir + "/" + dayDir, tagFTP);
            }
            if (!ftpHelper.DirectoryExist(ftpDir + "/" + yearDir + "/" + monthDir + "/" + dayDir + "/" + sortDir, tagFTP))
            {
                try
                {
                    ftpHelper.MakeDir(ftpDir + "/" + yearDir + "/" + monthDir + "/" + dayDir + "/" + sortDir, tagFTP);
                }
                catch { }
            }

            //if(!FTPHelper.DirectoryExist(path,tagFTP))
            //{
            //    FTPHelper.MakeDir(path, tagFTP);
            //}

            string   source = ftpHelper.DownloadFtp(tmpPath + "\\" + GetFileName(item.FTPATH), "", item.FTPATH, souFTp);
            FileInfo fi     = new FileInfo(source);

            item.FTPATH = ftpHelper.UploadFtp("", source, path, tagFTP);
            fi.Delete();
        }