private void btnLoginSave_Click(object sender, EventArgs e) { bool isUserValid = false; int user_id = 0; string userName = ToolBoxWrite.TextBoxRead(tbLoginUserName); string userPassword = ToolBoxWrite.TextBoxRead(tbLoginPassword); if (serverProtocol.AuthenticateUser(userName, userPassword)) { isUserValid = true; } else { LoginAttemptsCount++; ToolBoxWrite.TextBoxWrite(tbLoginUserName, string.Empty); ToolBoxWrite.TextBoxWrite(tbLoginPassword, string.Empty); if (LoginAttemptsCount == GlobalVar.MATS_SERVER_LOGIN_ATTEMPTS) { MessageBox.Show("Invalid Login Attempts For " + GlobalVar.MATS_SERVER_LOGIN_ATTEMPTS.ToString() + "Times. Please Restart The Program."); this.Close(); } else { MessageBox.Show("Login Details are Incorrect.", "!Warning"); } return; } if (isUserValid) { this.Visible = false; GlobalVar.USER_NAME = tbLoginUserName.Text; ToolBox.ToolBoxWrite.IS_FORM_LOADED = false; FrmMechBench frm = new FrmMechBench(serverProtocol); DialogResult dr = frm.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.Abort) { this.Close(); } else if (GlobalVar.isUserLogOut) { LoginAttemptsCount = 0; GlobalVar.isUserLogOut = false; this.Visible = true; ToolBoxWrite.TextBoxWrite(tbLoginUserName, string.Empty); ToolBoxWrite.TextBoxWrite(tbLoginPassword, string.Empty); } else { this.Close(); } } }
public bool GetBenchDetails() { serial.AsyncRead(BenchReceivedData, false); serial.Write(configEnd + transmitTerminator); string data = serial.ReadLine(4); serial.Write(configStart + transmitTerminator); data = serial.ReadLine(4); if (data == null || !data.Contains("Started")) { return(false); } serial.Write(configIdentify + transmitTerminator); //while (!data.Contains("prod.ch2:")) { data = serial.ReadLine(4); if (data == null) { serial.Write(configEnd + transmitTerminator); return(false); } data = data.Replace("\n", string.Empty); Console.WriteLine("Received Client Data: " + data); string[] instrumentMsg = data.Split(';'); for (int i = 0; i < instrumentMsg.Length; i++) { if (instrumentMsg[i].Length > 2) { string[] instrumentMsgfields = instrumentMsg[i].Split(' '); switch (instrumentMsgfields[0]) { case "prod.name:": ToolBoxWrite.TextBoxWrite(mainForm.tbBenchName, instrumentMsgfields[1]); // frm.tbBenchName.Text = instrumentMsgfields[1]; bench.setBenchName(instrumentMsgfields[1]); break; case "prod.swver:": break; case "prod.hwver:": break; case "prod.type:": bench.setType(instrumentMsgfields[1]); break; case "prod.class:": bench.setClass(instrumentMsgfields[1]); break; case "prod.num:": instrumentMsgfields[1] = instrumentMsgfields[1].Replace("\0\n", ""); bench.setNum(instrumentMsgfields[1]); break; case "prod.interface:": bench.setInterface(instrumentMsgfields[1]); break; case "prod.channelcount:": bench.setChCount(instrumentMsgfields[1]); break; case "prod.ch1:": ToolBoxWrite.ComboBoxWrite(mainForm.cbChannel1, instrumentMsgfields[1]); bench.setChan1(instrumentMsgfields[1]); break; case "prod.ch2:": ToolBoxWrite.ComboBoxWrite(mainForm.cbChannel2, instrumentMsgfields[1]); bench.setChan2(instrumentMsgfields[1]); break; case "prod.ch3:": ToolBoxWrite.ComboBoxWrite(mainForm.cbChannel3, instrumentMsgfields[1]); bench.setChan3(instrumentMsgfields[1]); break; //case "prod.ch4:": // ToolBoxWrite.ComboBoxWrite(mainForm.cbChannel4, instrumentMsgfields[1]); // bench.setChan4(instrumentMsgfields[1]); // break; } // switch (instrumentMsgfields[0]) if(sentCommand[0] == "identify\r") } } } serial.Write(configEnd + transmitTerminator); data = serial.ReadLine(4); if (!data.Contains("Ended")) { return(false); } return(true); }