Beispiel #1
0
        /// <summary>
        /// Updates the policy warnings.
        /// </summary>
        /// <remarks>Documented by CFI, 2011-01-08</remarks>
        private void UpdatePolicyWarnings()
        {
            List <object>        items   = new List <object>();
            List <PendingChange> changes = GetSelectedChanges();

            if (pendingChanges.Count > 0 && changes.Count > 0)
            {
                CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Policies,
                                                                                          PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, GetCurrentCheckinNotes(), GetSelectedWorkItems());
                if (result.PolicyEvaluationException != null || result.PolicyFailures.Length > 0)
                {
                    labelPolicyWarning.Text   = "The following check-in policies have not been satisfied";
                    pictureBoxWarning.Visible = true;

                    foreach (PolicyFailure failure in result.PolicyFailures)
                    {
                        if (failure.Message.Contains("CheckForComments.cs"))
                        {
                            if (string.IsNullOrEmpty(textBoxComment.Text))
                            {
                                items.Add("Please provide some comments about your check-in.");
                            }
                        }
                        else
                        {
                            items.Add(failure);
                        }
                    }
                    if (result.PolicyEvaluationException != null)
                    {
                        items.Add(result.PolicyEvaluationException);
                    }

                    objectListViewPolicyWarnings.SetObjects(items);
                }
                else
                {
                    labelPolicyWarning.Text   = "All check-in policies are satisfied";
                    pictureBoxWarning.Visible = false;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the conflicts.
        /// </summary>
        /// <remarks>Documented by CFI, 2011-01-08</remarks>
        private void UpdateConflicts()
        {
            objectListViewConflicts.SetObjects(null);

            if (PendingChanges.Count <= 0 || GetSelectedChanges().Count <= 0)
            {
                return;
            }

            CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Conflicts, PendingChanges.ToArray(),
                                                                                      GetSelectedChanges().ToArray(), textBoxComment.Text, GetCurrentCheckinNotes(), GetSelectedWorkItems());

            if (result.Conflicts.Length == 0)
            {
                labelConflicts.Text = "No Conflicts found";
            }
            else
            {
                labelConflicts.Text = result.Conflicts.Length < 2 ? "1 Conflict found" : result.Conflicts.Length + " Conflicts found";
                objectListViewConflicts.SetObjects(result.Conflicts);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Checks the in.
        /// </summary>
        /// <remarks>Documented by CFI, 2010-06-27</remarks>
        public void CheckIn()
        {
            foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
            {
                if (document.IsModified)
                {
                    document.Save();
                }
            }

            List <PendingChange> changes = GetSelectedChanges();

            if (pendingChanges.Count <= 0 || changes.Count <= 0)
            {
                MessageBox.Show("Nothing to Check In!", "Nothing to Check In", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            CheckinNote note = GetCurrentCheckinNotes();

            WorkItemCheckinInfo[] workItemsArray = GetSelectedWorkItems();

            PolicyOverrideInfo policyInfo = null;

            CheckinEvaluationResult result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Conflicts, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);

            if (result.Conflicts.Length > 0)
            {
                MessageBox.Show("Checkin cannot proceed because there are some conflicts.", "Conflict Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ShowConfilcts();

                return;
            }

            result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Notes, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);
            if (result.NoteFailures.Length > 0)
            {
                MessageBox.Show("Checkin cannot proceed because there are errors in the Check-in Notes.", "Check-in Notes Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ShowCheckInNotes();

                return;
            }

            result = Manager.CurrentWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Policies, PendingChanges.ToArray(), changes.ToArray(), textBoxComment.Text, note, workItemsArray);
            if (result.PolicyEvaluationException != null || result.PolicyFailures.Length > 0)
            {
                string errors = string.Empty;
                foreach (PolicyFailure failure in result.PolicyFailures)
                {
                    if (failure.Message.Contains("CheckForComments.cs"))
                    {
                        if (string.IsNullOrEmpty(textBoxComment.Text))
                        {
                            errors += Environment.NewLine + " - " + "Please provide comments for your check-in.";
                        }
                    }
                    else
                    {
                        errors += Environment.NewLine + " - " + failure.Message;
                    }
                }
                if (result.PolicyEvaluationException != null)
                {
                    errors += Environment.NewLine + " - " + result.PolicyEvaluationException.Message;
                }

                if (errors != string.Empty)
                {
                    DialogResult boxResult = MessageBox.Show("Checkin cannot proceed because the policy requirements have not been satisfied." + Environment.NewLine + errors, "Policy Failure", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                    if (boxResult == DialogResult.Abort)
                    {
                        ShowPolicyWarnings();
                        return;
                    }
                    else if (boxResult == DialogResult.Retry)
                    {
                        CheckIn();
                        return;
                    }
                }
            }

            Manager.CurrentWorkspace.CheckIn(changes.ToArray(), textBoxComment.Text, note, workItemsArray, policyInfo);
            CheckedInChanges = changes;

            textBoxComment.Text             = string.Empty;
            textBoxCodeReviewer.Text        = string.Empty;
            textBoxSecurityReviewer.Text    = string.Empty;
            textBoxPerformanceReviewer.Text = string.Empty;

            foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
            {
                if (changes.FirstOrDefault(c => c.LocalItem == document.FileName) != null)
                {
                    document.Reload(false);
                }
            }

            UpdatePendingChanges();

            OnCheckedIn(EventArgs.Empty);
        }