Example #1
0
        private async void GetChangesetAsync(CancellationToken ct)
        {
            ITfsServer tfs = new TfsServer(GlobalSettings.TFSServerURL);

            _changesets = new TfsChangesets(tfs, ErrorHandler);
            Model.FoundMoreItemsAfterInitialSearch = false; //making this variable initialized in each call. Once anything found will be set to true
            Model.IsSearchingMode   = true;
            HasRequestedToForceStop = false;

            Action onErrorOrComplete = () => Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Background,
                new Action(() =>
            {
                DisableLoadNotificatioChangeset.Invoke();
                SearchButtonTextReset.Invoke();
                Model.IsSearchingMode = false;
            }));

            var changesets = await _changesets.GetAsync(_searchOptions);

            if (changesets == null)
            {
                onErrorOrComplete();
                return;
            }

            var changesetToLoad = changesets.ToObservable();

            Action <ChangesetViewModel> addChangesetToCollection = changeset =>
            {
                if (HasRequestedToForceStop)
                {
                    return;
                }
                Model.ChangeSetCollection.Add(changeset);
                if (Model.ChangeSetCollection.Count > GlobalSettings.SearchPageSize && !Model.FoundMoreItemsAfterInitialSearch)
                {
                    Model.FoundMoreItemsAfterInitialSearch = true;
                }
            };

            try
            {
                changesetToLoad.Subscribe(c =>
                                          Application.Current.Dispatcher.Invoke(
                                              DispatcherPriority.Background,
                                              new Action <ChangesetViewModel>(addChangesetToCollection),
                                              c),
                                          ex => onErrorOrComplete(),
                                          onErrorOrComplete,
                                          ct
                                          );
            }
            catch (QueryCancelRequest) { } //do nothing
            catch (Exception ex)
            {
                ErrorHandler(ex);
            }
        }
Example #2
0
        public void OpenChangesetWindow(string changesetId, bool requiresVerification = false)
        {
            if (string.IsNullOrEmpty(changesetId))
            {
                return;
            }

            if (changesetId == "0")
            {
                return;
            }

            int intChangesetID;

            int.TryParse(changesetId, out intChangesetID);

            if (!changesetId.Trim().Equals(intChangesetID.ToString()))
            {
                return;
            }

            if (!IsVisualStudioIsConnectedToTfs())
            {
                return;
            }

            if (requiresVerification)
            {
                ITfsServer tfs = new TfsServer(GlobalSettings.TFSServerURL);
                _changesets = new TfsChangesets(tfs, ErrorHandler);
                var changeset = _changesets.Get(int.Parse(changesetId));
                if (changeset == null)
                {
                    return;
                }
            }

            var cId = int.Parse(changesetId);

            if (cId == 0)
            {
                return;
            }

            TeamExplorer.NavigateToPage(new Guid(TeamExplorerPageIds.ChangesetDetails), cId);
        }