Esempio n. 1
0
        public static void QueryLinkTypesCallback(object sender, EventArgs e)
        {
            //IntPtr hier;
            //uint itemid;
            //IVsMultiItemSelect dummy;
            //string canonicalName;
            bool bcanceled;
            int icanceled;
            string OperationCaption = "Change Work Items Link Types";
            IVsThreadedWaitDialog2 dlg = null;

            var lkdlg = new EditLinkTypeDialog(Utilities.wistore);
            var dlgResult = lkdlg.ShowDialog();
            if (dlgResult != DialogResult.OK) return;

            var origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                dlg = Utilities.CreateThreadedWaitDialog(OperationCaption, "Parsing query...", "status", 100);
                dlg.UpdateProgress(OperationCaption, "Parsing query...", "status", 1, 100, true, out bcanceled);

                var WIQueriesPageExt = Utilities.teamExplorer.CurrentPage.GetService<IWorkItemQueriesExt>();
                var qItem = WIQueriesPageExt.SelectedQueryItems.First();

                int[] qdata;
                int changedlinks = 0;
                bcanceled = ExecuteQueryLinkTypes(qItem as QueryDefinition, qItem.Project.Name, out qdata);
                dlg.UpdateProgress(OperationCaption, "Changing Link Types...", "status", 1, 100, false, out bcanceled);

                if (!bcanceled) changedlinks = ChangeLinkTypes(qdata, lkdlg.fromlink, lkdlg.tolink);

                dlg.EndWaitDialog(out icanceled);

                if (!bcanceled) MessageBox.Show(changedlinks + " links were changed.", Utilities.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dlg.EndWaitDialog(out icanceled);
                Cursor.Current = origCursor;
            }
            catch (Exception ex)
            {
                if(dlg != null) dlg.EndWaitDialog(out icanceled);
                Cursor.Current = origCursor;
                Utilities.OutputCommandString(ex.ToString());
                MessageBox.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message, Utilities.AppTitle, MessageBoxButtons.OK);
            }
        }
Esempio n. 2
0
        public static void QueryLinkTypesCallback(object sender, EventArgs e)
        {
            //IntPtr hier;
            //uint itemid;
            //IVsMultiItemSelect dummy;
            //string canonicalName;
            bool   bcanceled;
            int    icanceled;
            string OperationCaption    = "Change Work Items Link Types";
            IVsThreadedWaitDialog2 dlg = null;

            var lkdlg     = new EditLinkTypeDialog(Utilities.wistore);
            var dlgResult = lkdlg.ShowDialog();

            if (dlgResult != DialogResult.OK)
            {
                return;
            }

            var origCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                dlg = Utilities.CreateThreadedWaitDialog(OperationCaption, "Parsing query...", "status", 100);
                dlg.UpdateProgress(OperationCaption, "Parsing query...", "status", 1, 100, true, out bcanceled);

                var WIQueriesPageExt = Utilities.teamExplorer.CurrentPage.GetService <IWorkItemQueriesExt>();
                var qItem            = WIQueriesPageExt.SelectedQueryItems.First();

                int[] qdata;
                int   changedlinks = 0;
                bcanceled = ExecuteQueryLinkTypes(qItem as QueryDefinition, qItem.Project.Name, out qdata);
                dlg.UpdateProgress(OperationCaption, "Changing Link Types...", "status", 1, 100, false, out bcanceled);

                if (!bcanceled)
                {
                    changedlinks = ChangeLinkTypes(qdata, lkdlg.fromlink, lkdlg.tolink);
                }

                dlg.EndWaitDialog(out icanceled);

                if (!bcanceled)
                {
                    MessageBox.Show(changedlinks + " links were changed.", Utilities.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                dlg.EndWaitDialog(out icanceled);
                Cursor.Current = origCursor;
            }
            catch (Exception ex)
            {
                if (dlg != null)
                {
                    dlg.EndWaitDialog(out icanceled);
                }
                Cursor.Current = origCursor;
                Utilities.OutputCommandString(ex.ToString());
                MessageBox.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message, Utilities.AppTitle, MessageBoxButtons.OK);
            }
        }