示例#1
0
        private void ExecuteLogin()
        {
            ASMRestSettingsInstance.Instance.HostAndPort = _textHostAndPort.Text;
            ASMRestSettingsInstance.Instance.UserName    = _textUserName.Text;
            ASMRestSettingsInstance.Instance.Password    = _textPassword.Text;

            try
            {
                BaseRestHttpClient client = new BaseRestHttpClient(ASMRestSettingsInstance.Instance);
                client.Login();
                this.DialogResult = DialogResult.OK;
                this.Hide();

                if (_checkRemember.Checked)
                {
                    ASMLoginOptions options = new ASMLoginOptions();
                    options.Url      = _textHostAndPort.Text;
                    options.UserName = _textUserName.Text;
                    options.Password = Encryptor.EncryptToString(_textPassword.Text);
                    options.FullName = ASMRestSettingsInstance.Instance.FullName;
                    options.Save();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            ASMLoginOptions options = new ASMLoginOptions();

            if (!String.IsNullOrWhiteSpace(options.Password))
            {
                _textHostAndPort.Text = options.Url;
                _textUserName.Text    = options.UserName;
                ASMRestSettingsInstance.Instance.FullName = options.FullName;
                _textPassword.Text = Encryptor.DecryptToString(options.Password);
            }

            if (!String.IsNullOrWhiteSpace(_textUserName.Text))
            {
                ExecuteLogin();
            }
        }