protected override void UpdateUI() { if (BACKUP_SETTINGS_SERVICE != null) { m_serviceSettings = BACKUP_SETTINGS_SERVICE.Get(BitbucketBackupService.SERVICE_ID); BitBucketSettings bbSettings = m_serviceSettings as BitBucketSettings; Username = bbSettings.Username; OAuthPublic = bbSettings.PublicKey; OAuthPrivate = bbSettings.PrivateKey; Repositories = new ObservableCollection <RepositoriesViewDto>(); List <SharpBucket.V2.Pocos.Repository> repos = BitbucketService.GetAllRepositories(); if (repos != null) { foreach (SharpBucket.V2.Pocos.Repository repo in repos) { JObject obj = JObject.Parse(repo.owner); string ownerName = obj["username"].ToString(); string profilePicUrl = obj["links"]["avatar"]["href"].ToString(); Repositories.Add(new RepositoriesViewDto() { RepoName = repo.name, Owner = ownerName, PicUrl = profilePicUrl, }); } } NotifyOfPropertyChange(() => IsInvalidCredentials); } }
public override bool SetCredentials(IBackupSettings credentials) { if (credentials is BitBucketSettings) { BitBucketSettings bbPrefs = credentials as BitBucketSettings; Username = bbPrefs.Username; PublicKey = bbPrefs.PublicKey; PrivateKey = bbPrefs.PrivateKey; m_bitbucketAPI = new BitbucketAPIService(Username, PublicKey, PrivateKey); int count = m_bitbucketAPI.IsAuthorized() ? m_bitbucketAPI.GetAllRepos(m_bitbucketAPI.Username).Count : 0; InitializeWithCredentials(count); return(true); } else { LOGGER.Info($"Not correct credentials type"); IsAuthorized = CanBackup = false; return(false); } }