public async Task Setup() { this.personalCard = PersonalCard.Import(Settings.Default.PersonalCard); this.personalCardPassword = "******"; var dropboxClient = new DropboxClientFactory("14c-HsvO9WUAAAAAAAABfMqXv6__GhRIZMYzFK1Dvd3zsTPD-oCbzYWzthLI8DAC").GetInstance(); this.dropBoxCloudStorage = new DropBoxCloudStorage(dropboxClient, this.personalCard, this.personalCardPassword); }
public DropBoxLink(DropBoxLinkParams dropBoxLinkParams, IEventAggregator aggregator) { this.aggregator = aggregator; var client = new DropboxClientFactory(dropBoxLinkParams.AccessToken).GetInstance(); var localFolderRoot = new LocalFolderRoot(dropBoxLinkParams.LocalFolderPath); this.cloudStorage = new DropBoxCloudStorage(client, dropBoxLinkParams.Card, dropBoxLinkParams.PrivateKeyPassword); this.localFolder = new LocalFolder(localFolderRoot, "Source"); this.localFolderWatcher = new LocalFolderWatcher(this.localFolder); this.serverFolder = new ServerFolder(); this.serverFolderWatcher = new DropboxFolderWatcher(client, this.serverFolder); this.operationsFactory = new OperationsFactory(this.cloudStorage, this.localFolder); this.serverFolder.Subscribe(this); this.localFolder.Subscribe(this); }
private async void RefreshDropboxStatus(DropboxCredentials dropboxCredentials) { try { var factory = new DropboxClientFactory(dropboxCredentials.AccessToken); var dropboxClient = factory.GetInstance(); var accountTask = dropboxClient.Users.GetCurrentAccountAsync(); var spaceUsageTask = dropboxClient.Users.GetSpaceUsageAsync(); await Task.WhenAll(accountTask, spaceUsageTask); this.DropboxUserName = accountTask.Result.Email; var spaceAllocation = spaceUsageTask.Result.Allocation; this.TotalSpace = (long)(spaceAllocation.AsIndividual?.Value.Allocated ?? spaceAllocation.AsTeam?.Value.Allocated ?? 0); this.UsedSpace = (long)spaceUsageTask.Result.Used; this.UpdateUsedSapceString(); const double lowSpacePercent = 0.95; this.LowDropBoxSpace = 1.0 * this.UsedSpace / (this.TotalSpace != 0 ? this.TotalSpace : 1) >= lowSpacePercent; } catch (Exception e) { Console.WriteLine(e.ToString()); } }