public UnshelveDetailsServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, ProjectCollectionServiceModel projectCollectionServiceModel, WorkspaceServiceModel workspaceServiceModel, UnshelveServiceModel unshelveServiceModel, Shelveset shelveset)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            ProjectCollectionServiceModel = projectCollectionServiceModel;
            WorkspaceServiceModel = workspaceServiceModel;
            UnshelveServiceModel = unshelveServiceModel;
            Shelveset = shelveset;

            PendingChanges = new ObservableCollection<PendingChangeModel>();

            CancelCommand = new RelayCommand(Cancel, CanCancel);
            UnshelveCommand = new RelayCommand(Unshelve, CanUnshelve);

            SelectPendingChangesCommand = new RelayCommand<SelectPendingChangesCommandArgument>(SelectPendingChanges, CanSelectPendingChanges);
            SelectWorkItemsCommand = new RelayCommand<SelectWorkItemsCommandArgument>(SelectWorkItems, CanSelectWorkItems);

            PendingSet[] pendingSets;
            if (teamPilgrimServiceModelProvider.TryWorkspaceQueryShelvedChanges(WorkspaceServiceModel.Workspace, out pendingSets, shelveset.Name, shelveset.OwnerName, null))
            {
                PendingSet = pendingSets.First();

                foreach (var pendingChange in PendingSet.PendingChanges)
                {
                    PendingChanges.Add(new PendingChangeModel(pendingChange) { IncludeChange = true });
                }
            }

            PopulateSelectedPendingChangesSummary();
        }
        public WorkspaceServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, ProjectCollectionServiceModel projectCollectionServiceModel, Workspace workspace)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            _projectCollectionServiceModel = projectCollectionServiceModel;
            Workspace = workspace;

            var versionControlServer = _projectCollectionServiceModel.TfsTeamProjectCollection.GetVersionControlServer();

            this.Logger().Debug("VersionControlServer - WebServiceLevel: {0}, SupportedFeatures: {1}", versionControlServer.WebServiceLevel, versionControlServer.SupportedFeatures);

            versionControlServer.PendingChangesChanged += VersionControlServerOnPendingChangesChanged;

            checkinNotesCacheWrapper = new CheckinNotesCacheWrapper(versionControlServer);

            ShelveCommand = new RelayCommand(Shelve, CanShelve);
            UnshelveCommand = new RelayCommand(Unshelve, CanUnshelve);
            CheckInCommand = new RelayCommand(CheckIn, CanCheckIn);
            RefreshPendingChangesCommand = new RelayCommand(RefreshPendingChanges, CanRefreshPendingChanges);
            RefreshSelectedDefinitionWorkItemsCommand = new RelayCommand(RefreshSelectedDefinitionWorkItems, CanRefreshSelectedDefinitionWorkItems);
            ShowSelectWorkItemQueryCommand = new RelayCommand(ShowSelectWorkItemQuery, CanShowSelectWorkItemQuery);
            EvaluateCheckInCommand = new RelayCommand(EvaluateCheckIn, CanEvaluateCheckIn);

            SelectPendingChangesCommand = new RelayCommand<SelectPendingChangesCommandArgument>(SelectPendingChanges, CanSelectPendingChanges);
            SelectWorkItemsCommand = new RelayCommand<SelectWorkItemsCommandArgument>(SelectWorkItems, CanSelectWorkItems);

            ViewWorkItemCommand = new RelayCommand<ObservableCollection<object>>(ViewWorkItem, CanViewWorkItem);
            ViewPendingChangeCommand = new RelayCommand<ObservableCollection<object>>(ViewPendingChange, CanViewPendingChange);
            CompareWithLatestCommand = new RelayCommand<ObservableCollection<object>>(CompareWithLatest, CanCompareWithLatest);
            CompareWithWorkspaceCommand = new RelayCommand<ObservableCollection<object>>(CompareWithWorkspace, CanCompareWithWorkspace);
            UndoPendingChangeCommand = new RelayCommand<ObservableCollection<object>>(UndoPendingChange, CanUndoPendingChange);
            PendingChangePropertiesCommand = new RelayCommand<ObservableCollection<object>>(PendingChangeProperties, CanPendingChangeProperties);

            CheckinNotes = new ObservableCollection<CheckinNoteModel>();

            PendingChanges = new ObservableCollection<PendingChangeModel>();
            _backgroundFunctionPreventDataUpdate = true;

            PendingChanges.CollectionChanged += PendingChangesOnCollectionChanged;

            _populatePendingChangedBackgroundWorker = new BackgroundWorker();
            _populatePendingChangedBackgroundWorker.DoWork += PopulatePendingChangedBackgroundWorkerOnDoWork;
            _populatePendingChangedBackgroundWorker.RunWorkerAsync();

            SolutionIsOpen = teamPilgrimVsService.Solution.IsOpen && !string.IsNullOrEmpty(teamPilgrimVsService.Solution.FileName);
            teamPilgrimVsService.SolutionStateChanged += () =>
            {
                FilterSolution = false;
                SolutionIsOpen = teamPilgrimVsService.Solution.IsOpen && !string.IsNullOrEmpty(teamPilgrimVsService.Solution.FileName);
            };

            WorkItems = new ObservableCollection<WorkItemModel>();
            WorkItems.CollectionChanged += WorkItemsOnCollectionChanged;

            PopulatePreviouslySelectedWorkItemQueryModels();

            _backgroundFunctionPreventDataUpdate = false;
        }
        public UnshelveServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider,
                                           ITeamPilgrimVsService teamPilgrimVsService,
                                           ProjectCollectionServiceModel projectCollectionServiceModel, WorkspaceServiceModel workspaceServiceModel)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            ProjectCollectionServiceModel = projectCollectionServiceModel;
            WorkspaceServiceModel = workspaceServiceModel;

            ShelvesetOwner = projectCollectionServiceModel.TfsTeamProjectCollection.AuthorizedIdentity.UniqueName;

            FindShelvesetsCommand = new RelayCommand<string>(FindShelvesets, CanFindShelvesets);
            CancelCommand = new RelayCommand(Cancel, CanCancel);

            ViewPendingSetCommand = new RelayCommand<ShelvesetModel>(ViewPendingSet, CanViewPendingSet);

            UnshelveCommand = new RelayCommand<ObservableCollection<object>>(Unshelve, CanUnshelve);
            DeleteCommand = new RelayCommand<ObservableCollection<object>>(Delete, CanDelete);
            DetailsCommand = new RelayCommand<ObservableCollection<object>>(Details, CanDetails);

            FindShelvesetsCommand.Execute(null);
        }
        public ShelveServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider,
            ITeamPilgrimVsService teamPilgrimVsService,
            ProjectCollectionServiceModel projectCollectionServiceModel, WorkspaceServiceModel workspaceServiceModel)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            _projectCollectionServiceModel = projectCollectionServiceModel;
            _workspaceServiceModel = workspaceServiceModel;

            var versionControlServer = _projectCollectionServiceModel.TfsTeamProjectCollection.GetService<VersionControlServer>();
            versionControlServer.PendingChangesChanged += VersionControlServerOnPendingChangesChanged;

            _filterSolution = workspaceServiceModel.FilterSolution;
            _selectedWorkWorkItemQueryDefinition = workspaceServiceModel.SelectedWorkItemQueryDefinition;
            _comment = workspaceServiceModel.Comment;

            EvaluateCheckInCommand = new RelayCommand(EvaluateCheckIn, CanEvaluateCheckIn);
            ShowSelectWorkItemQueryCommand = new RelayCommand(ShowSelectWorkItemQuery, CanShowSelectWorkItemQuery);
            RefreshPendingChangesCommand = new RelayCommand(RefreshPendingChanges, CanRefreshPendingChanges);
            RefreshSelectedDefinitionWorkItemsCommand = new RelayCommand(RefreshSelectedDefinitionWorkItems, CanRefreshSelectedDefinitionWorkItems);
            ShelveCommand = new RelayCommand(Shelve, CanShelve);
            CancelCommand = new RelayCommand(Cancel, CanCancel);

            SelectPendingChangesCommand = new RelayCommand<SelectPendingChangesCommandArgument>(SelectPendingChanges, CanSelectPendingChanges);
            SelectWorkItemsCommand = new RelayCommand<SelectWorkItemsCommandArgument>(SelectWorkItems, CanSelectWorkItems);

            CompareWithLatestCommand = new RelayCommand<ObservableCollection<object>>(CompareWithLatest, CanCompareWithLatest);
            CompareWithWorkspaceCommand = new RelayCommand<ObservableCollection<object>>(CompareWithWorkspace, CanCompareWithWorkspace);
            UndoPendingChangeCommand = new RelayCommand<ObservableCollection<object>>(UndoPendingChange, CanUndoPendingChange);
            PendingChangePropertiesCommand = new RelayCommand<ObservableCollection<object>>(PendingChangeProperties, CanPendingChangeProperties);

            CheckinNotes = new ObservableCollection<CheckinNoteModel>();

            PendingChanges = new ObservableCollection<PendingChangeModel>();
            foreach (var pendingChangeModel in workspaceServiceModel.PendingChanges)
            {
                PendingChanges.Add(new PendingChangeModel(pendingChangeModel.Change)
                {
                    IncludeChange = pendingChangeModel.IncludeChange
                });
            }

            PendingChanges.CollectionChanged += PendingChangesOnCollectionChanged;

            WorkItems = new ObservableCollection<WorkItemModel>();
            foreach (var workItemModel in workspaceServiceModel.WorkItems)
            {
                WorkItems.Add(new WorkItemModel(workItemModel.WorkItem)
                {
                    IsSelected = workItemModel.IsSelected,
                    WorkItemCheckinAction = workItemModel.WorkItemCheckinAction
                });
            }

            WorkItems.CollectionChanged += WorkItemsOnCollectionChanged;

            SolutionIsOpen = teamPilgrimVsService.Solution.IsOpen && !string.IsNullOrEmpty(teamPilgrimVsService.Solution.FileName);
            teamPilgrimVsService.SolutionStateChanged += () =>
            {
                FilterSolution = false;
                SolutionIsOpen = teamPilgrimVsService.Solution.IsOpen && !string.IsNullOrEmpty(teamPilgrimVsService.Solution.FileName);
            };

            PopulatePreviouslySelectedWorkItemQueryModels();
            PopulateSelectedPendingChangesSummary();

            EvaluateCheckInCommand.Execute(null);
        }
