Exemple #1
0
        public bool Download(Uri host, string fileName, string localFilename, bool permitOverwrite)
        {
            FTPclient ftp = new FTPclient(host.AbsoluteUri, FtpUser, FtpPassword);
            ftp.UsePassive = true;

            return ftp.Download(fileName, localFilename, permitOverwrite);
        }
Exemple #2
0
        public virtual Result Perform()
        {
            try
            {
                Result.ResultValue returnResult = Result.ResultValue.Pass;
                returnDescription = "";

                ftpClient = new FTP.FTPclient(server, user, password);

                // clear out files from any previous lookups
                files.Clear();
                totalFileSize = 0;

                AddFileData("");
                GetPreviousFiles();

                // Check to see if we're over of disk space utilization limits
                if (totalFileSizeInMB >= diskSpaceFailureLevel)
                {
                    returnResult = Result.ResultValue.Fail;
                    returnDescription += String.Format("Disk space has exceeded {0} mb, currently at {1}.", diskSpaceFailureLevel, totalFileSizeInMB);
                }
                else if (totalFileSizeInMB >= diskSpaceWarningLevel)
                {
                    returnResult = Result.ResultValue.Warning;
                    returnDescription += String.Format("Disk space has exceeded {0} mb but below {1}, currently at {2} mb.", diskSpaceWarningLevel, diskSpaceFailureLevel, totalFileSizeInMB);
                }
                else
                {
                    returnResult = Result.ResultValue.Pass;
                    returnDescription += String.Format("Disk space is below warning threshold of {0} mb.  Currently at {1} mb.", diskSpaceWarningLevel, totalFileSizeInMB);
                }

                // See if there are any changes to our files since the last time we looked.
                if (!CompareFiles())
                {
                    // There are changes. Serialize the new file list for comparison next time
                    SaveFiles();

                    // We must be careful not to downgrade any results from previous checks
                    if (returnResult < Result.ResultValue.Warning)
                    {
                        returnResult = Result.ResultValue.Warning;
                    }

                    returnDescription += "\n\nFiles have changed!" + comparisonResults;
                }
                else
                {
                    returnDescription += "\n\nFiles have not changed.";
                }

                return new Result(ActionName, returnResult, returnDescription);
            }
            catch (WebException exc)
            {
                return new Result(ActionName, Result.ResultValue.Warning, "Exception encountered: " + exc.ToString());
            }
            finally
            {
                // nulling this guy out appears to get it cleaned up which prevents the FTP server from going
                // into passive mode.
                ftpClient = null;
            }
        }
Exemple #3
0
        public bool Upload(Uri host, string localFilename)
        {
            string targFileName = Path.GetFileName(localFilename);

            FTPclient ftp = new FTPclient(host.AbsoluteUri, FtpUser, FtpPassword);
            ftp.UsePassive = true;

            return ftp.Upload(localFilename, targFileName);
        }
Exemple #4
0
 public FTPdirectory GetFtpFiles(Uri Host, string ext = "")
 {
     FTPclient ftp = new FTPclient(Host.AbsoluteUri, FtpUser, FtpPassword);
     ftp.UsePassive = true;
     FTPdirectory ftpDir = ftp.ListDirectoryDetail();
     return ftpDir.GetFiles("");
 }