Exemplo n.º 1
0
 public StartSyncParams(
     PersonalCard personalCard,
     string password,
     DropboxCredentials dropboxCredentials,
     string sourceDir)
 {
     this.PersonalCard       = personalCard;
     this.Password           = password;
     this.DropboxCredentials = dropboxCredentials;
     this.SourceDir          = sourceDir;
 }
        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());
            }
        }