public bool TryCheckin(Workspace workspace, PendingChange[] changes, string comment, CheckinNote checkinNote = null, WorkItemCheckinInfo[] workItemChanges = null, PolicyOverrideInfo policyOverride = null) { try { _teamPilgrimTfsService.WorkspaceCheckin(workspace, changes, comment, checkinNote, workItemChanges, policyOverride); return true; } catch (Exception ex) { this.Logger().DebugException(ex); LastException = ex; } return false; }
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); }
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 = _workspaceServiceModel.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 modelToAdd in modelsToAdd) { CheckinNotes.Add(modelToAdd); } 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, _workspaceServiceModel.Workspace, pendingChanges, Comment, checkinNote, workItemChanges)) { CheckinEvaluationResult = checkinEvaluationResult; this.Logger().Debug("EvaluateCheckIn: Valid:{0}", checkinEvaluationResult.IsValid()); } }
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); } } }
public bool TryEvaluateCheckin(out CheckinEvaluationResult checkinEvaluationResult, Workspace workspace, PendingChange[] changes, string comment, CheckinNote checkinNote = null, WorkItemCheckinInfo[] workItemChanges = null) { try { checkinEvaluationResult = _teamPilgrimTfsService.EvaluateCheckin(workspace, changes, comment, checkinNote, workItemChanges); return true; } catch (Exception ex) { this.Logger().DebugException(ex); LastException = ex; } checkinEvaluationResult = null; return false; }
public CheckinEvaluationResult EvaluateCheckin(Workspace workspace, PendingChange[] changes, string comment, CheckinNote checkinNote, WorkItemCheckinInfo[] workItemChanges) { this.Logger().Trace("EvaluateCheckin"); return workspace.EvaluateCheckin(CheckinEvaluationOptions.All, changes, changes, comment, checkinNote, workItemChanges); }
public void WorkspaceCheckin(Workspace workspace, PendingChange[] changes, string comment, CheckinNote checkinNote, WorkItemCheckinInfo[] workItemChanges, PolicyOverrideInfo policyOverride) { this.Logger().Trace("WorkspaceCheckin"); workspace.CheckIn(changes, comment, checkinNote, workItemChanges, policyOverride); }