예제 #1
0
        private void btnAddUsers_Click(object sender, EventArgs e)
        {
            string temp = btnAddUsers.Text;

            btnAddUsers.Text    = "Adding users. This might take a minute...";
            btnAddUsers.Enabled = false;

            string strUrl   = txtCollectionURL.Text.Trim();
            string filePath = txtMappingFilePath.Text.Trim();

            if (string.IsNullOrEmpty(strUrl) || string.IsNullOrEmpty(filePath))
            {
                MessageBox.Show("Please specify TFS collection URL and the User to Groups Mapping file.");
                return;
            }

            try
            {
                List <User2GroupsMap> user2grpMap =
                    FileHelper.ReadUser2GroupsMapFromFile(filePath, fileType, FileContentType.UsersToGroupsMapping);
                if (permissionMgr != null)
                {
                    ReturnCode returnVal = permissionMgr.AddUsersToGroups(user2grpMap);
                    switch (returnVal)
                    {
                    case ReturnCode.Success:
                        toolStripStatusLabel1.Text = "Successfully added users to the groups!";
                        break;

                    case ReturnCode.PartialSuccess:
                        toolStripStatusLabel1.Text = "Partial success. Some users were added, but some errors were also encountered. Please refer the log file.";
                        break;

                    case ReturnCode.Failure:
                        toolStripStatusLabel1.Text = "Error! There were issues adding users to the groups. Please refer the log file.";
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Could not connect to TFS Server. Please ensure the collection URL is valid.");
                    toolStripStatusLabel1.Text = "Error!";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                toolStripStatusLabel1.Text = "Error!";
            }
            btnAddUsers.Text    = temp;
            btnAddUsers.Enabled = true;
        }