예제 #1
0
        LoginResultInfo DoLoginScreen(string initialUser, string initialPassword, string initialServer)
        {
            Utils.Log.Debug("Login screen showing...");
            LoginResultInfo ret = new LoginResultInfo();

            LoginForm f = new LoginForm();

            f.Password = initialPassword;
            f.UserName = initialUser;
            f.Server   = initialServer;


            if (f.ShowDialog() == DialogResult.Cancel)
            {
                ret.UserChoice = DialogResult.Cancel;
            }
            else
            {
                ret.UserChoice = DialogResult.OK;
                ret.User       = f.UserName;
                ret.Password   = f.Password;
                ret.Server     = f.Server;
            }
            Utils.Log.Debug("Logon screen done.");
            return(ret);
        }
예제 #2
0
        private void loginWithPrompt(bool forceNewCreds)
        {
            Utils.Log.DebugFormat("Logging in to FogBugz (with prompt: {0}", forceNewCreds);
            try
            {
                SetState(new StateLoggingIn(this));
                if (forceNewCreds || _password.Length == 0 || _username.Length == 0 || _server.Length == 0 || _server == ConfigurationManager.AppSettings["ExampleServerURL"])
                {
                    if (string.IsNullOrEmpty(_server))
                    {
                        string url = ConfigurationManager.AppSettings["FogBugzBaseURL"] ?? "";
                        _server = (url.Length > 0) ? url : ConfigurationManager.AppSettings["ExampleServerURL"];
                    }

                    LoginResultInfo info = DoLoginScreen(_username, _password, _server);
                    if (info.UserChoice != DialogResult.Cancel)
                    {
                        _username = info.User;
                        _password = info.Password;
                        _server   = info.Server;
                    }
                }

                Utils.Log.DebugFormat("Server is at {0}", _server);

                _fb = new FogBugz(_server);

                LoginAsync(_username, _password, delegate(bool succeeded)
                {
                    if (succeeded)
                    {
                        saveSettings();
                        updateCases();
                    }
                    else
                    {
                        _password = "";
                        SetState(new StateLoggedOff(this));
                        MessageBox.Show("Login failed", "FogBugz", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                });
            }
            catch (Exception x)
            {
                SetState(new StateLoggedOff(this));
                throw x;
            }
        }
예제 #3
0
        LoginResultInfo DoLoginScreen(string initialUser, string initialPassword, string initialServer)
        {
            Utils.Log.Debug("Login screen showing...");
            LoginResultInfo ret = new LoginResultInfo();

            LoginForm f = new LoginForm();
            f.Password = initialPassword;
            f.UserName = initialUser;
            f.Server = initialServer;

            if (f.ShowDialog() == DialogResult.Cancel)
                ret.UserChoice = DialogResult.Cancel;
            else
            {
                ret.UserChoice = DialogResult.OK;
                ret.User = f.UserName;
                ret.Password = f.Password;
                ret.Server = f.Server;

            }
            Utils.Log.Debug("Logon screen done.");
            return ret;
        }