Пример #1
0
        protected static void DoPostReview(FormSubmit form)
        {
            int reviewId = form.GetSelectedReviewId();
            List<string> changes = form.GetCheckedFullPaths();

            BackgroundWorker backgroundPostReview = new BackgroundWorker();
            backgroundPostReview.WorkerReportsProgress = true;
            backgroundPostReview.WorkerSupportsCancellation = true;
            backgroundPostReview.DoWork += (s, e) =>
            {
                string server = form.textBoxServer.Text;
                string username = form.textBoxUsername.Text;
                string password = form.textBoxPassword.Text;

                string submitAs = null;
                bool publish = false;
                PostReview.PostReviewOpen open = PostReview.PostReviewOpen.Internal;
                bool debug = false;

                e.Result = PostReview.Submit(backgroundPostReview, server, username, password, submitAs, reviewId, changes, publish, open, debug);

                if (backgroundPostReview.CancellationPending)
                {
                    e.Cancel = true;
                }
            };

            string label = String.Format("Uploading Code Review #{0} ({1} files)...", reviewId, changes.Count);

            FormProgress progress = new FormProgress("Uploading...", label, backgroundPostReview);

            progress.FormClosed += (s, e) =>
            {
                bool close = true;

                PostReview.PostReviewException pre = (PostReview.PostReviewException)progress.Error;
                if (pre != null)
                {
                    StringBuilder message = new StringBuilder();
                    message.AppendLine(pre.ToString());
                    message.AppendLine();
                    message.AppendLine("Click \"Retry\" to return to dialog, or \"Cancel\" to return to Visual Studio.");

                    if (MessageBox.Show(form, message.ToString(), "ERROR", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        close = false;
                    }
                }

                if (close)
                {
                    form.Review = progress.Result as PostReview.ReviewInfo;
                    form.DialogResult = DialogResult.OK;
                    form.Close();
                }
            };

            progress.ShowDialog(form);
        }
Пример #2
0
        private void ReviewBoardCommand(object caller, EventArgs args)
        {
            // TODO:(pv) Preselect most of the changed files according to the items selected in the Solution Explorer.
            // See below "GetCurrentSelection()" code.
            // I am holding off doing this because it is a little complicated trying to figure out what the user intended to submit.
            // Does selecting a folder mean to also submit all files in that folder?
            // What if a few files/subfolders of that folder are also selected?
            // Should none of the other items be selected?
            // For now, just check *all* visible solution items for changes...

            IVsOutputWindowPane owp = GetOutputWindowPaneGeneral();
            if (owp != null)
            {
                owp.Activate();
            }

            if (!solutionTracker.BackgroundInitialSolutionCrawl.IsBusy)
            {
                // The initial solution crawl is finished.
                // Just show the submit form as usual...
                ShowFormSubmit();
            }
            else
            {
                // The initial solution crawl is still in progress.
                // Display a cancelable modal dialog until the solution crawl is finished.

                string message = "Waiting for initial solution crawl to complete...";

                FormProgress progress = new FormProgress(message, message, solutionTracker.BackgroundInitialSolutionCrawl);
                DialogResult result = progress.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ShowFormSubmit();
                }
            }
        }