Ejemplo n.º 1
0
        static public bool MOGGlobalRepositoryLogin(MogMainForm main, bool forceRestart)
        {
SelectValidRepository:

            MogForm_RepositoryBrowser_Client browser = new MogForm_RepositoryBrowser_Client(forceRestart);
            DialogResult rc = DialogResult.Cancel;

            if (!MOG_Main.IsShutdown())
            {
                rc = browser.ShowDialog();
            }

            if (rc == DialogResult.OK)
            {
                if (forceRestart)
                {
                    main.Close();
                }
                return(true);
            }
            else if (rc == DialogResult.Retry)
            {
                goto SelectValidRepository;
            }

            return(false);
        }
Ejemplo n.º 2
0
        static public void MOGGlobalLaunchProjectLogin(string projectName, bool forceLogin)
        {
            // Launch the login dialog
            LoginForm login = new LoginForm(projectName);

            mainForm.Enabled = false;

Login:
            // Show the dialog
            if (login.ShowDialog(mainForm) == DialogResult.OK)
            {
                try
                {
                    // Login to the specified Project
                    if (guiProject.SetLoginProject(login.LoginProjectsComboBox.Text, login.LoginBranchesComboBox.Text))
                    {
                        // Set the login user
                        guiUser guiUsers = new guiUser(mainForm);
                        if ((string.Compare(login.LoginUsersComboBox.Text, "Choose Valid User", true) == 0) || (login.LoginUsersComboBox.Text.Length == 0))
                        {
                            MessageBox.Show("A valid user must be selected!", "Missing User");
                            goto Login;
                        }

                        if (guiUsers.SetLoginUser(login.LoginUsersComboBox.Text))
                        {
                            mainForm.Enabled = true;

                            // Disable the Change SQL Server menu item if the logged in user is not an administrator
                            MOGGlobalSetSQLConnectionMenuItemEnabled(login.LoginUsersComboBox.Text);
                            // Disable the Configure Project menu item if the logged in user is not an administrator
                            MOGGlobalSetToolsConfigureProjectMenuItemEnabled(login.LoginUsersComboBox.Text);
                            // Disable the Set MOG Repository menu item if the logged in user is not an administrator
                            MOGGlobalSetFileMOGRepositoryMenuItemEnabled(login.LoginUsersComboBox.Text);
                        }
                        else
                        {
                            MessageBox.Show("A valid user must be selected!", "Login Error");
                            goto Login;
                        }
                    }
                    else
                    {
                        MessageBox.Show("A valid project and branch must be selected!", "Login Error");
                        goto Login;
                    }
                }
                catch (Exception e)
                {
                    MOG_Report.ReportMessage("Login Project", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                    goto Login;
                }
            }
            else if (login.DialogResult == DialogResult.Cancel && forceLogin)
            {
                if (MessageBox.Show(mainForm, "Do you wish to exit MOG?", "Exit?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    mainForm.Close();
                    mainForm.Shutdown();
                }
                else
                {
                    goto Login;
                }
            }
            else
            {
                if (!MOG_ControllerProject.IsProject() || !MOG_ControllerProject.IsUser())
                {
                    MessageBox.Show("A valid project and user must be selected!", "Missing Project or User");
                    goto Login;
                }

                mainForm.Enabled = true;
            }

            // Always initialize our Database before leaving because the dialog loads projects that will leave us in a dirty state
            MOG_ControllerSystem.InitializeDatabase("", MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName());
        }