コード例 #1
0
        public void Unshelve()
        {
            Shelveset shelveset;
            bool      result;

            if (PendingChanges.All(model => model.IncludeChange))
            {
                result = teamPilgrimServiceModelProvider.TryWorkspaceUnshelve(WorkspaceServiceModel.Workspace, out shelveset, Shelveset.Name, Shelveset.OwnerName);
            }
            else
            {
                var itemSpecs = PendingChanges
                                .Where(model => model.IncludeChange)
                                .Select(model => new ItemSpec(model.Change))
                                .ToArray();

                result = teamPilgrimServiceModelProvider.TryWorkspaceUnshelve(WorkspaceServiceModel.Workspace, out shelveset,
                                                                              Shelveset.Name, Shelveset.OwnerName, itemSpecs);
            }

            if (result)
            {
                if (RestoreWorkItemsAndCheckinNotes)
                {
                    foreach (var workItemCheckinInfo in Shelveset.WorkItemInfo)
                    {
                        WorkspaceServiceModel.SelectWorkItemById(workItemCheckinInfo.WorkItem.Id);
                    }

                    foreach (var checkinNoteFieldValue in this.Shelveset.CheckinNote.Values)
                    {
                        WorkspaceServiceModel.RestoreCheckinNoteFieldValue(checkinNoteFieldValue);
                    }
                }

                if (!PreserveShelveset)
                {
                    teamPilgrimServiceModelProvider.TryDeleteShelveset(ProjectCollectionServiceModel.TfsTeamProjectCollection, shelveset.Name, shelveset.OwnerName);
                }
            }

            OnDismiss(result, true);
        }
コード例 #2
0
        private void EvaluateCheckIn()
        {
            this.Logger().Trace("EvaluateCheckIn");

            var pendingChanges = PendingChanges
                                 .Where(model => model.IncludeChange)
                                 .Select(model => model.Change)
                                 .ToArray();

            if (!pendingChanges.Any())
            {
                CheckinEvaluationResult = null;
                CheckinNotes.Clear();
                return;
            }

            var currentCheckinNoteDefinitions = checkinNotesCacheWrapper.GetCheckinNotes(pendingChanges);

            var equalityComparer = CheckinNoteFieldDefinition.NameComparer.ToGenericComparer <CheckinNoteFieldDefinition>().ToEqualityComparer();

            var modelIntersection =
                CheckinNotes
                .Join(currentCheckinNoteDefinitions, model => model.CheckinNoteFieldDefinition, checkinNoteFieldDefinition => checkinNoteFieldDefinition, (model, change) => model, equalityComparer)
                .ToArray();

            var modelsToRemove = CheckinNotes.Where(model => !modelIntersection.Contains(model)).ToArray();

            var modelsToAdd = currentCheckinNoteDefinitions
                              .Where(checkinNoteFieldDefinition => !modelIntersection.Select(model => model.CheckinNoteFieldDefinition).Contains(checkinNoteFieldDefinition, equalityComparer))
                              .Select(checkinNoteFieldDefinition => new CheckinNoteModel(checkinNoteFieldDefinition)).ToArray();

            foreach (var checkinNoteModel in modelsToAdd)
            {
                CheckinNotes.Add(checkinNoteModel);
            }

            foreach (var modelToRemove in modelsToRemove)
            {
                CheckinNotes.Remove(modelToRemove);
            }

            CheckinEvaluationResult checkinEvaluationResult;

            var workItemChanges =
                WorkItems
                .Where(model => model.IsSelected)
                .Select(model => new WorkItemCheckinInfo(model.WorkItem, model.WorkItemCheckinAction.ToWorkItemCheckinAction())).ToArray();

            var checkinNoteFieldValues =
                CheckinNotes
                .Where(model => !string.IsNullOrWhiteSpace(model.Value))
                .Select(model => new CheckinNoteFieldValue(model.CheckinNoteFieldDefinition.Name, model.Value))
                .ToArray();

            var checkinNote = new CheckinNote(checkinNoteFieldValues);

            if (teamPilgrimServiceModelProvider.TryEvaluateCheckin(out checkinEvaluationResult, Workspace, pendingChanges, Comment, checkinNote, workItemChanges))
            {
                CheckinEvaluationResult = checkinEvaluationResult;
            }
        }
