//turn this into some kind of interface
        public GatherResults DownloadQtyFiles(IVendorDirectory dir)
        {
            var files = new List<File>();

            using (var ftp = new FtpLib.FtpConnection(_config.QtyFileHost,
                _config.QtyFilePort,
                _config.QtyFileUsername,
                _config.QtyFilePassword))
            {
                ftp.Open();
                ftp.Login();

                dir.EnsureExists();

                var localFile = dir.GetNewRawFile(FileTypes.Qty);
                ftp.GetFile(_config.QtyFileName, localFile.Name.GetPath(), true);
                files.Add(localFile);

                ftp.Close();
            }

            return new GatherResults
            {
                VendorHandle = dir.VendorHandle,
                Files = files
            };
        }
Exemplo n.º 2
0
        //@"ftp://*****:*****@192.168.42.6/"
        //只能支持单个FTP站点
        public bool InitHttpRoot(DataModel.VideoSupplierDeviceInfo item)
        {
            string strformat = string.IsNullOrEmpty(item.UserName) ? "{0}://{3}:{4}/{5}" : "{0}://{1}:{2}@{3}:{4}/{5}";
            string urlroot   = string.Format(strformat
                                             , (item.ProtocolType == DataModel.E_VDA_NET_STORE_DEV_PROTOCOL_TYPE.E_DEV_PROTOCOL_CONTYPE_FTP_FILE) ? "ftp" : "http"
                                             , item.UserName
                                             , item.Password
                                             , item.IP
                                             , item.Port
                                             , item.Rest);

            ftproot          = urlroot.TrimEnd('/') + "/";
            GetDirectoryList = GetFtpDirectoryList;
            GetFileList      = GetFtpFileList;
            ClearRoot();
            InitRoot(ftproot, ftproot);

            //string ftproot = @"ftp://*****:*****@192.168.42.6/";

            m_ftpService = new FtpLib.FtpConnection(item.IP, (int)item.Port, item.UserName, item.Password);
            m_ftpService.Open();
            try
            {
                m_ftpService.Login();
                //m_ftpService.SetCurrentDirectory(textBoxPath.Text);
                SaveFtpInfo();
                return(true);
            }
            catch (Exception ex)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("无法连接FTP服务器,请检查地址及用户名密码。 " + ex.Message, Framework.Environment.PROGRAM_NAME);
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Abre la conexión FTP
 /// </summary>
 public void Start()
 {
     try
     {
         clienteFTP.Open();
         clienteFTP.Login();
     }
     catch (Exception ex)
     {
         throw SpinException.GetException("SpinFTP:: " + ex.Message, ex);
     }
 }
Exemplo n.º 4
0
 void FTPLogin(string server, string username, string password, string uploadDir, bool upperChannel, bool first = true)
 {
     try
     {
         using (FtpLib.FtpConnection ftp = new FtpLib.FtpConnection(server, username, password))
         {
             ftp.Open();  /* Open the FTP connection */
             ftp.Login(); /* Login using previously provided credentials */
             DirSearch(uploadDir, ftp, "/", upperChannel, first);
             ftp.Close();
         }
     }
     catch {  }
 }