private Boolean ConnectToServer(Boolean isFirstTime) { try { this.ShowConnectingMessage("验证登录中……"); //如果连不上?重新获取服务器连接 passiveEngine.SystemToken = SystemToken.Manage + "#" + this.skinTextBoxBusinessAccount.Text + "#" + skinLabelVersion.Text; //if (!GlobalUtil.IPAndPort(new IPEndPoint(IPAddress.Parse(config.BusinessAccount.ServerIP), config.BusinessAccount.ServerPort))) //{ // GlobalMessageBox.Show("连接不到服务地址,请联系客服!"); // return false; //} // CommonGlobalUtil.WriteLog(this.skinTextBoxUser.Text + "," + skinTextBoxPwd.Text + "," + config.BusinessAccount.ServerIP + "," + config.BusinessAccount.ServerPort); String pwdMd5 = SecurityHelper.MD5String2(this.skinTextBoxPwd.Text); LogonResponse result = this.passiveEngine.Initialize(this.skinTextBoxUser.Text.ToLower(), pwdMd5, config.BusinessAccount.ServerIP, config.BusinessAccount.ServerPort, new CustomizeHandler()); switch (result.LogonResult) { case LogonResult.Succeed: LoginInfo info = new LoginInfo(); info.LastLoginID = this.skinTextBoxUser.Text.ToLower(); info.SavePassword = this.skinCheckBoxSavePwd.Checked; if (info.SavePassword) { info.Password = this.skinTextBoxPwd.Text; } else { info.Password = null; } info.loginTime = DateTime.Now; LoginInfo orgInfo = config.LoginInfos.Find(t => t.LastLoginID.ToLower() == info.LastLoginID.ToLower()); if (orgInfo != null) { config.LoginInfos.Remove(orgInfo); } config.LoginInfos.Insert(0, info); config.Save(CONFIG_PATH); CommonGlobalCache.SetBusinessAccount(config.BusinessAccount); this.UpdateDialogResult(); if (!String.IsNullOrEmpty(result.FailureCause)) { ShowDialogMessage(result.FailureCause); CommonGlobalCache.SystemUpdateMessage = result.FailureCause; } break; case LogonResult.Failed: this.ShowConnectingMessage(result.FailureCause, true); break; case LogonResult.HadLoggedOn: this.ShowConnectingMessage("该帐号已经在其它地方登录!", true); break; case LogonResult.VersionMismatched: this.ShowConnectingMessage("客户端与服务器的CJFramework版本不一致!", true); break; default: break; } } catch (SocketException ex) { if (!isFirstTime) { GlobalUtil.WriteLog(ex + "!isFirstTime1 ERROR Message=" + ex.Message + "Exception StackTrace=" + ex.StackTrace); this.ShowConnectingMessage("连接不到服务端,请联系客服!", true); } else { GlobalUtil.WriteLog(ex + "1ERROR Message=" + ex.Message + "Exception StackTrace=" + ex.StackTrace); return(false); } } catch (Exception ex) { if (!isFirstTime) { this.ShowConnectingMessage("系统异常" + ex.Message, true); GlobalUtil.WriteLog(ex + "!isFirstTime2 ERROR Message=" + ex.Message + "Exception StackTrace=" + ex.StackTrace); } else { GlobalUtil.WriteLog(ex + "2ERROR Message=" + ex.Message + "Exception StackTrace=" + ex.StackTrace); return(false); } } return(true); }