コード例 #3
0
        private void CheckIn()
        {
            this.Logger().Trace("CheckIn");

            var pendingChanges = PendingChanges
                                 .Where(model => model.IncludeChange)
                                 .Select(model => model.Change)
                                 .ToArray();

            var workItemChanges =
                WorkItems.Where(model => model.IsSelected)
                .Select(model => new WorkItemCheckinInfo(model.WorkItem, model.WorkItemCheckinAction.ToWorkItemCheckinAction())).ToArray();

            var missingCheckinNotes = CheckinNotes
                                      .Where(model => model.CheckinNoteFieldDefinition.Required && string.IsNullOrWhiteSpace(model.Value))
                                      .Select(model => model.CheckinNoteFieldDefinition.Name).ToArray();

            if (missingCheckinNotes.Any())
            {
                OnShowPendingChangesItem(ShowPendingChangesTabItemEnum.CheckinNotes);

                MessageBox.Show("Check-in Validation\r\n\r\nEnter a value for " + string.Join(", ", missingCheckinNotes), "Team Pilgrim", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var checkinNoteFieldValues =
                CheckinNotes
                .Where(model => !string.IsNullOrWhiteSpace(model.Value))
                .Select(model => new CheckinNoteFieldValue(model.CheckinNoteFieldDefinition.Name, model.Value))
                .ToArray();

            var checkinNote = new CheckinNote(checkinNoteFieldValues);

            CheckinEvaluationResult checkinEvaluationResult;

            if (teamPilgrimServiceModelProvider.TryEvaluateCheckin(out checkinEvaluationResult, Workspace, pendingChanges, Comment, checkinNote, workItemChanges))
            {
                this.Logger().Debug("CheckIn EvaluateCheckin: Valid:{0}", checkinEvaluationResult.IsValid());

                PolicyOverrideInfo policyOverrideInfo = null;

                if (!checkinEvaluationResult.IsValid())
                {
                    if (checkinEvaluationResult.Conflicts.Any())
                    {
                        MessageBox.Show(
                            "Check In\r\n\r\nNo files checked in due to conflicting changes. Please use Conflicts Manager to resolve conflicts and try again.",
                            "Team Pilgrim", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                        var conflictedServerItems = checkinEvaluationResult.Conflicts.Select(conflict => conflict.ServerItem).ToArray();
                        teamPilgrimVsService.ResolveConflicts(Workspace, conflictedServerItems, false, false);

                        return;
                    }

                    if (checkinEvaluationResult.PolicyFailures.Any())
                    {
                        OnShowPendingChangesItem(ShowPendingChangesTabItemEnum.PolicyWarnings);

                        var policyFailureModel  = new PolicyFailureModel();
                        var policyFailureDialog = new PolicyFailureDialog()
                        {
                            DataContext = policyFailureModel
                        };

                        var dialogResult = policyFailureDialog.ShowDialog();
                        if (!dialogResult.HasValue || !dialogResult.Value || !policyFailureModel.Override)
                        {
                            CheckinEvaluationResult = checkinEvaluationResult;
                            return;
                        }

                        policyOverrideInfo = new PolicyOverrideInfo(policyFailureModel.Reason, checkinEvaluationResult.PolicyFailures);
                    }
                }

                if (teamPilgrimServiceModelProvider.TryCheckin(Workspace, pendingChanges, Comment, checkinNote, workItemChanges, policyOverrideInfo))
                {
                    Comment = string.Empty;
                    RefreshPendingChanges();

                    foreach (var workItem in WorkItems.Where(model => model.IsSelected))
                    {
                        workItem.IsSelected = false;
                    }

                    RefreshPendingChangesCommand.Execute(null);
                    RefreshSelectedDefinitionWorkItemsCommand.Execute(null);
                }
            }
        }
コード例 #4
0
        private void PopulatePendingChangedBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            this.Logger().Trace("Begin Refresh Pending Changes");

            PendingChange[] currentPendingChanges;

            var filterItems = SolutionIsOpen && FilterSolution;

            string[] solutionFilePaths = null;

            if (filterItems)
            {
                try
                {
                    solutionFilePaths = teamPilgrimVsService.GetSolutionFilePaths();
                }
                catch (Exception)
                {
                    filterItems = false;
                }
            }

            if (filterItems
                    ? teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, Workspace,
                                                                           solutionFilePaths)
                    : teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, Workspace))
            {
                var intersections = PendingChanges
                                    .Join(currentPendingChanges, model => model.Change.ItemId, change => change.ItemId,
                                          (model, change) => new { model, change })
                                    .ToArray();

                var intersectedModels =
                    intersections
                    .Select(arg => arg.model)
                    .ToArray();

                var modelsToRemove = PendingChanges.Where(model => !intersectedModels.Contains(model)).ToArray();

                var modelsToAdd = currentPendingChanges
                                  .Where(
                    pendingChange =>
                    !intersectedModels.Select(model => model.Change.ItemId).Contains(pendingChange.ItemId))
                                  .Select(change => new PendingChangeModel(change)
                {
                    IncludeChange = true
                }).ToArray();

                Application.Current.Dispatcher.Invoke(() =>
                {
                    _backgroundFunctionPreventDataUpdate = true;

                    foreach (var intersection in intersections)
                    {
                        intersection.model.Change = intersection.change;
                    }

                    foreach (var pendingChangeModel in modelsToAdd)
                    {
                        PendingChanges.Add(pendingChangeModel);
                    }

                    foreach (var modelToRemove in modelsToRemove)
                    {
                        PendingChanges.Remove(modelToRemove);
                    }

                    _backgroundFunctionPreventDataUpdate = false;

                    PendingChangesOnCollectionChanged();
                }, DispatcherPriority.Normal);
            }

            this.Logger().Trace("End Refresh Pending Changes");
        }
