void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Tuple <bool, bool> E = e.Result as Tuple <bool, bool>; bool dataFlag = E.Item1; bool fileFlag = E.Item2; if (dataFlag && fileFlag) { FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试成功!", this.panelTop.BackColor); this.Close(); } else { if (dataFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试成功,\r\n文件通讯服务连接测试失败!", this.panelTop.BackColor); } else if (fileFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试失败,\r\n文件通讯服务连接测试成功!", this.panelTop.BackColor); } else { FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试失败!", this.panelTop.BackColor); } } }
private void panelLogin_Click(object sender, EventArgs e) { pictureBox4.Image = Properties.Resources.top2; if (this.enableFlag) { this.errorProvider.Clear(); if (string.IsNullOrEmpty(this.tbUser.Caption.Trim()) || this.tbUser.Caption.Trim() == "用户名") { Utility.Common.Validator.SetError(this.errorProvider, this.tbUser, "用户名不能为空!"); return; } if (string.IsNullOrEmpty(this.tbPwd.Caption.Trim()) || this.tbPwd.Caption.Trim() == "密码") { Utility.Common.Validator.SetError(this.errorProvider, this.tbPwd, "密码不能为空!"); return; } //FormLoading.StartLoading(this, new Size(110, 120)); this.enableFlag = false; this.userName = this.tbUser.Caption.Trim(); this.pwd = this.tbPwd.Caption.Trim(); this.uiHandler += new UiHandler(this.LoginResult); //登录验证 ThreadPool.QueueUserWorkItem(new WaitCallback(this._Login)); } else { FormMessgeBox.ShowMsg(this, "数据库连接异常!", this.panelTop.BackColor); } }
private void ShowTestResult(bool flag) { FormLoading.EndLoading(); if (flag) { string _connString = Secret.Encrypt3DES(connString, LocalVariable.Key); if (ConfigManager.SaveConnString(ConfigConst.ConnectionManageString, _connString, ConfigConst.ConfigPath) && ConfigManager.SaveConnString(ConfigConst.ConnectionStringWrite, _connString, ConfigConst.ConfigPath) && ConfigManager.SaveConnString(ConfigConst.ConnectionStringReadonly, _connString, ConfigConst.ConfigPath) && ConfigManager.SaveConnString(ConfigConst.ConStrManageSql, _connString, ConfigConst.ConfigPath)) { LocalVariable.SetConnStringValue(ConfigConst.ConnectionManageString, connString); LocalVariable.SetConnStringValue(ConfigConst.ConnectionStringWrite, connString); LocalVariable.SetConnStringValue(ConfigConst.ConnectionStringReadonly, connString); LocalVariable.SetConnStringValue(ConfigConst.ConStrManageSql, connString); FormMessgeBox.ShowMsg(this, "测试成功,并保存!", this.panelTop.BackColor); this.myLock = true; this.Close(); } else { FormMessgeBox.ShowMsg(this, "测试成功,但保存失败!", this.panelTop.BackColor); } } else { FormMessgeBox.ShowMsg(this, "测试失败!", this.panelTop.BackColor); } this.myLock = true; }
private void LoginResult(object obj) { this.uiHandler -= new UiHandler(this.LoginResult); string errMsg = obj.ToString(); if (!string.IsNullOrEmpty(errMsg)) { FormLoading.EndLoading(); FormMessgeBox.ShowMsg(this, errMsg, this.panelTop.BackColor); this.enableFlag = true; return; } if (GlobalStaticObj.gLoginDataSet == null || GlobalStaticObj.gLoginDataSet.Tables.Count == 0 || GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1) { this.enableFlag = true; FormLoading.EndLoading(); FormMessgeBox.ShowMsg(this, "用户名或密码错误!", this.panelTop.BackColor); return; } if (HXCServerWinForm.GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1) { this.enableFlag = true; FormMessgeBox.ShowMsg(this, "数据加载失败!", this.panelTop.BackColor); FormLoading.EndLoading(); return; } #region 设置全局变量 GlobalStaticObj_Server.Instance.UserID = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_id"].ToString(); GlobalStaticObj_Server.Instance.UserName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_name"].ToString(); GlobalStaticObj_Server.Instance.LoginName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["land_name"].ToString(); GlobalStaticObj_Server.Instance.PassWord = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["password"].ToString(); GlobalStaticObj_Server.Instance.RoleID = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["role_id"].ToString(); GlobalStaticObj_Server.Instance.RoleName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["role_name"].ToString(); GlobalStaticObj_Server.Instance.OrgID = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_id"].ToString(); GlobalStaticObj_Server.Instance.OrgName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_name"].ToString(); GlobalStaticObj_Server.Instance.ComID = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_id"].ToString(); GlobalStaticObj_Server.Instance.ComName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_name"].ToString(); GlobalStaticObj_Server.Instance.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); #endregion //预加载信息 //LocalCache.PreLoad(); //登录记忆保存 this.SaveMemery(); FormLoading.EndLoading(); this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态 }
private void timer_Tick(object sender, EventArgs e) { if (!this.enableFlag) { FormLoading.EndLoading(); if (!InetetTest(GlobalStaticObj.DataServerIp, 200)) { FormMessgeBox.ShowMsg(this, "无法连接服务器!", this.panelTop.BackColor); } else { FormMessgeBox.ShowMsg(this, "服务器登录超时!", this.panelTop.BackColor); } this.enableFlag = true; } this.timer.Enabled = false; }
private void panelYes_Click(object sender, EventArgs e) { if (!myLock) { return; } this.myLock = false; this.errorProvider.Clear(); if (string.IsNullOrEmpty(this.tbDBIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbDBIp, "服务器Ip不能为空!"); return; } if (!InetetTest(this.tbDBIp.Caption.Trim(), 100)) { FormMessgeBox.ShowMsg(this, "IP无法连接!", this.panelTop.BackColor); this.myLock = true; return; } if (string.IsNullOrEmpty(this.tbDBUser.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbDBUser, "用户名不能为空!"); return; } if (string.IsNullOrEmpty(this.tbDBPwd.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbDBPwd, "密码不能为空!"); return; } this.arrays[1] = this.tbDBIp.Caption.Trim(); this.arrays[5] = this.tbDBUser.Caption.Trim(); this.arrays[7] = this.tbDBPwd.Caption.Trim(); connString = ConfigHelper.PackageConnString(this.arrays); FormLoading.StartLoading(this); ThreadPool.QueueUserWorkItem(new WaitCallback(this._DbTest), connString); }
private void ShowAccData(object obj) { this.uiHandler -= new UiHandler(this.ShowAccData); if (obj.ToString().Length > 0) { FormLoading.EndLoading(); if (this.formSet == null || !this.formSet.Visible) { FormMessgeBox.ShowMsg(this, "无法加载帐套数据!", this.panelTop.BackColor); } } this.enableFlag = true; //加载帐套 if (this.dtDb.Rows.Count > 0) { this.tbDb.Caption = this.dtDb.Rows[0]["DisplayName"].ToString(); this.tbDb.Tag = this.dtDb.Rows[0]["Value"].ToString(); if (this.tbUser.Caption.Trim().Length == 0) { this.tbUser.Focus(); } else { if (this.tbPwd.Caption.Trim().Length == 0) { this.tbPwd.Focus(); } else { this.panelLogin.Focus(); } } } this.formCmb = new FormCmb(); this.formCmb.DisplayName = "DisplayName"; this.formCmb.ValueName = "Value"; this.formCmb.ItemHeight = 35; this.formCmb.BackColor = Color.White; this.formCmb.SelectedColor = Color.FromArgb(97, 167, 208); this.formCmb.ItemSelected += new FormCmb.ItemSelectedHandler(this.SeletecdAccount); this.formCmb.BindCmb(this.tbDb.InnerTextBox, this.dtDb, this.tbDb.Location.X, this.panelDb.Height - this.tbDb.Location.Y - this.tbDb.Height, false); }
private void panelYes_Click(object sender, EventArgs e) { this.errorProvider.Clear(); if (string.IsNullOrEmpty(this.tbServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerIp, "数据服务器Ip不能为空!"); return; } if (!InetetTest(this.tbServerIp.Caption.Trim(), 100)) { FormMessgeBox.ShowMsg(this, "数据服务器地址无法连接!", this.panelTop.BackColor); return; } if (string.IsNullOrEmpty(this.tbServerPort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerPort, "数据服务端口不能为空!"); return; } if (string.IsNullOrEmpty(this.tbFileServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFileServerIp, "文件服务器Ip不能为空!"); return; } if (!InetetTest(this.tbFileServerIp.Caption.Trim(), 100)) { FormMessgeBox.ShowMsg(this, "文件服务器地址无法连接!", this.panelTop.BackColor); return; } if (string.IsNullOrEmpty(this.tbFilePort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFilePort, "文件服务端口不能为空!"); return; } bool dataFlag = false; bool fileFlag = false; if (ConfigManager.SaveWcfConfig(ConfigConst.WcfData, this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim())) { ConfigurationManager.RefreshSection("system.serviceModel/behaviors"); ConfigurationManager.RefreshSection("system.serviceModel/bindings"); ConfigurationManager.RefreshSection("system.serviceModel/client"); ConfigurationManager.RefreshSection("system.serviceModel/services"); GlobalStaticObj.channelFactory = null; if (WCFClientProxy.TestDataProxy()) { dataFlag = true; GlobalStaticObj.DataServerIp = this.tbServerIp.Caption.Trim(); GlobalStaticObj.DataPort = int.Parse(this.tbServerPort.Caption.Trim()); } else { this.tbServerIp.Caption = GlobalStaticObj.DataServerIp; this.tbServerPort.Caption = GlobalStaticObj.DataPort.ToString(); ConfigManager.SaveWcfConfig(ConfigConst.WcfData, this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim()); } } if (ConfigManager.SaveWcfConfig(ConfigConst.WcfFile, this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim())) { ConfigurationManager.RefreshSection("system.serviceModel/behaviors"); ConfigurationManager.RefreshSection("system.serviceModel/bindings"); ConfigurationManager.RefreshSection("system.serviceModel/client"); ConfigurationManager.RefreshSection("system.serviceModel/services"); GlobalStaticObj.channelFactoryFile = null; if (WCFClientProxy.TestFileProxy()) { fileFlag = true; GlobalStaticObj.FileServerIp = this.tbFileServerIp.Caption.Trim(); GlobalStaticObj.FilePort = int.Parse(this.tbFilePort.Caption.Trim()); } else { this.tbFileServerIp.Caption = GlobalStaticObj.FileServerIp; this.tbFilePort.Caption = GlobalStaticObj.FilePort.ToString(); //恢复原来的连接 ConfigManager.SaveWcfConfig(ConfigConst.WcfFile, this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim()); } } if (dataFlag && fileFlag) { FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试成功!", this.panelTop.BackColor); this.Close(); } else { if (dataFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试成功,\r\n文件通讯服务连接测试失败!", this.panelTop.BackColor); //if (this.RefreshDataStart != null) //{ // this.RefreshDataStart(); //} } else if (fileFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试失败,\r\n文件通讯服务连接测试成功!", this.panelTop.BackColor); } else { FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试失败!", this.panelTop.BackColor); } } }
private void panelYes_Click(object sender, EventArgs e) { this.errorProvider.Clear(); if (string.IsNullOrEmpty(this.tbServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerIp, "数据服务器Ip不能为空!"); return; } if (string.IsNullOrEmpty(this.tbServerPort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerPort, "数据服务端口不能为空!"); return; } if (string.IsNullOrEmpty(this.tbFileServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFileServerIp, "文件服务器Ip不能为空!"); return; } if (string.IsNullOrEmpty(this.tbFilePort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFilePort, "文件服务端口不能为空!"); return; } bool dataFlag = false; bool fileFlag = false; if (ConfigManager.SaveWcfConfig(ConfigConst.WcfData, this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim())) { if (WCFClientProxy.TestDataProxy()) { dataFlag = true; GlobalStaticObj.DataServerIp = this.tbServerIp.Caption.Trim(); GlobalStaticObj.DataPort = int.Parse(this.tbServerPort.Caption.Trim()); } else { this.tbServerIp.Caption = GlobalStaticObj.DataServerIp; this.tbServerPort.Caption = GlobalStaticObj.DataPort.ToString(); ConfigManager.SaveWcfConfig(ConfigConst.WcfData, this.tbServerIp.Caption.Trim() + ":" + this.tbServerPort.Caption.Trim()); } } if (ConfigManager.SaveWcfConfig(ConfigConst.WcfFile, this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim())) { if (WCFClientProxy.TestFileProxy()) { fileFlag = true; GlobalStaticObj.FileServerIp = this.tbFileServerIp.Caption.Trim(); GlobalStaticObj.FilePort = int.Parse(this.tbFilePort.Caption.Trim()); } else { this.tbFileServerIp.Caption = GlobalStaticObj.FileServerIp; this.tbFilePort.Caption = GlobalStaticObj.FilePort.ToString(); //恢复原来的连接 ConfigManager.SaveWcfConfig(ConfigConst.WcfFile, this.tbFileServerIp.Caption.Trim() + ":" + this.tbFilePort.Caption.Trim()); } } if (dataFlag && fileFlag) { if (this.RefreshDataStart != null) { this.RefreshDataStart(); } FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试成功!", this.panelTop.BackColor); this.Close(); } else { if (dataFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试成功,文件通讯服务连接测试失败!", this.panelTop.BackColor); if (this.RefreshDataStart != null) { this.RefreshDataStart(); } } else if (fileFlag) { FormMessgeBox.ShowMsg(this, "数据通讯服务连接测试失败,文件通讯服务连接测试成功!", this.panelTop.BackColor); } else { FormMessgeBox.ShowMsg(this, "数据、文件通讯服务连接测试失败!", this.panelTop.BackColor); } } }
private void LoginResult(object obj) { this.uiHandler -= new UiHandler(this.LoginResult); if (this.enableFlag) { return; } this.timer.Enabled = false; string errMsg = obj.ToString(); if (!string.IsNullOrEmpty(errMsg)) { FormLoading.EndLoading(); FormMessgeBox.ShowMsg(this, errMsg, this.panelTop.BackColor); this.enableFlag = true; return; } if (HXCPcClient.GlobalStaticObj.gLoginDataSet == null) { FormMessgeBox.ShowMsg(this, "数据加载失败!", this.panelTop.BackColor); FormLoading.EndLoading(); this.enableFlag = true; return; } if (HXCPcClient.GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1) { FormLoading.EndLoading(); this.enableFlag = true; return; } try { #region 务站信息 add by kord var dr = DBHelper.GetTable("获取当前服务站信息", GlobalStaticObj.CommAccCode, "tb_company", "*", "data_source = '2'", "", ""); if (dr == null || dr.Rows.Count == 0) { GlobalStaticObj.GlobalLogService.WriteLog("无法获取当前服务站信息"); } else { GlobalStaticObj.ServerStationCode = CommonCtrl.IsNullToString(dr.Rows[0]["sap_code"]); GlobalStaticObj.ServerStationName = CommonCtrl.IsNullToString(dr.Rows[0]["com_name"]); } #endregion GlobalStaticObj.CookieStr = GlobalStaticObj.gLoginDataSet.Tables["cookieStr"].Rows[0][0].ToString(); GlobalStaticObj.UserID = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_id"].ToString(); GlobalStaticObj.UserName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_name"].ToString(); GlobalStaticObj.LandName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["land_name"].ToString(); GlobalStaticObj.PassWord = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["password"].ToString(); GlobalStaticObj.CurrUserCom_Id = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_id"].ToString(); GlobalStaticObj.CurrUserCom_Code = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_code"].ToString(); GlobalStaticObj.CurrUserCom_Name = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_name"].ToString(); GlobalStaticObj.CurrUserOrg_Id = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_id"].ToString(); GlobalStaticObj.CurrUserOrg_Name = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_name"].ToString(); GlobalStaticObj.CurrUserCom_Category = CommonCtrl.IsNullToString(HXCPcClient.GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["category"]); //modify by kord } catch (Exception ex) { //write log } ThreadPool.SetMinThreads(3, 3); ThreadPool.SetMaxThreads(5, 5); //预加载信息 LocalCache.PreLoad(); //记忆登录保存 this.SaveMemery(); FormLoading.EndLoading(); this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态 }
private void panelYes_Click(object sender, EventArgs e) { this.errorProvider.Clear(); if (string.IsNullOrEmpty(this.tbServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerIp, "数据服务器Ip不能为空!"); return; } if (string.IsNullOrEmpty(this.tbServerPort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbServerPort, "数据服务端口不能为空!"); return; } int dataPort = 0; if (!int.TryParse(tbServerPort.Caption.Trim(), out dataPort)) { FormMessgeBox.ShowMsg(this, "数据服务端口只能录入数字!", this.panelTop.BackColor); return; } if (!InetetTest(this.tbServerIp.Caption.Trim(), dataPort, 100)) { FormMessgeBox.ShowMsg(this, "数据服务器地址无法连接!", this.panelTop.BackColor); return; } if (string.IsNullOrEmpty(this.tbFileServerIp.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFileServerIp, "文件服务器Ip不能为空!"); return; } if (string.IsNullOrEmpty(this.tbFilePort.Caption.Trim())) { Utility.Common.Validator.SetError(this.errorProvider, this.tbFilePort, "文件服务端口不能为空!"); return; } int filePort = 0; if (!int.TryParse(tbFilePort.Caption.Trim(), out filePort)) { FormMessgeBox.ShowMsg(this, "文件服务端口只能录入数字!", this.panelTop.BackColor); return; } if (!InetetTest(this.tbFileServerIp.Caption.Trim(), filePort, 100)) { FormMessgeBox.ShowMsg(this, "文件服务器地址无法连接!", this.panelTop.BackColor); return; } BackgroundWorker Worker = new BackgroundWorker(); Worker.WorkerReportsProgress = false; Worker.WorkerSupportsCancellation = true; Worker.DoWork += Worker_DoWork; Worker.RunWorkerCompleted += Worker_RunWorkerCompleted; Worker.RunWorkerAsync(); }