示例#1
0
        static public bool Exec(bool closeMainForm)
        {
            if (closeMainForm)
            {
                MIS.MainForm.Close();
            }
            else
            {
                ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();
                if (loginAction == null)
                {
                    return(false);
                }

                try {
                    //MIS.WriteApplicationLog("系统", "退出系统");
                    //IMainMenuAction m = RemotingHelper.GetRemotingService<IMainMenuAction>();
                    //m.AddMenuClick(MIS.UserInfo, "Itop.Client.dll", "Itop.Client.Login.UserLogoutCommand", "Execute", -1);
                    loginAction.Out(MIS.Token, MIS.UserNumber);
                    MIS.Token = string.Empty;
                } catch (System.Net.Sockets.SocketException ex) {
                    MIS.WriteExceptionLog(ex.Message);
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        static private string GetUserName()
        {
            if (UserNumber == string.Empty)
            {
                return(string.Empty);
            }

            string       result      = string.Empty;
            ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();

            if (loginAction != null)
            {
                result = loginAction.GetUserName(UserInfo, UserNumber);
            }

            return(result);
        }
示例#3
0
        public CopySecretOnSecretSave(string hackerUser,
                                      string targetUser,
                                      string targetKey,
                                      ILoginAction loginAction,
                                      ICreateSecretAction createSecretAction,
                                      ISecretsList secretsList)
        {
            if (hackerUser == null)
            {
                throw new ArgumentNullException("hackerUser");
            }
            if (targetUser == null)
            {
                throw new ArgumentNullException("targetUser");
            }
            if (targetKey == null)
            {
                throw new ArgumentNullException("targetKey");
            }
            if (loginAction == null)
            {
                throw new ArgumentNullException("loginAction");
            }
            if (createSecretAction == null)
            {
                throw new ArgumentNullException("createSecretAction");
            }
            if (secretsList == null)
            {
                throw new ArgumentNullException("secretsList");
            }

            _hackerUser         = hackerUser;
            _targetUser         = targetUser;
            _targetKey          = targetKey;
            _loginAction        = loginAction;
            _createSecretAction = createSecretAction;
            _secretsList        = secretsList;
        }
示例#4
0
        /// <summary>
        /// 执行登录
        /// </summary>
        private void DoLogin()
        {
            if (utxtuser.tbox.Text == string.Empty)
            {
                MsgBox.Show("工号没有输入");
                utxtuser.Focus();
                return;
            }

            ILoginAction loginAction = RemotingHelper.GetRemotingService <ILoginAction>();

            if (loginAction == null)
            {
                MsgBox.Show("ILoginAction没有被正确注册");
                return;
            }

            string      token;
            string      userNumber = utxtuser.tbox.Text.Trim();
            string      password   = utxtpwd.tbox.Text;
            LoginData   data       = new LoginData(userNumber, password);
            LoginStatus status;

            try {
                loginAction.Login(data, out token, out status);
            } catch (System.Net.Sockets.SocketException) {
                MsgBox.Show("无法连接服务器,请稍候重试");
                utxtpwd.tbox.Focus();
                return;
            }
            switch (status)
            {
            case LoginStatus.OK:
                if (m_reLogin)
                {
                    // 原来的用户退出
                    if (!UserLogoutCommand.Exec(false))
                    {
                        MsgBox.Show("无法连接服务器,请稍候重试");
                        utxtpwd.tbox.Focus();
                        return;
                    }

                    //MIS.WriteApplicationLog("系统", "退出系统");
                }
                DialogResult   = DialogResult.OK;
                MIS.Token      = token;
                MIS.UserNumber = data.UserNumber;
                //MIS.WriteApplicationLog("系统", "登录系统");

                // 记录最近一次登录的用户的工号
                Itop.Client.Option.Settings.SetLastLoginUserNumber(userNumber);

                break;

            case LoginStatus.InvalidUser:
                MsgBox.Show("工号输入错误");
                utxtuser.tbox.Focus();
                break;

            case LoginStatus.InvalidPassword:
                if (m_error.ContainsKey(userNumber))
                {
                    // 错误加一
                    m_error[userNumber]++;
                }
                else
                {
                    // 第一次错误
                    m_error.Add(userNumber, 1);
                }

                if (m_error[userNumber] >= 3)
                {
                    if (!m_reLogin)
                    {
                        MsgBox.Show("密码输入错误次数超过三次,无法登录系统");
                        CloseServer();
                        Application.Exit();
                    }
                    else
                    {
                        MsgBox.Show("密码输入错误次数超过三次,请稍候重试");
                        DialogResult = DialogResult.Cancel;
                    }
                }
                else
                {
                    MsgBox.Show("密码输入错误,请重新输入密码");
                }
                utxtpwd.tbox.Text = "";
                utxtpwd.tbox.Focus();
                break;

            default:
                break;
            }
        }
示例#5
0
        public LoginController(ILoginAction loginAction)
        {
            //this._deviceLogAction = deviceLogAction;

            this._loginAction = loginAction;
        }