private async Task <bool> TesConnection(string pass) { Log.Info("Start TestConnection"); var scheme = SelectedServer.SslEnabled ? Uri.UriSchemeHttps : Uri.UriSchemeHttp; var uri = new UriBuilder(scheme, SelectedServer.Host, SelectedServer.Port, SelectedServer.RpcPath); try { var user = SelectedServer.AuthEnabled ? SelectedServer.UserName : null; var pswd = SelectedServer.AuthEnabled ? pass ?? _view.pwd.Password : null; _client = new TransmissionClient(uri.Uri.AbsoluteUri, null, user, pswd); var sessionInfo = await _client.GetSessionInformationAsync(CancellationToken.None); return(await CheckResponse(sessionInfo.Response)); } catch (Exception ex) { Log.Error(ex.Message, ex); Crashes.TrackError(ex); return(false); } finally { _client = null; IsTesting = false; } }
public RemoveTorrentDialog(IEnumerable <string> names, uint[] toRm, ref TransmissionClient?transmissionClient, bool witData = false) { InitializeComponent(); Container.ItemsSource = names; RemoveWithDataCheckBox.IsChecked = witData; _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; RemoveWithDataCheckBox.IsChecked = witData; _toRemove = toRm; _transmissionClient = transmissionClient; DataContext = this; }
/// <summary> /// /// </summary> /// <param name="transmissionClient">TransmissionClient.</param> /// <param name="ids">Torrent ids</param> /// <param name="manager">IWindowManager</param> public TorrentPropsViewModel(TransmissionClient transmissionClient, uint[] ids, IWindowManager manager) { _transmissionClient = transmissionClient; tors = ids; _manager = manager; Task.Factory.StartNew(async() => { try { var answ = await _transmissionClient.TorrentGetAsyncWithID(TorrentFields.ALL_FIELDS, new CancellationToken(), tors); if (Application.Current.Dispatcher.HasShutdownStarted) { return; } if (answ != null && answ.Torrents.Length > 0) { var ti = answ.Torrents.First(); Name = ids.Length > 1 ? $"{ids.Length} {LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.TP_TorrentsSelected))}" : ti?.Name; MaxDownSp = ti.DownloadLimit; MaxUpSp = ti.UploadLimit; PeerLimit = ti.PeerLimit; StopSeed = ti.SeedIdleLimit; SeedRation = ti.SeedRatioLimit; MXD_Bool = ti.DownloadLimited; MXU_Bool = ti.UploadLimited; //SeedR_Bool = ti.SeedRatioMode; //StopSeed_Bool = ti.SeedIdleMode; Trackers = new BindableCollection <TransmissionTorrentTrackers>(ti.Trackers); } } finally { IsBusy = Visibility.Collapsed; } }); }
public SystemService() { _client = new TransmissionClient(TransmissionContext.Credentials?.Host, null, TransmissionContext.Credentials?.User, TransmissionContext.Credentials?.Password); }