コード例 #5
0
        private void Shelve()
        {
            var pendingChanges = PendingChanges
                                 .Where(model => model.IncludeChange)
                                 .Select(model => model.Change)
                                 .ToArray();

            if (EvaluatePoliciesAndCheckinNotes)
            {
                var missingCheckinNotes = CheckinNotes
                                          .Where(model => model.CheckinNoteFieldDefinition.Required && string.IsNullOrWhiteSpace(model.Value))
                                          .Select(model => model.CheckinNoteFieldDefinition.Name).ToArray();

                if (missingCheckinNotes.Any())
                {
                    OnShowPendingChangesItem(ShowPendingChangesTabItemEnum.CheckinNotes);

                    MessageBox.Show(
                        string.Format("Check-in Validation\r\n\r\nEnter a value for {0}", string.Join(", ", missingCheckinNotes)),
                        "Team Pilgrim", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            var workItemInfo = WorkItems
                               .Where(model => model.IsSelected)
                               .Select(model => new WorkItemCheckinInfo(model.WorkItem, model.WorkItemCheckinAction.ToWorkItemCheckinAction()))
                               .ToArray();

            var checkinNoteFieldValues =
                CheckinNotes
                .Where(model => !string.IsNullOrWhiteSpace(model.Value))
                .Select(model => new CheckinNoteFieldValue(model.CheckinNoteFieldDefinition.Name, model.Value))
                .ToArray();

            var checkinNote = new CheckinNote(checkinNoteFieldValues);

            string policyOverrideComment = null;

            if (EvaluatePoliciesAndCheckinNotes)
            {
                CheckinEvaluationResult checkinEvaluationResult;
                if (teamPilgrimServiceModelProvider.TryEvaluateCheckin(out checkinEvaluationResult, _workspaceServiceModel.Workspace, pendingChanges, Comment, checkinNote, workItemInfo))
                {
                    if (!checkinEvaluationResult.IsValid())
                    {
                        OnShowPendingChangesItem(ShowPendingChangesTabItemEnum.PolicyWarnings);

                        var policyFailureModel  = new PolicyFailureModel();
                        var policyFailureDialog = new PolicyFailureDialog()
                        {
                            DataContext = policyFailureModel
                        };

                        var dialogResult = policyFailureDialog.ShowDialog();
                        if (!dialogResult.HasValue || !dialogResult.Value || !policyFailureModel.Override)
                        {
                            CheckinEvaluationResult = checkinEvaluationResult;
                            return;
                        }

                        policyOverrideComment = policyFailureModel.Reason;
                    }
                }
                else
                {
                    return;
                }
            }

            var versionControlServer = _projectCollectionServiceModel.TfsTeamProjectCollection.GetVersionControlServer();
            var shelveset            = new Shelveset(versionControlServer, ShelvesetName, _projectCollectionServiceModel.TfsTeamProjectCollection.AuthorizedIdentity.UniqueName)
            {
                Comment               = Comment,
                ChangesExcluded       = PendingChanges.Count() != pendingChanges.Count(),
                WorkItemInfo          = workItemInfo,
                CheckinNote           = checkinNote,
                PolicyOverrideComment = policyOverrideComment
            };

            PendingSet[] pendingSets;
            if (teamPilgrimServiceModelProvider.TryWorkspaceQueryShelvedChanges(_workspaceServiceModel.Workspace, out pendingSets, ShelvesetName,
                                                                                _projectCollectionServiceModel.TfsTeamProjectCollection.AuthorizedIdentity.UniqueName, null))
            {
                bool overwrite = false;
                if (pendingSets != null && pendingSets.Any())
                {
                    if (MessageBox.Show(string.Format("Replace shelveset\r\n\r\nThe shelveset {0} already exists. Replace?", ShelvesetName),
                                        "Team Pilgrim", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                    {
                        overwrite = true;
                    }
                    else
                    {
                        return;
                    }
                }

                var shelvingOptions = ShelvingOptions.None;

                if (!PreservePendingChangesLocally)
                {
                    shelvingOptions |= ShelvingOptions.Move;
                }

                if (overwrite)
                {
                    shelvingOptions |= ShelvingOptions.Replace;
                }

                if (teamPilgrimServiceModelProvider.TryShelve(_workspaceServiceModel.Workspace, shelveset, pendingChanges, shelvingOptions))
                {
                }
            }

            OnDismiss(true);
        }
コード例 #6
0
        private void RefreshPendingChanges()
        {
            this.Logger().Trace("RefreshPendingChanges");

            PendingChange[] currentPendingChanges;

            var filterItems = SolutionIsOpen && FilterSolution;

            string[] solutionFilePaths = null;

            if (filterItems)
            {
                try
                {
                    solutionFilePaths = teamPilgrimVsService.GetSolutionFilePaths();
                }
                catch (Exception)
                {
                    filterItems = false;
                }
            }

            if (filterItems
                ? teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, _workspaceServiceModel.Workspace, solutionFilePaths)
                : teamPilgrimServiceModelProvider.TryGetPendingChanges(out currentPendingChanges, _workspaceServiceModel.Workspace))
            {
                var intersections = PendingChanges
                                    .Join(currentPendingChanges, model => model.Change.ItemId, change => change.ItemId, (model, change) => new { model, change })
                                    .ToArray();

                var intersectedModels =
                    intersections
                    .Select(arg => arg.model)
                    .ToArray();

                var modelsToRemove = PendingChanges.Where(model => !intersectedModels.Contains(model)).ToArray();

                var modelsToAdd = currentPendingChanges
                                  .Where(pendingChange => !intersectedModels.Select(model => model.Change.ItemId).Contains(pendingChange.ItemId))
                                  .Select(change => new PendingChangeModel(change)).ToArray();

                _backgroundFunctionPreventDataUpdate = true;

                foreach (var intersection in intersections)
                {
                    intersection.model.Change = intersection.change;
                }

                foreach (var modelToAdd in modelsToAdd)
                {
                    PendingChanges.Add(modelToAdd);
                }

                foreach (var modelToRemove in modelsToRemove)
                {
                    PendingChanges.Remove(modelToRemove);
                }

                _backgroundFunctionPreventDataUpdate = false;

                PopulateSelectedPendingChangesSummary();
                EvaluateCheckInCommand.Execute(null);
            }
        }