Ejemplo n.º 1
0
        private async Task GetRepositories()
        {
            _log.Write(LogLevel.Debug, "Fetching repositories for current user");
            Repositories.Clear();
            Organizations.Clear();

            try
            {
                var repositories = await _github.Repository.GetAllForCurrent();

                AddRepositories(repositories);
                var organizations = await _github.Organization.GetAllForCurrent();

                foreach (var organization in organizations)
                {
                    repositories = await _github.Repository.GetAllForOrg(organization.Login);

                    AddRepositories(repositories);
                }
                OnRepositoriesComplete();
            }
            catch (Exception exception)
            {
                _log.Write(LogLevel.Warn, "Failed to get repository data", exception);
            }
        }
        /// <summary>
        /// Get a list of local repositories.  It is saved to local variable localRepos.
        /// For each local repository, get remote urls list.
        /// From each URL, get the project-id.
        /// Now, check if the list of 'cloud repositories' under the project-id contains the URL.
        /// If it does, the local repository with the URL will be shown to user.
        /// </summary>
        private async Task ListRepositoryAsync()
        {
            if (!IsReady)
            {
                return;
            }

            var projects = await GetProjectsAsync();

            IsReady = false;
            Repositories.Clear();
            try
            {
                var watch = Stopwatch.StartNew();
                await AddLocalReposAsync(await GetLocalGitRepositoriesAsync(), projects);

                EventsReporterWrapper.ReportEvent(
                    CsrListedEvent.Create(CommandStatus.Success, watch.Elapsed));
                ShowActiveRepo(_teamExplorer.GetActiveRepository());
            }
            catch (Exception)
            {
                EventsReporterWrapper.ReportEvent(CsrListedEvent.Create(CommandStatus.Failure));
                throw;
            }
            finally
            {
                IsReady = true;
            }
        }
Ejemplo n.º 3
0
        private void LoadRepositories()
        {
            IReadOnlyList <Repository> known   = null;
            IReadOnlyList <Project>    remotes = null;

            Exception ex = null;

            Task.Run(async() =>
            {
                try
                {
                    remotes = await _web.GetProjectsAsync();
                    known   = Registry.GetKnownRepositories();
                }
                catch (Exception e)
                {
                    ex = e;
                }
            }).ContinueWith(async tsk =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                if (ex == null)
                {
                    Repositories.Clear();

                    var activeRepository = _teamexplorer.GetActiveRepository();

                    var valid = new List <Repository>();

                    if (known != null)
                    {
                        foreach (var k in known)
                        {
                            var r = remotes.FirstOrDefault(o => o.Name == k.Name);
                            if (r != null)
                            {
                                k.Icon = r.Icon;

                                valid.Add(k);
                            }
                        }
                    }

                    if (activeRepository != null)
                    {
                        var matched = valid.FirstOrDefault(o => string.Equals(o.Path, activeRepository.Path, StringComparison.OrdinalIgnoreCase));
                        if (matched != null)
                        {
                            matched.IsActived = true;
                        }
                    }

                    valid.Each(o => Repositories.Add(o));
                }
                else if (!(ex is UnauthorizedAccessException))
                {
                    _teamexplorer.ShowMessage(ex.Message);
                }
            }, TaskScheduler.Default).Forget();
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    var connection = DbContext.Database.Connection;
                    if (connection != null && connection.State != ConnectionState.Closed)
                    {
                        connection.Close();
                    }

                    if (DbContext != null)
                    {
                        DbContext.Dispose();
                        DbContext = null;
                    }

                    if (Repositories != null)
                    {
                        foreach (var repository in Repositories.Values)
                        {
                            repository.Dispose();
                        }


                        Repositories.Clear();
                        Repositories = null;
                    }
                }
            }

            disposed = true;
        }
Ejemplo n.º 5
0
        public async void Search()
        {
            Repositories.Clear();

            var repositories = await _gitHubClient.Search.SearchRepo(new SearchRepositoriesRequest(Term));

            Repositories.AddRange(repositories.Items);
        }
