コード例 #1
0
		public FtpDownloader(Settings settings, FtpEvents events = null)
		{
			_events = events ?? new FtpEvents();
			_settings = settings;
			TvRenamer.SetRemapFile(settings.RemapFile);
			_ftpWrapper = GenerateFtpWrapper(_settings, _events);
			_cleanup = GenerateFileCleanup(_settings, _events);
		}
コード例 #2
0
		internal FtpWrapper(IFtpClient ftpClient, Settings settings)
		{
			_currentErrors = new Dictionary<string, int>();
			if (DownloadList == null)
			{
				DownloadList = new FtpListItemQueue();
			}
			_client = ftpClient;
			_settings = settings;
		}
コード例 #3
0
		private static FtpWrapper GenerateFtpWrapper(Settings settings, FtpEvents events)
		{
			var ftp = new FtpWrapper(settings);

			if (events == null)
			{
				return ftp;
			}

			ftp.OnProgressUpdated += events.UpdatedProgressHandler;
			ftp.OnDownloadStarted += events.DownloadStartedHandler;
			ftp.OnDownloadError += events.DownloadErrorHandler;
			ftp.OnDownloadComplete += events.DownloadCompletedHandler;
			
			return ftp;
		}
コード例 #4
0
		public MainWindow()
		{
			InitializeComponent();

			_viewModel = new MainViewModel();

			DataContext = _viewModel;

			var settings = new Settings
			{
				NormalRecheckTime = Properties.Settings.Default.NormalRecheckTime,
				ExpeditedRecheckTime = Properties.Settings.Default.ExpeditedRecheckTime,
				FtpRootCheckDir = Properties.Settings.Default.FTPRootCheckDir,
				TempDownloadPath = Properties.Settings.Default.TempDownloadPath,
				RemapFile = Properties.Settings.Default.RemapFile,
				MaxRetryCount = Properties.Settings.Default.MaxRetryCount,
				ProgressBarSize = Properties.Settings.Default.ProgressBarSize,
				VideoRootPath = Properties.Settings.Default.VideoRootPath,
				BatchDownloads = Properties.Settings.Default.BatchDownloads,
				FtpUserName = Properties.Settings.Default.FTPUserName,
				FtpPassword = Properties.Settings.Default.FTPPassword,
				FtpUrl = Properties.Settings.Default.FTPUrl,
				BatchDownloadSize = Properties.Settings.Default.BatchDownloadSize,
				EnableProcessing = Properties.Settings.Default.EnableProcessing
			};

			_downloader = new FtpDownloader(settings, new FtpEvents
			{
				UpdatedProgressHandler = updateProgressBar,
				DownloadStartedHandler = downloadStarted,
				DownloadErrorHandler = downloadError,
				DownloadCompletedHandler = downloadCompleted,
				CleanupCompletedHandler = cleanupCompleted,
				CleanupStartedHandler = cleanupStarted
			});

			FtpWrapper.DownloadList.OnAdd += downloadListOnOnAdd;

			_downloader.BeginProcess();
		}
コード例 #5
0
		private static FileCleanup GenerateFileCleanup(Settings settings, FtpEvents events)
		{
			var cleanup = new FileCleanup(settings.VideoRootPath);
			
			cleanup.CleanupStarted += events.CleanupStartedHandler;
			cleanup.CleanupFinished += events.CleanupCompletedHandler;

			return cleanup;
		}
コード例 #6
0
		public FtpWrapper(Settings settings) : 
			this(FtpClient(settings), settings)
		{
		}
コード例 #7
0
		public static IFtpClient FtpClient(Settings settings)
		{
			return new FtpClient
			{
				Credentials = new NetworkCredential(settings.FtpUserName, settings.FtpPassword),
				Host = settings.FtpUrl,
				DataConnectionEncryption = true,
				Port = 21
			};
		}