Example #1
0
        private async Task RefreshAsync(bool newUser = false)
        {
            if (!IsEnabled || TfsContext == null)
            {
                IsBusy = false;
                return;
            }
            try
            {
                if (UserContext == null && !TfsContext.BuildDetailManager.IsBackgroundBuildDefinitionLoadingEnabled)
                {
                    IsVisible = false;
                    return;
                }
                IsBusy = true;
                SetTitle("Last Triggered Builds");
                if (UserContext == null)
                {
                    await Task.Delay(1000);
                }

                if (TfsContext.BuildDetailManager.AllBuildDetailsLoaded || UserContext == null)
                {
                    var pageView = TeamExplorer.CurrentPage.PageContent as BuildsPageView;
                    BuildDetails = pageView != null && !newUser && !IsInUserInfoPage
                                                ? new ObservableCollection <IBuildDetail>((await TfsContext.BuildDetailManager.QueryLastBuildsAsync()))
                                                : new ObservableCollection <IBuildDetail>((await TfsContext.BuildDetailManager.QueryBuildsAsync()).Where(GetFilter()));
                    SetTitle(string.Format("Last {0} Builds {1}", BuildDetails.Count, pageView == null ? "for this Changeset" :string.Empty));
                }
                else
                {
                    BuildDetails = new ObservableCollection <IBuildDetail>((await TfsContext.BuildDetailManager.QueryBuildsForUserAsync(UserContext.UserName)));
                }

                if (UserContext != null)
                {
                    SetTitle(string.Format("Last {0} Builds for {1}", BuildDetails.Count, UserContext.UserName));
                }

                IsVisible = BuildDetails.Any();
                if (TfsContext.BuildDetailManager.IsBackgroundBuildDefinitionLoadingEnabled)
                {
                    foreach (var buildDetail in BuildDetails)
                    {
                        buildDetail.StatusChanged += (sender, args) => RaisePropertyChanged(() => BuildDetails);
                    }
                }
            }
            finally
            {
                IsBusy = false;
                RaisePropertiesChanged(() => HasItems, () => IsInUserInfoPage, () => IsUserNameVisible, () => BuildDetails);
                UserInfoCommand.RaiseCanExecuteChanged();
            }
        }