示例#1
0
        private void ButtonBorrarImagen_Click(object sender, EventArgs e)
        {
            Chilkat.Ftp2 ftp = new Chilkat.Ftp2();
            bool         success;

            ftp.Hostname = "www.repuestosdemoviles.es";
            ftp.Username = "******";
            ftp.Password = "******";
            success      = ftp.Connect();
            if (success != true)
            {
                Console.WriteLine(ftp.LastErrorText);
                return;
            }
            string codigo  = (string)gridViewArticulos.GetRowCellValue(gridViewArticulos.FocusedRowHandle, colCodigo);
            string cwd     = "httpdocs/ebay/imagenes/" + codigo.Trim();
            string BaseUrl = "http://www.repuestosdemoviles.es/ebay/imagenes/" + codigo.Trim();

            success = ftp.ChangeRemoteDir(cwd);
            var    i        = imageSlider1.CurrentImageIndex;
            string filename = ListaImagenes[i];

            ftp.DeleteRemoteFile(filename);
            ftp.Disconnect();
            CargarImagenes(codigo);
        }
示例#2
0
        /// <summary>
        /// FtpInternalDownload() --> Performs an FTP Download.
        /// </summary>
        /// <param name="folder">Indicates the folder where the file will be uploaded</param>
        /// <param name="localfolders">Indicates the local folders where the file will be downloaded to</param>
        /// <param name="apps">Indicates the eFlow apps for which the download are going to be placed</param>
        /// <param name="hostname">Indicates the host name where the file will be uploaded</param>
        /// <param name="username">Indicates the name of the user allowed to login into the hostname</param>
        /// <param name="pwd">Indicates the password of the user allowed to login into the hostname</param>
        /// <example><code>s.FtpInternalDownload("/images_receive", localfolders, apps, "ftp.doksend.com", "supplierportaluser", "e7low5!!");</code></example>
        protected bool FtpInternalDownload(string folder, string[] localfolders, string[] apps, string hostname, string username, string pwd)
        {
            bool result = false;

            try
            {
                using (Chilkat.Ftp2 ftp = new Chilkat.Ftp2())
                {
                    if (ftp.UnlockComponent(Constants.cStrChilkatFtpLic))
                    {
                        ftp.Hostname = hostname;
                        ftp.Username = username;
                        ftp.Password = pwd;

                        ftp.Passive = true;

                        if (ftp.Connect())
                        {
                            if (ftp.ChangeRemoteDir(folder))
                            {
                                ftp.ListPattern = Constants.cStrAllAll;

                                for (int i = 0; i <= ftp.NumFilesAndDirs - 1; i++)
                                {
                                    if (localfolders.Length > 0 && apps.Length > 0)
                                    {
                                        string fl  = ftp.GetFilename(i);
                                        string lfn = GetLocalFolderFileName(fl, localfolders, apps);

                                        if (File.Exists(lfn))
                                        {
                                            File.Delete(lfn);
                                        }

                                        result = ftp.GetFile(fl, lfn);
                                        Thread.Sleep(50);

                                        ftp.DeleteRemoteFile(fl);
                                        Thread.Sleep(50);
                                    }
                                }
                            }
                        }
                        else
                        {
                            Logging.WriteLog(ftp.LastErrorText);
                        }

                        ftp.Disconnect();
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteLog(ex.ToString());
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// FtpInternalCleanupImageWithNoCollections() --> Cleanup images which do not have a corresponding collection on the portal (FTP).
        /// </summary>
        /// <param name="cust">Indicates the name of supplier portal customer.</param>
        /// <param name="app">Indicates the name of eFlow application.</param>
        /// <param name="fn">Indicates the name of the file to upload.</param>
        /// <param name="fnUp">Indicates the name of the file on the server (how it will be called once uploaded).</param>
        /// <param name="folder">Indicates the folder where the file will be uploaded</param>
        /// <param name="hostname">Indicates the host name where the file will be uploaded</param>
        /// <param name="username">Indicates the name of the user allowed to login into the hostname</param>
        /// <param name="pwd">Indicates the password of the user allowed to login into the hostname</param>
        /// <example><code>s.FtpInternalCleanupImageWithNoCollections("topimagesystems.com", "CLS", "00000323.tif", "/images", "ftp.doksend.com", "supplierportaluser", "e7low5!!");</code></example>
        protected bool FtpInternalCleanupImageWithNoCollections(string cust, string app, string fn, string fnUp, string folder, string hostname, string username, string pwd)
        {
            bool result = false;

            try
            {
                using (Chilkat.Ftp2 ftp = new Chilkat.Ftp2())
                {
                    if (ftp.UnlockComponent(Constants.cStrChilkatFtpLic))
                    {
                        ftp.Hostname = hostname;
                        ftp.Username = username;
                        ftp.Password = pwd;

                        ftp.Passive = true;

                        if (ftp.Connect())
                        {
                            if (ftp.ChangeRemoteDir(folder))
                            {
                                // Cleanup images which do not have a corresponding collection on the portal
                                ftp.ListPattern = Constants.cStrAllTif;
                                for (int i = 0; i <= ftp.NumFilesAndDirs - 1; i++)
                                {
                                    string fl        = ftp.GetFilename(i);
                                    string customer  = fl.Substring(0, fl.IndexOf("_"));
                                    string appName   = ExtractStrInBetween(fl, "_", "-");
                                    string batchName = ExtractStrInBetween(fl, "-", Constants.cStrTif);

                                    //if (HttpPostCollectionDataQry(customer + "_" + appName,
                                    if (HttpPostCollectionDataQry(cust + "_" + appName,
                                                                  Constants.cStrHttpPostCollectionDatacollectionNameQryCln,
                                                                  batchName, 80, false).ToLower().Contains(Constants.cStrEmptyJsonResponse))
                                    {
                                        Thread.Sleep(50);
                                        ftp.DeleteRemoteFile(fl);
                                    }
                                }
                            }
                        }
                        else
                        {
                            Logging.WriteLog(ftp.LastErrorText);
                        }

                        ftp.Disconnect();
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteLog(ex.ToString());
            }

            return(result);
        }