Example #1
0
        public void Login()
        {
            SinoUser _su;

            try
            {
                string ls_name      = textUser.EditValue.ToString().Trim();
                string ls_pass      = textPass.EditValue.ToString();
                string ls_checktype = ConvertToCheckType(cb_CheckType.EditValue.ToString());

                if (ls_checktype == "windows")
                {
                    string cdn = GetDomainName();

                    if (cdn == "")
                    {
#if DEBUG
                        ls_name = "lijianlin";
#else
                        throw new Exception("未登录到域,不可进行域认证!");
#endif
                    }

                    ls_pass = StrUtils.EncodeByDESC(ls_name, "DOMAINCK");
                }

                // 取数据接口
                using (AuthorizeService.AuthorizeServiceClient _client = new AuthorizeService.AuthorizeServiceClient())
                {
                    _su = _client.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_checktype);
                }

                if (_su != null)
                {
                    SessionClass.CurrentLogonName     = ls_name;
                    SessionClass.CurrentLogonPass     = ls_pass;
                    SessionClass.CurrentSinoUser      = _su;
                    SessionClass.CurrentCheckType     = ls_checktype;
                    SessionClass.CurrentTicket        = new SinoSZTicketInfo(_su.UserID, _su.IPAddress, _su.EncryptedTicket);
                    SinoBestTicketCache.CurrentTicket = _su.EncryptedTicket;

                    using (CommonService.CommonServiceClient _cs = new CommonService.CommonServiceClient())
                    {
                        SessionClass.ServerConfigData = _cs.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 });
            }
        }
Example #2
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 });
            }
        }