Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the OK button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void BtnOKSettings_Click(object sender, EventArgs e)
        {
            Settings.Default.EmailRecipient = this.txtBoxEmailRecipient.Text;

            // save the url to TFS and try to reconnect to it
            var url = this.txtBoxTeamServerUrl.Text;

            Settings.Default.TeamServerUrl = url;

            Uri uriResult;

            if (!string.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)
            {
                try
                {
                    TfsConnect.Initialize(url);
                }
                catch (Exception)
                {
                    TfsConnect.isInitialized = false;
                }
            }
            else
            {
                TfsConnect.isInitialized = false;
            }

            Settings.Default.CloseShelvesetWindowOnSelection = this.closeShelvesetWindowsCheckBox.Checked;

            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when [shelvesets button].
        /// </summary>
        /// <param name="control">The control.</param>
        public void OnShelvesetsButton(Office.IRibbonControl control)
        {
            this.pointY = 0;
            List <ShelvesetWrapper> orderedShelvesets;

            if (TfsConnect.isInitialized)
            {
                orderedShelvesets = TfsConnect.GetOrderedShelvesets(TfsConnect.CurrentUser);
            }
            else
            {
                try
                {
                    TfsConnect.Initialize(Settings.Default.TeamServerUrl);
                    orderedShelvesets = TfsConnect.GetOrderedShelvesets(TfsConnect.CurrentUser);
                }
                catch (Exception ex)
                {
                    TfsConnect.isInitialized = false;
                    MessageBox.Show("Please make sure that the Team Server Url is defined properly in the settings. Exception was " + ex.Message, "ermahgerd ferleure");
                    new SettingsBox().ShowDialog();
                    return;
                }
            }

            // we should only have one instance of the form
            if (this.form != null && !this.form.IsDisposed)
            {
                if (this.form.WindowState == FormWindowState.Minimized)
                {
                    this.form.WindowState = FormWindowState.Normal;
                }
                this.form.Focus();
                this.form.BringToFront();
                return;
            }

            this.form = new Form1
            {
                Text = "Shelvesets for " + TfsConnect.CurrentUser,
                lblShelvesetCount = { Text = orderedShelvesets.Count + " shelvesets" },
            };
            this.form.lblShelvesetCount.Font = new Font(this.form.lblShelvesetCount.Font, FontStyle.Bold);

            var buttons = new List <Button>();

            for (var i = 0; i < orderedShelvesets.Count; i++)
            {
                Console.WriteLine(i + 1 + " " + orderedShelvesets[i].Name);
                buttons.Add(this.createButton(orderedShelvesets[i]));
                this.pointY += ButtonHeight;
            }

            foreach (var b in buttons)
            {
                this.form.panelShelvesets.Controls.Add(b);
            }

            this.form.Show();
        }
Exemplo n.º 3
0
        /// <summary>The index.</summary>
        /// <param name="user">The user.</param>
        /// <returns>The default view.</returns>
        public ActionResult Index(string user)
        {
            TfsConnect.Initialize(ConfigurationManager.AppSettings.Get("teamProjectUrl"), true);

            string selectedUser = user ?? User.Identity.Name;

            MainViewModel model = new MainViewModel();

            model.UsersChoice = from IdentityWrapper id in TfsConnect.Users
                                select new SelectListItem()
            {
                Text     = id.DisplayName,
                Value    = id.UniqueName,
                Selected = selectedUser.ToLower() == id.UniqueName.ToLower()
            };
            model.Shelvesets = from sh in TfsConnect.GetOrderedShelvesets(selectedUser)
                               select new ShelvesetModel
            {
                Name        = sh.Name,
                DateCreated = sh.CreationDate,
                OwnerName   = sh.OwnerName
            };

            return(this.View(model));
        }
Exemplo n.º 4
0
 public ActionResult Index(MainViewModel model)
 {
     model.UsersChoice = from IdentityWrapper id in TfsConnect.Users
                         select new SelectListItem()
     {
         Text     = id.DisplayName,
         Value    = id.UniqueName,
         Selected = model.SelectedUser == id.DisplayName
     };
     model.Shelvesets = from sh in TfsConnect.GetOrderedShelvesets(model.SelectedUser)
                        select new ShelvesetModel
     {
         Name        = sh.Name,
         DateCreated = sh.CreationDate,
         OwnerName   = sh.OwnerName
     };
     return(this.View(model));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Startup event of the ThisAddIn control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // initialize the connection to TFS.
            var url = Settings.Default.TeamServerUrl;
            Uri uriResult;

            if (!string.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)
            {
                try
                {
                    TfsConnect.Initialize(url);
                }
                catch (Exception)
                {
                    TfsConnect.isInitialized = false;
                }
            }
            else
            {
                TfsConnect.isInitialized = false;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// The application main.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            // initialize the connection to TFS.
            TfsConnect.Initialize(ConfigurationManager.AppSettings.Get("teamProjectUrl"));

            // set up the menu.
            int shelvesetToShow;

            int.TryParse(ConfigurationManager.AppSettings.Get("shelvesetToShow"), out shelvesetToShow);
            var menu = new Dictionary <string, string>();

            if (shelvesetToShow > 0)
            {
                Console.WriteLine(LocalizableResource.introText + Environment.NewLine);
                var orderedShelvesets = TfsConnect.GetOrderedShelvesets(TfsConnect.CurrentUser);
                for (var i = 0; i < System.Math.Min(shelvesetToShow, orderedShelvesets.Count); i++)
                {
                    Console.WriteLine(i + 1 + " " + orderedShelvesets[i].Name);
                    menu.Add((i + 1).ToString(), orderedShelvesets[i].Name);
                }
            }

            // get user input and creates the code review report
            while (true)
            {
                Console.Write(Environment.NewLine + string.Format("Shelveset ({0}-{1}): ", 1, menu.Count));
                var userInput = Console.ReadLine();

                if (userInput == "exit" || userInput == "kill")
                {
                    Environment.Exit(0);
                }

                if (!string.IsNullOrEmpty(userInput))
                {
                    userInput = userInput.Replace("\"", string.Empty);
                }

                if (string.IsNullOrEmpty(userInput))
                {
                    continue;
                }

                string shelvesetName, shelvesetOwnerName;
                if (userInput.Contains("\\"))
                {
                    var values = userInput.Split('\\');
                    shelvesetOwnerName = values[0];
                    shelvesetName      = values[1];
                }
                else if (menu.ContainsKey(userInput))
                {
                    // get the shelveset name and the owner name.
                    menu.TryGetValue(userInput, out shelvesetName);
                    shelvesetOwnerName = TfsConnect.CurrentUser;
                }
                else
                {
                    shelvesetName      = userInput;
                    shelvesetOwnerName = TfsConnect.CurrentUser;
                }

                ShelvesetReport shelvesetReport = new ShelvesetReport(shelvesetName, shelvesetOwnerName);
                if (shelvesetReport.Exception == null)
                {
                    // open in browser.
                    if (bool.Parse(ConfigurationManager.AppSettings.Get("openInBrowser")))
                    {
                        // save as file.
                        string pathName = shelvesetReport.SaveHtmlFile(shelvesetName, ConfigurationManager.AppSettings.Get("outputFolder"), true);
                        Console.WriteLine(string.Format(LocalizableResource.doneSavingFile, pathName));
                    }

                    // open in email.
                    if (bool.Parse(ConfigurationManager.AppSettings.Get("openAsEmail")))
                    {
                        Console.WriteLine(LocalizableResource.doneCreatingEmail);
                        shelvesetReport.PrepareEmail(ConfigurationManager.AppSettings["mailTo"]);
                    }
                }
                else
                {
                    Console.WriteLine(shelvesetReport.Exception.Message);
                }
            }
        }