//open connection to database private bool OpenConnection(monitorUi userDisplay) { // userDisplay.AppendTextBox("Connecting....\r\n"); try { connection.Open(); // userDisplay.AppendTextBox("Connected!\r\n"); return(true); } catch (MySqlException ex) { //When handling errors, you can your application's response based //on the error number. //The two most common error numbers when connecting are as follows: //0: Cannot connect to server. //1045: Invalid user name and/or password. switch (ex.Number) { case 0: userDisplay.AppendTextBox("Cannot connect to server. Contact administrator"); break; case 1045: userDisplay.AppendTextBox("Invalid username/password, please try again"); break; } userDisplay.AppendTextBox(ex.Number + "\r\n"); return(false); } }
public static void Start( monitorUi userDisplay ) { FalconDataFormats source = new FalconDataFormats(); Reader memReader = new Reader(source); Process[] processes = Process.GetProcessesByName("Falcon BMS"); while (processes.Length < 1) { processes = Process.GetProcessesByName("Falcon BMS"); System.Threading.Thread.Sleep(3000); } if (processes.Length > 0) { System.Diagnostics.Process eqproc = processes[0]; int addrname = 0x4A2E848; while (true) { MemoryLoc Pmhp3 = new MemoryLoc(eqproc, addrname); // string nameData = Pmhp3.getString(100, false); var data1 = memReader.GetCurrentData(); int newX = System.Convert.ToInt32((data1.y / 1640) - 450); int newY = System.Convert.ToInt32((data1.x / 1640) - 1800); userDisplay.updateLocationX(newX); userDisplay.updateLocationY(newY); System.Threading.Thread.Sleep(250); } } while (true) { System.Threading.Thread.Sleep(3000); } }
public void saveUserToDatabase(double x, double y, double z, string name, monitorUi userDisplay) { string query = @"INSERT INTO flightunits ( x, y, z, name, active, source) VALUES ( " + x + ", " + y + ", " + z + ", '" + name + "', 1, 'Falcon4')"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public void updateUserInDatabase(double x, double y, double z, string name, monitorUi userDisplay) { string query = @"UPDATE flightunits SET x = " + x + ", y = " + y + ", z = " + z + " WHERE name = '" + name + "' AND active = 1"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public void deactivateUserInDatabase(monitorUi userDisplay) { string name = userDisplay.getCallsign(); string query = @"UPDATE flightunits SET active = 0 WHERE name = '" + name + "'"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection( userDisplay ) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public void deactivateUserInDatabase(monitorUi userDisplay) { string name = userDisplay.getCallsign(); string query = @"UPDATE flightunits SET active = 0 WHERE name = '" + name + "'"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public static void Start(monitorUi userDisplay) { while (true) { if (userDisplay.getActiveSound() != null) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = userDisplay.getActiveSound() + ".wav"; try { player.Play(); } catch { } System.Threading.Thread.Sleep(2000); } } }
public static void Start( monitorUi userDisplay ) { while (true) { if (userDisplay.getActiveSound() != null) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = userDisplay.getActiveSound() + ".wav"; try { player.Play(); } catch { } System.Threading.Thread.Sleep(2000); } } }
public string[] getBombData(monitorUi userDisplay) { string query = @"SELECT * FROM `playerunits` WHERE (`lasery` != 0 OR `laserx` != 0 OR `laserz` != 0) AND (`lasercode` = 91016 OR `lasercode` = 48377) AND active = 1"; //userDisplay.AppendTextBox(query + "\r\n"); string[] numbers = new string[5]; //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { string code = dr.GetString(7); string laserx = dr.GetString(8); string lasery = dr.GetString(9); string laserz = dr.GetString(10); string profile = dr.GetString(11);; numbers = new string[5] { code, laserx, lasery, laserz, profile }; } } //close Connection this.CloseConnection(); } return(numbers); }
public string[] getBombData(monitorUi userDisplay) { string query = @"SELECT * FROM `playerunits` WHERE (`lasery` != 0 OR `laserx` != 0 OR `laserz` != 0) AND (`lasercode` = 91016 OR `lasercode` = 48377) AND active = 1"; //userDisplay.AppendTextBox(query + "\r\n"); string[] numbers = new string[5]; //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { string code = dr.GetString(7); string laserx = dr.GetString(8); string lasery = dr.GetString(9); string laserz = dr.GetString(10); string profile = dr.GetString(11); ; numbers = new string[5] { code, laserx, lasery, laserz, profile }; } } //close Connection this.CloseConnection(); } return numbers; }
public static void Start( monitorUi userDisplay ) { FalconDataFormats source = new FalconDataFormats(); Boolean soundActive = userDisplay.getSoundActive(); string callSign = userDisplay.getCallsign(); Reader memReader = new Reader(source); Process[] processes = Process.GetProcessesByName("Falcon BMS"); int seconds = 0; int minutes = 0; int hours = 0; userDisplay.AppendTextBox("Searching for Falcon...\r\n"); while (processes.Length < 1) { processes = Process.GetProcessesByName("Falcon BMS"); System.Threading.Thread.Sleep(3000); } if (processes.Length > 0) { userDisplay.AppendTextBox("Falcon Found!\r\n"); System.Diagnostics.Process eqproc = processes[0]; int addrname = 0x4A2E848; DBConnect mySQLConnection = new DBConnect(); mySQLConnection.deactivateUserInDatabase( userDisplay ); mySQLConnection.saveUserToDatabase(0, 0, 0, callSign, userDisplay); while (true) { MemoryLoc Pmhp3 = new MemoryLoc(eqproc, addrname); // string nameData = Pmhp3.getString(100, false); string nameData = callSign; var data1 = memReader.GetCurrentData(); double mapratio = 30000 / ((85 * 1640) * 0.3048); double xoffset = 597 * 1640; double yoffset = 1402.5 * 1640; double xm = (((data1.y - xoffset) * 0.3048) * mapratio); double ym = (((data1.x - yoffset) * 0.3048) * mapratio); string[] laserData = mySQLConnection.getBombData(userDisplay); string profile = laserData[4]; double laserX = Convert.ToDouble(laserData[1]); double laserY = Convert.ToDouble(laserData[2]); double dX = xm - laserX; double dY = ym - laserY; double diff = Math.Sqrt(dX * dX + dY * dY); bool testDistance = diff < 3000; bool testDistance2 = diff < 1600; string[] laserCodes = userDisplay.getLaserCodes(); bool code1match = false; bool code2match = false; if (laserData[0] != null) { code1match = (laserData[0].ToString() == laserCodes[0]); code2match = (laserData[0].ToString() == laserCodes[1]); } if (soundActive == true && testDistance && (code1match || code2match)) { userDisplay.setActiveSound("intervalBeep"); userDisplay.setProfile( "" ); userDisplay.setLaserX(0); userDisplay.setLaserY(0); } if (soundActive == true && testDistance2 && (code1match || code2match)) { userDisplay.setLaserX(laserX); userDisplay.setLaserY(laserY); userDisplay.setProfile(profile); userDisplay.setActiveSound("solidTone"); } if (!testDistance2 && !testDistance) { userDisplay.setActiveSound( null ); userDisplay.setProfile( "" ); userDisplay.setLaserX( 0 ); userDisplay.setLaserY( 0 ); } double altitude = data1.z * -1; userDisplay.AppendTextBox("addUnit&position=[" + xm + "," + ym + "," + altitude + "]&name=" + nameData + "&active=true\r\n"); mySQLConnection.updateUserInDatabase(xm, ym, altitude, nameData, userDisplay); /* string url2 = @"http://infernusdealtis.com/terminal/update.php?page=addUnit&position=[" + xm + "," + ym + "," + data1.z + "]&name=" + nameData + "&active=true"; HttpWebRequest req3 = (HttpWebRequest)WebRequest.Create(url2); HttpWebResponse response3 = (HttpWebResponse)req3.GetResponse(); response3.Close(); */ System.Threading.Thread.Sleep(2000); seconds = seconds + 2; string secondsText = seconds.ToString(); if (seconds < 10) { secondsText = "0" + seconds; } if (seconds == 60) { seconds = 0; secondsText = "00"; minutes = minutes + 1; } if (minutes == 60) { hours = hours + 1; } string minutesText = minutes.ToString(); if (minutes < 10) { minutesText = "0" + minutes; } userDisplay.updateTimer(hours + " : " + minutesText + " : " + secondsText); } } while (true) { System.Threading.Thread.Sleep(3000); } }
public static void Start(monitorUi userDisplay) { FalconDataFormats source = new FalconDataFormats(); Boolean soundActive = userDisplay.getSoundActive(); string callSign = userDisplay.getCallsign(); Reader memReader = new Reader(source); Process[] processes = Process.GetProcessesByName("Falcon BMS"); while (processes.Length < 1) { processes = Process.GetProcessesByName("Falcon BMS"); System.Threading.Thread.Sleep(3000); } if (processes.Length > 0) { userDisplay.AppendTextBox("Starting Bomber!\r\n"); System.Diagnostics.Process eqproc = processes[0]; int addrbase = 0x4E985B1; int addrname = 0x4A2E848; string bombData = ""; string bombText = ""; DBConnect mySQLConnection = new DBConnect(); while (true) { if (bombData == "") { MemoryLoc Pmhp = new MemoryLoc(eqproc, addrbase); bombData = Pmhp.getString(6, false); bombText = Pmhp.getString(6, false); if (bombData.Contains("GB12")) { userDisplay.AppendTextBox(@"Start: " + bombData + "\r\n"); bombData = bombData.Replace(" GB12", ""); userDisplay.AppendTextBox(@"Bomb Count: " + bombData + "\r\n"); } } MemoryLoc Pmhp3 = new MemoryLoc(eqproc, addrname); // string nameData = Pmhp3.getString(100, false); string nameData = callSign; /* * int index = nameData.IndexOf(" at "); * * if (index > 0) * { * nameData = nameData.Substring(0, index); * } * else * { * nameData = "notAssigned"; * } */ MemoryLoc Pmhp2 = new MemoryLoc(eqproc, addrbase); string bombData2 = Pmhp2.getString(6, false); string bombText2 = Pmhp2.getString(6, false); if (bombData2.Contains("GB12")) { bombData2 = bombData2.Replace(" GB12", ""); } else { bombData2 = ""; } var data1 = memReader.GetCurrentData(); double mapratio = 30000 / ((85 * 1640) * 0.3048); double xoffset = 597 * 1640; double yoffset = 1402.5 * 1640; double xm = (((data1.y - xoffset) * 0.3048) * mapratio); double ym = (((data1.x - yoffset) * 0.3048) * mapratio); double altitude = (data1.z * 0.3048) * -1; if (bombData != bombData2 && bombData != "" && bombData2 != "" && bombData != "SMS") { string profile = userDisplay.getProfile(); double laserX = userDisplay.getLaserX(); double laserY = userDisplay.getLaserY(); mySQLConnection.saveBombToDatabase(laserX, laserY, 0, profile, altitude, userDisplay); userDisplay.AppendTextBox("addBomb&x=" + laserX + "&y=" + laserY + "&type=1&profile=" + profile + "&altitude=" + altitude + "\r\n"); /* * string url = @"http://infernusdealtis.com/terminal/ajax.php?page=addBomb&x=" + xm + "&y=" + ym + "&type=1"; * * HttpWebRequest req2 = (HttpWebRequest)WebRequest.Create(url); * HttpWebResponse response = (HttpWebResponse)req2.GetResponse(); * * response.Close(); */ bombData = bombData2; } System.Threading.Thread.Sleep(2000); } } while (true) { System.Threading.Thread.Sleep(3000); } }
//open connection to database private bool OpenConnection( monitorUi userDisplay ) { // userDisplay.AppendTextBox("Connecting....\r\n"); try { connection.Open(); // userDisplay.AppendTextBox("Connected!\r\n"); return true; } catch (MySqlException ex) { //When handling errors, you can your application's response based //on the error number. //The two most common error numbers when connecting are as follows: //0: Cannot connect to server. //1045: Invalid user name and/or password. switch (ex.Number) { case 0: userDisplay.AppendTextBox("Cannot connect to server. Contact administrator"); break; case 1045: userDisplay.AppendTextBox("Invalid username/password, please try again"); break; } userDisplay.AppendTextBox(ex.Number + "\r\n"); return false; } }
public void saveBombToDatabase(double x, double y, double z, string profile, double altitude, monitorUi userDisplay) { string query = @"INSERT INTO bombdrops ( x, y, z, fired, type, profile, originz) VALUES ( " + x + ", " + y + ", " + z + ", 1, 1, '" + profile + "', " + altitude + ")"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public void updateUserInDatabase(double x, double y, double z, string name, monitorUi userDisplay) { string query = @"UPDATE flightunits SET x = " + x + ", y = " + y + ", z = " + z + " WHERE name = '" + name + "' AND active = 1"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public void saveBombToDatabase(double x, double y, double z, string profile, double altitude, monitorUi userDisplay) { string query = @"INSERT INTO bombdrops ( x, y, z, fired, type, profile, originz) VALUES ( " + x + ", " + y + ", " + z + ", 1, 1, '" + profile + "', " + altitude + ")"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection(userDisplay) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }
public static void Start( monitorUi userDisplay ) { FalconDataFormats source = new FalconDataFormats(); Boolean soundActive = userDisplay.getSoundActive(); string callSign = userDisplay.getCallsign(); Reader memReader = new Reader(source); Process[] processes = Process.GetProcessesByName("Falcon BMS"); while (processes.Length < 1) { processes = Process.GetProcessesByName("Falcon BMS"); System.Threading.Thread.Sleep(3000); } if (processes.Length > 0) { userDisplay.AppendTextBox("Starting Bomber!\r\n"); System.Diagnostics.Process eqproc = processes[0]; int addrbase = 0x4E985B1; int addrname = 0x4A2E848; string bombData = ""; string bombText = ""; DBConnect mySQLConnection = new DBConnect(); while (true) { if (bombData == "") { MemoryLoc Pmhp = new MemoryLoc(eqproc, addrbase); bombData = Pmhp.getString(6, false); bombText = Pmhp.getString(6, false); if (bombData.Contains("GB12")) { userDisplay.AppendTextBox(@"Start: " + bombData + "\r\n"); bombData = bombData.Replace(" GB12", ""); userDisplay.AppendTextBox(@"Bomb Count: " + bombData + "\r\n"); } } MemoryLoc Pmhp3 = new MemoryLoc(eqproc, addrname); // string nameData = Pmhp3.getString(100, false); string nameData = callSign; /* int index = nameData.IndexOf(" at "); if (index > 0) { nameData = nameData.Substring(0, index); } else { nameData = "notAssigned"; } */ MemoryLoc Pmhp2 = new MemoryLoc(eqproc, addrbase); string bombData2 = Pmhp2.getString(6, false); string bombText2 = Pmhp2.getString(6, false); if (bombData2.Contains("GB12")) { bombData2 = bombData2.Replace(" GB12", ""); } else { bombData2 = ""; } var data1 = memReader.GetCurrentData(); double mapratio = 30000 / ((85 * 1640) * 0.3048); double xoffset = 597 * 1640; double yoffset = 1402.5 * 1640; double xm = (((data1.y - xoffset) * 0.3048) * mapratio); double ym = (((data1.x - yoffset) * 0.3048) * mapratio); double altitude = (data1.z * 0.3048) * -1; if (bombData != bombData2 && bombData != "" && bombData2 != "" && bombData != "SMS") { string profile = userDisplay.getProfile(); double laserX = userDisplay.getLaserX(); double laserY = userDisplay.getLaserY(); mySQLConnection.saveBombToDatabase(laserX, laserY, 0, profile, altitude, userDisplay); userDisplay.AppendTextBox("addBomb&x=" + laserX + "&y=" + laserY + "&type=1&profile=" + profile + "&altitude=" + altitude + "\r\n"); /* string url = @"http://infernusdealtis.com/terminal/ajax.php?page=addBomb&x=" + xm + "&y=" + ym + "&type=1"; HttpWebRequest req2 = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)req2.GetResponse(); response.Close(); */ bombData = bombData2; } System.Threading.Thread.Sleep(2000); } } while (true) { System.Threading.Thread.Sleep(3000); } }
public static void Start(monitorUi userDisplay) { FalconDataFormats source = new FalconDataFormats(); Boolean soundActive = userDisplay.getSoundActive(); string callSign = userDisplay.getCallsign(); Reader memReader = new Reader(source); Process[] processes = Process.GetProcessesByName("Falcon BMS"); int seconds = 0; int minutes = 0; int hours = 0; userDisplay.AppendTextBox("Searching for Falcon...\r\n"); while (processes.Length < 1) { processes = Process.GetProcessesByName("Falcon BMS"); System.Threading.Thread.Sleep(3000); } if (processes.Length > 0) { userDisplay.AppendTextBox("Falcon Found!\r\n"); System.Diagnostics.Process eqproc = processes[0]; int addrname = 0x4A2E848; DBConnect mySQLConnection = new DBConnect(); mySQLConnection.deactivateUserInDatabase(userDisplay); mySQLConnection.saveUserToDatabase(0, 0, 0, callSign, userDisplay); while (true) { MemoryLoc Pmhp3 = new MemoryLoc(eqproc, addrname); // string nameData = Pmhp3.getString(100, false); string nameData = callSign; var data1 = memReader.GetCurrentData(); double mapratio = 30000 / ((85 * 1640) * 0.3048); double xoffset = 597 * 1640; double yoffset = 1402.5 * 1640; double xm = (((data1.y - xoffset) * 0.3048) * mapratio); double ym = (((data1.x - yoffset) * 0.3048) * mapratio); string[] laserData = mySQLConnection.getBombData(userDisplay); string profile = laserData[4]; double laserX = Convert.ToDouble(laserData[1]); double laserY = Convert.ToDouble(laserData[2]); double dX = xm - laserX; double dY = ym - laserY; double diff = Math.Sqrt(dX * dX + dY * dY); bool testDistance = diff < 3000; bool testDistance2 = diff < 1600; string[] laserCodes = userDisplay.getLaserCodes(); bool code1match = false; bool code2match = false; if (laserData[0] != null) { code1match = (laserData[0].ToString() == laserCodes[0]); code2match = (laserData[0].ToString() == laserCodes[1]); } if (soundActive == true && testDistance && (code1match || code2match)) { userDisplay.setActiveSound("intervalBeep"); userDisplay.setProfile(""); userDisplay.setLaserX(0); userDisplay.setLaserY(0); } if (soundActive == true && testDistance2 && (code1match || code2match)) { userDisplay.setLaserX(laserX); userDisplay.setLaserY(laserY); userDisplay.setProfile(profile); userDisplay.setActiveSound("solidTone"); } if (!testDistance2 && !testDistance) { userDisplay.setActiveSound(null); userDisplay.setProfile(""); userDisplay.setLaserX(0); userDisplay.setLaserY(0); } double altitude = data1.z * -1; userDisplay.AppendTextBox("addUnit&position=[" + xm + "," + ym + "," + altitude + "]&name=" + nameData + "&active=true\r\n"); mySQLConnection.updateUserInDatabase(xm, ym, altitude, nameData, userDisplay); /* * string url2 = @"http://infernusdealtis.com/terminal/update.php?page=addUnit&position=[" + xm + "," + ym + "," + data1.z + "]&name=" + nameData + "&active=true"; * * HttpWebRequest req3 = (HttpWebRequest)WebRequest.Create(url2); * HttpWebResponse response3 = (HttpWebResponse)req3.GetResponse(); * * response3.Close(); */ System.Threading.Thread.Sleep(2000); seconds = seconds + 2; string secondsText = seconds.ToString(); if (seconds < 10) { secondsText = "0" + seconds; } if (seconds == 60) { seconds = 0; secondsText = "00"; minutes = minutes + 1; } if (minutes == 60) { hours = hours + 1; } string minutesText = minutes.ToString(); if (minutes < 10) { minutesText = "0" + minutes; } userDisplay.updateTimer(hours + " : " + minutesText + " : " + secondsText); } } while (true) { System.Threading.Thread.Sleep(3000); } }
public void saveUserToDatabase(double x, double y, double z, string name, monitorUi userDisplay) { string query = @"INSERT INTO flightunits ( x, y, z, name, active, source) VALUES ( " + x + ", " + y + ", " + z + ", '" + name + "', 1, 'Falcon4')"; //userDisplay.AppendTextBox(query + "\r\n"); //Open Connection if (this.OpenConnection( userDisplay ) == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); cmd.ExecuteReader(); //close Connection this.CloseConnection(); } }