Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var progress = new Progress();

            progress.FormClosed += progress_FormClosed;

            try
            {
                if (ConfigurationManager.AppSettings["TFSUri"] == null)
                {
                    System.Windows.Forms.MessageBox.Show("TFS Uri not set in config file");
                    System.Windows.Forms.Application.Exit();
                }

                int autoRefreshInterval = 300000;
                if (ConfigurationManager.AppSettings["AutoRefreshInterval"] != null)
                {
                    int.TryParse(ConfigurationManager.AppSettings["AutoRefreshInterval"], out autoRefreshInterval);
                }

                timer1.Interval = autoRefreshInterval;

                string tfsUriStr = ConfigurationManager.AppSettings["TFSUri"].ToString();
                if (!Uri.IsWellFormedUriString(tfsUriStr, UriKind.Absolute))
                {
                    System.Windows.Forms.MessageBox.Show("TFS Uri in config file is not valid");
                    System.Windows.Forms.Application.Exit();
                }

                tfs = new Tfs(new Uri(tfsUriStr));
                TableHelper._tfs   = tfs;
                TableHelper._table = _table;
                var picker = new IterationPicker(tfs);
                if (picker.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && picker.SelectedIterations != null)
                {
                    progress.Show(this);

                    System.Windows.Forms.Application.DoEvents();

                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    this.Cursor = Cursors.WaitCursor;
                    List <IterationSelection> selections = picker.SelectedIterations;
                    TableHelper.LoadSuccesors = picker.LoadSuccesors;

                    SetIterationsGrid(selections);

                    TableHelper.SetTable(selections, _table, tfs);
                    this.Cursor = Cursors.Default;
                    sw.Stop();
                    var secs = sw.Elapsed.TotalSeconds;
                    System.Diagnostics.Debug.WriteLine(secs);
                }
                else
                {
                    System.Windows.Forms.Application.Exit();
                }

                picker.Dispose();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Could not connect : " + ex.Message + System.Environment.NewLine + ex.StackTrace);
                System.Windows.Forms.Application.Exit();
            }
            finally
            {
                progress.FormClosed -= progress_FormClosed;
                progress.Close();
            }
        }