예제 #1
0
        public void Login()
        {
            try
            {
                string ls_name = textUser.EditValue.ToString().Trim();
                string ls_pass = textPass.EditValue.ToString();
                string ls_type = this.CE_AuthorType.EditValue.ToString();

                #region 取数据接口
                IAuthorize _authService = LoginConfig.GetAuthorizeInterface();
                if (_authService == null)
                {
                    throw new Exception("未找到服务器端登录服务!");
                }

                #endregion
                SinoUser _su = _authService.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_type);
                if (_su != null)
                {
                    SessionClass.CurrentLogonName = ls_name;
                    SessionClass.CurrentLogonPass = ls_pass;
                    SessionClass.CurrentSinoUser  = _su;
                    SessionClass.CurrentTicket    = new SinoSZTicketInfo(_su.LoginName, _su.IPAddress, _su.EncryptedTicket);
                    SessionClass.ServerConfigData = _authService.GetServerConfig();
                    DataRow[] _drs = _UserDs.User.Select(string.Format("Username='******'", ls_name));
                    if (_drs.Length == 0)
                    {
                        DataRow row = _UserDs.User.NewRow();
                        row["Username"] = ls_name;
                        _UserDs.User.Rows.Add(row);
                        _UserDs.WriteXml(_schemaFile, XmlWriteMode.IgnoreSchema);
                    }

                    _su.DwID = _su.CurrentPost.PostDwID;

                    loginTimes = 0;
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(LoginSuccess);
                    synchronizer.Invoke(invoker, null);
                }
                else
                {
                    XtraMessageBox.Show("用户名/口令不正确或过期!", "系统提示");
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(ResetForm);
                    synchronizer.Invoke(invoker, null);
                }


                loginTimes++;

                if (loginTimes > 2)
                {
                    System.ComponentModel.ISynchronizeInvoke synchronizer = this;
                    MethodInvoker invoker = new MethodInvoker(CancelApplicaton);
                    synchronizer.Invoke(invoker, null);
                }
            }
            catch (Exception e)
            {
                ShowMessageDelegate showProgress = new ShowMessageDelegate(ShowMessage);
                string _msg = string.Format("发生错误:{0}", e.Message);
                this.Invoke(showProgress, new object[] { _msg });
            }
        }