Exemplo n.º 1
0
        public virtual ILoginUser RemoteLogin(string username, string password)
        {
            ILoginUser loginUser = null;

            IUserConfig user = SystemContext.UserConfigManager.GetConfig(username);

            if (user != null && user.Password.Equals(password))
            {
                lock (mLoginUserTable.SyncRoot)
                {
                    foreach (ILoginUser curuser in mLoginUserTable.Values)
                    {
                        if (curuser != null && curuser.Name.Equals(username))
                        {
                            if (!user.MultiLogin)
                            {
                                return(null);
                            }
                            break;
                        }
                    }

                    loginUser = new CLoginUser(user);
                    mLoginUserTable.Add(loginUser.LoginKey, loginUser);
                }
                user.RefreshACL();
            }

            return(loginUser);
        }
Exemplo n.º 2
0
        public override bool Login(string username, string password, bool isQuiet)
        {
            if (!IsLogin)
            {
                IUserConfig user = SystemContext.UserConfigManager.GetConfig(username);
                if (user != null && user.Password.Equals(password))
                {
                    LoginUser = new CLoginUser(user);
                    State     = MonitorSystemState.Login;

                    user.RefreshACL();
                }
                else
                {
                    if (!isQuiet)
                    {
                        MessageBox.Show("系统登录失败,可能是不存在此用户或密码不正确! ", "本地系统登录失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            return(IsLogin);
        }
Exemplo n.º 3
0
        private void DoReceiveData(IMonitorSystemContext context, IProcessor processor, string data)
        {
            if (CheckOrigin(context, processor))
            {
                string kk = Config.Name + "<RemoteSystem>";

                if (data.StartsWith(kk))
                {
                    data = data.Remove(0, kk.Length);
                    if (data.StartsWith("<State>"))
                    {
                        int m, n = data.IndexOf("</State>");
                        if (n > 0)
                        {
                            string state = data.Substring(7, n - 7);
                            if (state.Equals("Login"))
                            {
                                m = data.IndexOf("<UserName>");
                                n = data.IndexOf("</UserName>");
                                string username = data.Substring(m + 10, n - m - 10);

                                m = data.IndexOf("<LoginKey>");
                                n = data.IndexOf("</LoginKey>");
                                string loginkey = data.Substring(m + 10, n - m - 10);

                                if (SystemContext.SystemInitFromXml(data.Substring(n + 11, data.Length - n - 11), true))
                                {
                                    IUserConfig user = SystemContext.UserConfigManager.GetConfig(username);
                                    if (user != null)
                                    {
                                        LoginUser = new CLoginUser(user, loginkey);

                                        State = MonitorSystemState.Login;
                                    }
                                }
                            }
                            else if (state.Equals("LoginFailed"))
                            {
                                MessageBox.Show("远程系统“" + mConfig.Desc + "”登录失败,可能是不存在此用户或密码不正确! ", "远程系统登录失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (state.Equals("MultiLogin"))
                            {
                                n = data.IndexOf("<UserName>");
                                m = data.IndexOf("</UserName>");
                                string username = data.Substring(n + 10, m - n - 10);

                                MessageBox.Show(username + " 已经登录,此用户不能重复登录! ", "远程系统登录失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (state.Equals("Logout"))
                            {
                                n = data.IndexOf("<UserName>");
                                m = data.IndexOf("</UserName>");

                                string username = data.Substring(n + 10, m - n - 10);

                                if (LoginUser != null && LoginUser.Name.Equals(username))
                                {
                                    LoginUser = null;
                                }

                                if (LoginUser == null)
                                {
                                    State = MonitorSystemState.Logout;
                                }
                            }
                            else if (state.Equals("Refresh"))
                            {
                                if (IsLogin)
                                {
                                    SystemContext.SystemInitFromXml(data.Substring(n + 8, data.Length - n - 8), true);
                                    RefreshState();
                                }
                            }
                        }
                    }
                }
            }
        }