Ejemplo n.º 6
0
 public override void Logout()
 {
     _log.Write(LogLevel.Info, "Logging out of GitHub");
     base.Logout();
     SettingsCache.Credentials = null;
     User = null;
     Repositories.Clear();
     Organizations.Clear();
     AllIssues.Clear();
     OnPropertyChanged("Issues");
 }
Ejemplo n.º 7
0
        private void Dispose(bool disposing)
        {
            if (!_disposed && disposing)
            {
                // clear repositories
                Repositories?.Clear();
                // dispose the db context.
                DataContext?.Dispose();
            }

            _disposed = true;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 /// <param name="disposing">The disposing.</param>
 protected virtual void Dispose(bool disposing)
 {
     lock (SyncRoot)
     {
         if (!Disposed && disposing)
         {
             Logger?.LogTrace("Disposing {0}", GetType().GetFriendlyName());
             Repositories.Clear();
             ReadOnlyRepositories.Clear();
             DbContext.Dispose();
         }
         Disposed = true;
     }
 }
        private async void Loaded()
        {
            List <RepositoryViewModel> tmpRepositories = null;
            List <LauncherViewModel>   tmpLaunchers    = null;
            await Task.Run(() =>
            {
                tmpRepositories = GetRepositories();
                tmpLaunchers    = GetLaunchers();
            });

            Repositories.Clear();
            Repositories.AddRange(tmpRepositories);

            Launchers.Clear();
            Launchers.AddRange(tmpLaunchers);

            SettingsChanged = false;
        }
Ejemplo n.º 10
0
        private async Task LoadRepos()
        {
            var repos = await UserUtility.GetUserRepositories();

            if (repos.Count == 0 || repos == null)
            {
                ZeroRepo = true;
                if (Repositories != null)
                {
                    Repositories.Clear();
                }
            }
            else
            {
                ZeroRepo = false;
                RepositoriesNotFiltered = Repositories = repos;
            }
        }
Ejemplo n.º 11
0
        private async Task LoadRepos()
        {
            var repos = await UserDataService.getUserRepositories();

            if (repos.Count == 0 || repos == null)
            {
                ZeroRepo = true;
                if (Repositories != null)
                {
                    Repositories.Clear();
                }
            }
            else
            {
                ZeroRepo     = false;
                Repositories = repos;
            }
        }
Ejemplo n.º 12
0
        internal virtual void CommandDeleteExecute()
        {
            if (Repositories.Count == 0 && IsFileLoaded)
            {
                if (MessageBox.Show(
                        Resources.MainWindowVM_commandDeleteExecute_DeleteCheckedFiles_ConfirmText,
                        Resources.MainWindowVM_commandDeleteExecute_DeleteCheckedFiles_ConfirmTitle,
                        MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
                {
                    return;
                }

                // Delete all selected file
                if (DeleteFiles(Repositories))
                {
                    Repositories.Clear();
                    IsFileLoaded = false;
                }
            }
        }
Ejemplo n.º 13
0
        public async Task LoadRepositories()
        {
            Repositories.Clear();
            OctokitRepositories.Clear();

            var result = await Client.Repository.GetAllForCurrent();


            foreach (var repository in result)
            {
                OctokitRepositories.Add(repository);
                Repositories.Add(new Models.Repository()
                {
                    Id              = repository.Id,
                    FullName        = repository.FullName,
                    Name            = repository.Name,
                    HasIssues       = repository.HasIssues,
                    Language        = repository.Language,
                    OpenIssuesCount = repository.OpenIssuesCount
                });
            }
        }
Ejemplo n.º 14
0
 void UpdateRepositoriesFromCustomRepo()
 {
     Repositories.Clear();
     Repositories.Add(CustomRepoUrl.ToUri().ProcessRepoUrl());
 }
Ejemplo n.º 15
0
 public void Reset()
 {
     Repositories.Clear();
 }
Ejemplo n.º 16
0
 public void ClearPersistenceRepositories()
 {
     Repositories.Clear();
 }
Ejemplo n.º 17
0
 public void Dispose()
 {
     Repositories.Clear();
     Repositories = null;
 }