mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 17:55:38 +02:00
Basic error proofing for UDP (port al;ready in use) and MySQL (connection/access issues).
This commit is contained in:
@@ -150,6 +150,7 @@
|
||||
//
|
||||
// con_txt_mysql_port
|
||||
//
|
||||
this.con_txt_mysql_port.Enabled = false;
|
||||
this.con_txt_mysql_port.Location = new System.Drawing.Point(106, 45);
|
||||
this.con_txt_mysql_port.Name = "con_txt_mysql_port";
|
||||
this.con_txt_mysql_port.Size = new System.Drawing.Size(207, 20);
|
||||
|
||||
@@ -125,12 +125,27 @@ namespace Perun_v1
|
||||
rdr.Close();
|
||||
LogHistoryAdd(ref LogHistory, "MySQL updated, package type: " + type);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (ArgumentException a_ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL: type " + type);
|
||||
Console.WriteLine(a_ex.ToString());
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL - package type " + type);
|
||||
}
|
||||
catch (MySqlException ex)
|
||||
{
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL - package type " + type);
|
||||
switch (ex.Number)
|
||||
{
|
||||
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL - unable to connect");
|
||||
break;
|
||||
case 0: // Access denied (Check DB name,username,password)
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL - access denied");
|
||||
break;
|
||||
default:
|
||||
LogHistoryAdd(ref LogHistory, "ERROR MySQL - " + ex.Number);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
Console.WriteLine("Sending data to MySQL - Done");
|
||||
}
|
||||
@@ -155,6 +170,9 @@ namespace Perun_v1
|
||||
}
|
||||
|
||||
public void StartListen()
|
||||
{
|
||||
Console.WriteLine("UDP Listen start");
|
||||
try
|
||||
{
|
||||
// Start listening to UDP
|
||||
this.done = false;
|
||||
@@ -163,9 +181,7 @@ namespace Perun_v1
|
||||
string received_data;
|
||||
byte[] receive_byte_array;
|
||||
|
||||
Console.WriteLine("UDP Listen start");
|
||||
try
|
||||
{
|
||||
|
||||
while (!done)
|
||||
{
|
||||
Console.WriteLine("UDP: Waiting for packet");
|
||||
@@ -191,13 +207,15 @@ namespace Perun_v1
|
||||
}
|
||||
|
||||
}
|
||||
listener.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
LogHistoryAdd(ref LogHistory, "ERROR UDP - port may be in use");
|
||||
}
|
||||
Console.WriteLine("UDP listen stop");
|
||||
listener.Close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,8 +296,14 @@ namespace Perun_v1
|
||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Stop listening
|
||||
try
|
||||
{
|
||||
UDPListener.listener.Close();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
// Update form controls
|
||||
con_Button_Listen_ON.Enabled = true;
|
||||
con_Button_Listen_OFF.Enabled = false;
|
||||
@@ -287,7 +311,7 @@ namespace Perun_v1
|
||||
con_txt_mysql_database.Enabled = true;
|
||||
con_txt_mysql_username.Enabled = true;
|
||||
con_txt_mysql_password.Enabled = true;
|
||||
con_txt_mysql_port.Enabled = true;
|
||||
//con_txt_mysql_port.Enabled = true;
|
||||
con_txt_mysql_server.Enabled = true;
|
||||
con_txt_3rd_lotatc.Enabled = true;
|
||||
con_txt_3rd_srs.Enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user