private bool OpenSocketClient() { try { if (client != null) { if (!client.Connected) { client.Close(); client = null; } } if (client == null) { client = new TcpClient(); client.Connect(SocketServerIp, SocketServerPort); client.ReceiveTimeout = receiveTimeout; client.ReceiveBufferSize = 255; } } catch (Exception e) { UtilMessage.ShowError(e); return(false); } return(true); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { if (e != null && e.Exception != null) { UtilMessage.ShowError(e.Exception); UtilLog.Error(e.Exception); } }
private void BtnInstall_Click(object sender, EventArgs e) { try { Install(); } catch (Exception ex) { UtilMessage.ShowError(ex); } }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { if (e != null && e.ExceptionObject != null) { Exception exception = e.ExceptionObject as Exception; if (exception != null) { UtilMessage.ShowError(exception); UtilLog.Error(exception); } } }
private void SendCommand(string commandString) { byte[] bytes; // -------------------------------------------- try { OpenSocketClient(); bytes = Encoding.Default.GetBytes(commandString); client.GetStream().Write(bytes, 0, bytes.Length); new Thread(DataListiner).Start(); } catch (Exception e) { UtilMessage.ShowError(e); } }
private void btnLogin_Click(object sender, EventArgs e) { try { using (TesterRecipe_Service.TesterRecipe_Service ts_rmsService = new TesterRecipe_Service.TesterRecipe_Service()) { string strDepartment = ""; UtilLog.Info("Verify user login :"******"Verify user login Result:" + sVerfiyResult); if (sVerfiyResult.Substring(0, 4) == "True") { if (sVerfiyResult.Length != 8) { strDepartment = sVerfiyResult.Substring(4, 5); } else { strDepartment = "NONE*"; } #region Set User Info Data UtilCommonInfo.UserName = txtUserName.Text.Trim(); UtilCommonInfo.Password = txtPassword.Text.Trim(); UtilCommonInfo.Dept = strDepartment; #endregion this.DialogResult = DialogResult.OK; } else if (sVerfiyResult.Substring(0, 4) == "miss") { string sMsg = "UserID or PassWord missmatch!用户名或密码不正确!"; UtilMessage.ShowError(sMsg); this.DialogResult = DialogResult.None; //return; } } } catch (Exception ex) { string sMsg = "Remote Host Not Responding!!远端服务器没有响应!"; UtilMessage.ShowWarn(sMsg); UtilLog.Error("LogIn Handle Send Message to Host Error :", ex); } }
private bool CloseSocketClient() { try { if (client != null) { if (client.Connected) { client.Close(); } client = null; } return(true); } catch (Exception e) { UtilMessage.ShowError(e); return(false); } }
private void btnConfrim_Click(object sender, EventArgs e) { if (comb_Resetreason.Text.Trim() == "") { UtilMessage.ShowError("请选择reset lot 原因!!!"); this.DialogResult = DialogResult.None; } else { using (Tester_Service.TestSummary_Service service = new Tester_Service.TestSummary_Service()) { gv_lot.Hold_Reason = comb_Resetreason.SelectedValue.ToString().Trim(); service.RecordResetLot(UtilCommonMethod.SerializeObject(gv_lot), UtilCommonMethod.SerializeObject(gv_machine)); } this.DialogResult = DialogResult.OK; } }