private async Task ExecuteConnect() { IsConnecting = true; _log.Clear(); RaisePropertyChanged(nameof(Log)); var client = _ftpClientFactory.CreateClient(Host, UserName, Password, Port); client.Log += Client_Log; _cancellationTokenSource = new CancellationTokenSource(); var result = await client.ConnectAsync(_cancellationTokenSource.Token); if (result.Success) { IsConnected = true; _wftpClient = client; var browser = _ftpBrowserCreator(); browser.Load(client); FtpBrowser = browser; } else { client.Log -= Client_Log; client.Dispose(); _dialogService.Show(result.ErrorMessage); } IsConnecting = false; }
public async void Load(IWFTPClient wFTPClient) { _wFtpClient = wFTPClient; _cancellationTokenSource = new CancellationTokenSource(); var workingDirectoryResult = await _wFtpClient.GetWorkingDirectoryAsync(_cancellationTokenSource.Token); _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; if (!workingDirectoryResult.Success) { _dialogService.Show(workingDirectoryResult.ErrorMessage); IsLoaded = true; return; } Directory = workingDirectoryResult.Result; await ExecuteRefresh(); IsLoaded = true; }
private async Task ExecuteDisconnect() { IsConnecting = true; _cancellationTokenSource = new CancellationTokenSource(); var ftpBrowser = FtpBrowser; FtpBrowser = null; ftpBrowser.Dispose(); var result = await _wftpClient.DisconnectAsync(_cancellationTokenSource.Token); _wftpClient.Log -= Client_Log; _wftpClient.Dispose(); _wftpClient = null; if (!result.Success) { _dialogService.Show(result.ErrorMessage); } IsConnecting = false; IsConnected = false; }