예제 #5
0
        private void PopulateBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            try
            {
                var domainUri = (string)doWorkEventArgs.Argument;

                this.Logger().Trace("Begin Populate");

                var tpcAddress = new Uri(domainUri);
                TfsTeamProjectCollection collection;

                if (!teamPilgrimServiceModelProvider.TryGetCollection(out collection, tpcAddress))
                {
                    return;
                }

                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Clear(), DispatcherPriority.Normal);
                if (collection == null)
                {
                    return;
                }

                var projectCollectionServiceModel = new ProjectCollectionServiceModel(teamPilgrimServiceModelProvider,
                                                                                      teamPilgrimVsService, this,
                                                                                      collection);
                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Add(projectCollectionServiceModel));

                WorkspaceInfo[] workspaceInfos;
                if (teamPilgrimServiceModelProvider.TryGetLocalWorkspaceInfos(out workspaceInfos, collection.InstanceId))
                {
                    Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Clear(), DispatcherPriority.Normal);

                    if (_populateBackgroundWorker.CancellationPending)
                    {
                        doWorkEventArgs.Cancel = true;
                        return;
                    }

                    var activeWorkspace = teamPilgrimVsService.ActiveWorkspace;

                    WorkspaceInfoModel selectedWorkspaceInfoModel = null;

                    foreach (var workspaceInfo in workspaceInfos)
                    {
                        var workspaceInfoModel = new WorkspaceInfoModel(workspaceInfo);
                        Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Add(workspaceInfoModel),
                                                              DispatcherPriority.Normal);

                        if (activeWorkspace != null && activeWorkspace.QualifiedName == workspaceInfo.QualifiedName)
                        {
                            selectedWorkspaceInfoModel = workspaceInfoModel;
                        }

                        if (_populateBackgroundWorker.CancellationPending)
                        {
                            doWorkEventArgs.Cancel = true;
                            return;
                        }
                    }

                    if (selectedWorkspaceInfoModel != null)
                    {
                        Application.Current.Dispatcher.Invoke(
                            () => SelectedWorkspaceInfoModel = selectedWorkspaceInfoModel, DispatcherPriority.Normal);
                    }
                }

                this.Logger().Trace("End Populate");
            }
            finally
            {
                _populateResetEvent.Set();
            }
        }
 public SelectWorkItemQueryModel(ProjectCollectionServiceModel activeProjectCollectionServiceModel)
 {
     ActiveProjectCollectionModel = activeProjectCollectionServiceModel;
 }
        private void PopulateBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            try
            {
                var domainUri = (string) doWorkEventArgs.Argument;

                this.Logger().Trace("Begin Populate");

                var tpcAddress = new Uri(domainUri);
                TfsTeamProjectCollection collection;

                if (!teamPilgrimServiceModelProvider.TryGetCollection(out collection, tpcAddress))
                    return;

                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Clear(), DispatcherPriority.Normal);
                if (collection == null)
                    return;

                var projectCollectionServiceModel = new ProjectCollectionServiceModel(teamPilgrimServiceModelProvider,
                                                                                      teamPilgrimVsService, this,
                                                                                      collection);
                Application.Current.Dispatcher.Invoke(() => ProjectCollectionModels.Add(projectCollectionServiceModel));

                WorkspaceInfo[] workspaceInfos;
                if (teamPilgrimServiceModelProvider.TryGetLocalWorkspaceInfos(out workspaceInfos, collection.InstanceId))
                {
                    Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Clear(), DispatcherPriority.Normal);

                    if (_populateBackgroundWorker.CancellationPending)
                    {
                        doWorkEventArgs.Cancel = true;
                        return;
                    }

                    var activeWorkspace = teamPilgrimVsService.ActiveWorkspace;

                    WorkspaceInfoModel selectedWorkspaceInfoModel = null;

                    foreach (var workspaceInfo in workspaceInfos)
                    {
                        var workspaceInfoModel = new WorkspaceInfoModel(workspaceInfo);
                        Application.Current.Dispatcher.Invoke(() => WorkspaceInfoModels.Add(workspaceInfoModel),
                                                              DispatcherPriority.Normal);

                        if (activeWorkspace != null && activeWorkspace.QualifiedName == workspaceInfo.QualifiedName)
                        {
                            selectedWorkspaceInfoModel = workspaceInfoModel;
                        }

                        if (_populateBackgroundWorker.CancellationPending)
                        {
                            doWorkEventArgs.Cancel = true;
                            return;
                        }
                    }

                    if (selectedWorkspaceInfoModel != null)
                    {
                        Application.Current.Dispatcher.Invoke(
                            () => SelectedWorkspaceInfoModel = selectedWorkspaceInfoModel, DispatcherPriority.Normal);
                    }
                }

                this.Logger().Trace("End Populate");
            }
            finally
            {
                _populateResetEvent.Set();
            }
        }