Formated code , updated MySQL structure

This commit is contained in:
Szymon Porwolik
2019-02-25 00:00:43 +01:00
parent 5d3f7148bb
commit f49734560e
4 changed files with 297 additions and 239 deletions

View File

@@ -325,9 +325,9 @@
elseif eventName == "connect" then elseif eventName == "connect" then
--"connect", playerID, name --"connect", playerID, name
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected");
Perun.LogLogin(arg1); Perun.LogLogin(arg1);
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected");
elseif eventName == "disconnect" then elseif eventName == "disconnect" then
--"disconnect", playerID, name, playerSide, reason_code --"disconnect", playerID, name, playerSide, reason_code
Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected"); Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected");

View File

@@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
// Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki // Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki
// przy użyciu symbolu „*”, tak jak pokazano poniżej: // przy użyciu symbolu „*”, tak jak pokazano poniżej:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.3.3")] [assembly: AssemblyVersion("0.3.5.0")]
[assembly: AssemblyFileVersion("0.3.3.3")] [assembly: AssemblyFileVersion("0.3.5.0")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]

View File

@@ -17,13 +17,13 @@ namespace Perun_v1
{ {
// Variable definitions // Variable definitions
public Thread thread_UDPListener; // Seperate thread for UDP public Thread thread_UDPListener; // Seperate thread for UDP
public class_UDPListener UDPListener; // Helper class for UDP comunication public class_UDPListener UDPListener; // Helper class for UDP comunication
public string[] LogHistory=new string[10]; // Log history for GUI public string[] LogHistory = new string[10]; // Log history for GUI
public string[] SendBuffer=new string[10]; // Mysql send buffer public string[] SendBuffer = new string[10]; // Mysql send buffer
public bool LetMeOut=false; // Helper to handle system tray public bool LetMeOut = false; // Helper to handle system tray
public string MySql_connStr; // MySQL connection string public string MySql_connStr; // MySQL connection string
public string publishVersion = "DEBUG"; // Helper for pulling version definition public string publishVersion = "DEBUG"; // Helper for pulling version definition
public static void LogHistoryAdd(ref string[] LogHistory, string Comment) public static void LogHistoryAdd(ref string[] LogHistory, string Comment)
{ {
@@ -38,141 +38,149 @@ namespace Perun_v1
public void SendToMySql(string raw_udp_frame) public void SendToMySql(string raw_udp_frame)
{ {
// Main function to send data to mysql // Main function to send data to mysql
dynamic udp_frame = JsonConvert.DeserializeObject(raw_udp_frame); dynamic udp_frame = JsonConvert.DeserializeObject(raw_udp_frame);
// Cut raw data to type and paylod for proper mysql insert // Cut raw data to type and paylod for proper mysql insert
string type = udp_frame.type; string type = udp_frame.type;
string payload = ""; string payload = "";
string sql = ""; string sql = "";
// Modify specific // Modify specific
if (type == "1") // Inject app version information if (type == "1") // Inject app version information
{ {
udp_frame.payload["v_win"] = "v" + publishVersion;
udp_frame.payload["v_win"] = "v"+ publishVersion;
}
// Specific SQL
if(type == "50")
{
sql = "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`) VALUES (NULL,'" + udp_frame.payload.datetime + "', '" + udp_frame.payload.player+ "', '" + udp_frame.payload.msg + "', '" + udp_frame.payload.all + "');";
}
else if(type == "51")
{
sql = "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash`) VALUES ( NULL, '" + udp_frame.payload.log_datetime + "', '" + udp_frame.payload.log_type + "', '" + udp_frame.payload.log_content + "', '" + udp_frame.payload.log_missionhash + "');";
}
else if (type == "52")
{
payload = JsonConvert.SerializeObject(udp_frame.payload.stat_data);
sql = "INSERT INTO `pe_LogStats` (`pe_LogStats_datetime`, `pe_LogStats_ucid`, `pe_LogStats_debug`,`pe_LogStats_missionhash`) VALUES ('" + udp_frame.payload.stat_datetime + "', '" + udp_frame.payload.stat_ucid + "', JSON_QUOTE('" + payload + "'), '" + udp_frame.payload.stat_missionhash + "') ON DUPLICATE KEY UPDATE pe_LogStats_datetime='" + udp_frame.payload.stat_datetime + "',pe_LogStats_ucid = '" + udp_frame.payload.stat_ucid + "', pe_LogStats_debug=JSON_QUOTE('" + payload + "'), pe_LogStats_missionhash='"+ udp_frame.payload.stat_missionhash+"'";
Console.WriteLine(sql);
} }
else
{ // Specific SQL
payload = JsonConvert.SerializeObject(udp_frame.payload); if (type == "50")
sql = "INSERT INTO pe_DataRaw(pe_dataraw_type,pe_dataraw_payload) VALUES (" + type + ",JSON_QUOTE('" + payload + "')) ON DUPLICATE KEY UPDATE pe_dataraw_payload = JSON_QUOTE('" + payload + "')"; {
} // Add entry to event log
sql = "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`) VALUES (NULL,'" + udp_frame.payload.datetime + "', '" + udp_frame.payload.player + "', '" + udp_frame.payload.msg + "', '" + udp_frame.payload.all + "');";
// Connect to mysql }
else if (type == "51")
{
// Add entry to event log
sql = "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash`) VALUES ( NULL, '" + udp_frame.payload.log_datetime + "', '" + udp_frame.payload.log_type + "', '" + udp_frame.payload.log_content + "', '" + udp_frame.payload.log_missionhash + "');";
}
else if (type == "52")
{
// Update user stats
payload = JsonConvert.SerializeObject(udp_frame.payload.stat_data);
sql = "INSERT INTO `pe_LogStats` (`pe_LogStats_datetime`, `pe_LogStats_ucid`, `pe_LogStats_debug`,`pe_LogStats_missionhash`) VALUES ('" + udp_frame.payload.stat_datetime + "', '" + udp_frame.payload.stat_ucid + "', JSON_QUOTE('" + payload + "'), '" + udp_frame.payload.stat_missionhash + "') ON DUPLICATE KEY UPDATE pe_LogStats_datetime='" + udp_frame.payload.stat_datetime + "',pe_LogStats_ucid = '" + udp_frame.payload.stat_ucid + "', pe_LogStats_debug=JSON_QUOTE('" + payload + "'), pe_LogStats_missionhash='" + udp_frame.payload.stat_missionhash + "'";
}
else if (type == "53")
{
// User logged in to DCS server
payload = JsonConvert.SerializeObject(udp_frame.payload.stat_data);
sql = "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_ucid`, `pe_LogLogins_name`, `pe_LogLogins_ip`) VALUES ('" + udp_frame.payload.login_datetime + "', '" + udp_frame.payload.login_ucid + "', '" + udp_frame.payload.login_name + "', '" + udp_frame.payload.login_ipaddr + "');";
sql = sql + "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_id`, `pe_DataPlayers_ucid`, `pe_DataPlayers_lastip`, `pe_DataPlayers_lastname`, `pe_DataPlayers_updated`) VALUES (NULL, '" + udp_frame.payload.login_ucid + "', '" + udp_frame.payload.login_ipaddr + "', '" + udp_frame.payload.login_name + "', '" + udp_frame.payload.login_datetime + "') ON DUPLICATE KEY UPDATE pe_DataPlayers_lastip='" + udp_frame.payload.login_ipaddr + "',pe_DataPlayers_lastname='" + udp_frame.payload.login_name + "',pe_DataPlayers_updated='" + udp_frame.payload.login_datetime + "'";
}
else
{
// General definition used for 1-10 packets
payload = JsonConvert.SerializeObject(udp_frame.payload);
sql = "INSERT INTO pe_DataRaw(pe_dataraw_type,pe_dataraw_payload) VALUES (" + type + ",JSON_QUOTE('" + payload + "')) ON DUPLICATE KEY UPDATE pe_dataraw_payload = JSON_QUOTE('" + payload + "')";
}
// Connect to mysql and execute sql
MySqlConnection conn = new MySqlConnection(MySql_connStr); MySqlConnection conn = new MySqlConnection(MySql_connStr);
try try
{
Console.WriteLine("Sending data to MySQL - Begin");
conn.Open();
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{ {
Console.WriteLine("Sending data to MySQL - Begin"); Console.WriteLine(rdr[0] + " -- " + rdr[1]);
conn.Open();
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr[0] + " -- " + rdr[1]);
}
rdr.Close();
LogHistoryAdd(ref LogHistory, "MySQL updated, package type: "+ type);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
LogHistoryAdd(ref LogHistory, "ERROR: MySQL");
} }
rdr.Close();
LogHistoryAdd(ref LogHistory, "MySQL updated, package type: " + type);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
LogHistoryAdd(ref LogHistory, "ERROR: MySQL");
}
conn.Close(); conn.Close();
Console.WriteLine("Sending data to MySQL - Done"); Console.WriteLine("Sending data to MySQL - Done");
} }
public class class_UDPListener public class class_UDPListener
{ {
// Main class for UDP listener // Main class for UDP listener
int listenPort; // Port to listen at int listenPort; // Port to listen at
public bool done; // Helper to exit main loop without killing thread public bool done; // Helper to exit main loop without killing thread
public UdpClient listener; // Listener object public UdpClient listener; // Listener object
public string[] LogHistory; // Log history for GUI public string[] LogHistory; // Log history for GUI
public string[] SendBuffer; // Mysql send buffer public string[] SendBuffer; // Mysql send buffer
public class_UDPListener(int port, ref string[] LogHistory, ref string[] SendBuffer) public class_UDPListener(int port, ref string[] LogHistory, ref string[] SendBuffer)
{ {
// Create clas - NOTE that there is reference passing // Create clas - NOTE that there is reference passing
this.listenPort = port; this.listenPort = port;
this.LogHistory = LogHistory; this.LogHistory = LogHistory;
this.SendBuffer = SendBuffer; this.SendBuffer = SendBuffer;
}
public void StartListen()
{
// Start listening to UDP
this.done = false;
listener = new UdpClient(listenPort);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Loopback, listenPort);
string received_data;
byte[] receive_byte_array;
Console.WriteLine("UDP Listen start");
try
{
while (!done)
{
Console.WriteLine("UDP: Waiting for packet");
receive_byte_array = listener.Receive(ref groupEP);
received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);
Console.WriteLine("Sender: {0} Payload: {1}", groupEP.ToString(), received_data);
// Add to log history and rotate
dynamic udp_frame = JsonConvert.DeserializeObject(received_data);
string type = udp_frame.type;
LogHistoryAdd(ref LogHistory, "UDP packet received, type: "+ type);
// Add to mySQL send buffer and rotate
for (int i = 0; i < SendBuffer.Length - 1; i++)
{
SendBuffer[i] = SendBuffer[i + 1];
}
SendBuffer[9] = received_data;
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.WriteLine("UDP listen stop");
listener.Close();
}
} }
public void StartListen()
{
// Start listening to UDP
this.done = false;
listener = new UdpClient(listenPort);
IPEndPoint groupEP = new IPEndPoint(IPAddress.Loopback, listenPort);
string received_data;
byte[] receive_byte_array;
Console.WriteLine("UDP Listen start");
try
{
while (!done)
{
Console.WriteLine("UDP: Waiting for packet");
receive_byte_array = listener.Receive(ref groupEP);
received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);
Console.WriteLine("Sender: {0} Payload: {1}", groupEP.ToString(), received_data);
// Add to log history and rotate
dynamic udp_frame = JsonConvert.DeserializeObject(received_data);
string type = udp_frame.type;
LogHistoryAdd(ref LogHistory, "UDP packet received, type: " + type);
// Add to mySQL send buffer and rotate
for (int i = 0; i < SendBuffer.Length - 1; i++)
{
SendBuffer[i] = SendBuffer[i + 1];
}
SendBuffer[9] = received_data;
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.WriteLine("UDP listen stop");
listener.Close();
}
}
public form_Main() public form_Main()
{ {
// Form init // Form init
InitializeComponent(); InitializeComponent();
} }
private void form_Main_Load(object sender, EventArgs e) private void form_Main_Load(object sender, EventArgs e)
{ {
// Form loaded - fill controls with default values // Form loaded - fill controls with default values
LogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun loaded..."; LogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun loaded...";
// Load settings // Load settings
con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB; con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB;
@@ -197,24 +205,108 @@ namespace Perun_v1
private void con_Button_Listen_ON_Click(object sender, EventArgs e) private void con_Button_Listen_ON_Click(object sender, EventArgs e)
{ {
// Start listening // Start listening
UDPListener = new class_UDPListener(48620,ref LogHistory, ref SendBuffer); UDPListener = new class_UDPListener(48620, ref LogHistory, ref SendBuffer);
thread_UDPListener = new Thread(UDPListener.StartListen); thread_UDPListener = new Thread(UDPListener.StartListen);
thread_UDPListener.Start(); thread_UDPListener.Start();
// Update form controls // Update form controls
con_Button_Listen_ON.Enabled = false; con_Button_Listen_ON.Enabled = false;
con_Button_Listen_OFF.Enabled = true; con_Button_Listen_OFF.Enabled = true;
con_txt_mysql_database.Enabled = false; con_txt_mysql_database.Enabled = false;
con_txt_mysql_username.Enabled = false; con_txt_mysql_username.Enabled = false;
con_txt_mysql_password.Enabled = false; con_txt_mysql_password.Enabled = false;
con_txt_mysql_server.Enabled = false; con_txt_mysql_server.Enabled = false;
con_txt_mysql_port.Enabled = false; con_txt_mysql_port.Enabled = false;
con_txt_3rd_lotatc.Enabled = false; con_txt_3rd_lotatc.Enabled = false;
con_txt_3rd_srs.Enabled = false; con_txt_3rd_srs.Enabled = false;
con_check_3rd_lotatc.Enabled = false; con_check_3rd_lotatc.Enabled = false;
con_check_3rd_srs.Enabled = false; con_check_3rd_srs.Enabled = false;
// Save settings // Save settings
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
Properties.Settings.Default.MYSQL_Password = con_txt_mysql_password.Text;
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
// Prepare connection string
MySql_connStr = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
// Start timmers
tim_1000ms.Enabled = true;
tim_10000ms.Enabled = true;
}
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
{
// Stop listening
UDPListener.listener.Close();
// Update form controls
con_Button_Listen_ON.Enabled = true;
con_Button_Listen_OFF.Enabled = false;
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_server.Enabled = true;
con_txt_3rd_lotatc.Enabled = true;
con_txt_3rd_srs.Enabled = true;
con_check_3rd_lotatc.Enabled = true;
con_check_3rd_srs.Enabled = true;
// Stop timmers
tim_1000ms.Enabled = false;
tim_10000ms.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
// Main timer to sync GUI with background tasks and flush buffers
// Refresh Log Window
con_List_Received.Items.Clear();
foreach (string i in LogHistory)
{
if (i != null)
{
con_List_Received.Items.Add(i);
}
}
// Send buffer to MySQL
for (int i = 0; i < SendBuffer.Length - 1; i++)
{
if (SendBuffer[i] != null)
{
SendToMySql(SendBuffer[i]);
SendBuffer[i] = null;
}
}
}
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Open default browser with link to Perun repo
ProcessStartInfo sInfo = new ProcessStartInfo("https://github.com/szporwolik/perun");
Process.Start(sInfo);
}
private void con_Button_Quit_Click(object sender, EventArgs e)
{
// Close app
DialogResult dialogResult = MessageBox.Show("Are you sure to exit Perun?", "Question", MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
// Save settings on exit
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text; Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text; Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text; Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
@@ -227,104 +319,20 @@ namespace Perun_v1
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked; Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked; Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
// Prepare connection string Properties.Settings.Default.Save();
MySql_connStr = "server="+con_txt_mysql_server.Text+";user="+con_txt_mysql_username.Text+";database="+con_txt_mysql_database.Text+";port="+ con_txt_mysql_port.Text + ";password="+con_txt_mysql_password.Text;
// Start timmers LetMeOut = true;
tim_1000ms.Enabled = true; this.Close();
tim_10000ms.Enabled = true; }
else if (dialogResult == DialogResult.No)
} {
//do nothing
private void con_Button_Listen_OFF_Click(object sender, EventArgs e) }
{
// Stop listening
UDPListener.listener.Close();
// Update form controls
con_Button_Listen_ON.Enabled = true;
con_Button_Listen_OFF.Enabled = false;
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_server.Enabled = true;
con_txt_3rd_lotatc.Enabled = true;
con_txt_3rd_srs.Enabled = true;
con_check_3rd_lotatc.Enabled = true;
con_check_3rd_srs.Enabled = true;
// Stop timmers
tim_1000ms.Enabled = false;
tim_10000ms.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
// Main timer to sync GUI with background tasks and flush buffers
// Refresh Log Window
con_List_Received.Items.Clear();
foreach (string i in LogHistory)
{
if (i != null)
{
con_List_Received.Items.Add(i);
}
}
// Send buffer to MySQL
for (int i = 0; i < SendBuffer.Length - 1; i++)
{
if (SendBuffer[i] != null)
{
SendToMySql(SendBuffer[i]);
SendBuffer[i] = null;
}
}
}
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Open default browser with link to Perun repo
ProcessStartInfo sInfo = new ProcessStartInfo("https://github.com/szporwolik/perun");
Process.Start(sInfo);
}
private void con_Button_Quit_Click(object sender, EventArgs e)
{
// Close app
DialogResult dialogResult = MessageBox.Show("Are you sure to exit Perun?", "Question", MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
// Save settings on exit
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
Properties.Settings.Default.MYSQL_Password = con_txt_mysql_password.Text;
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
Properties.Settings.Default.Save();
LetMeOut = true;
this.Close();
}
else if (dialogResult == DialogResult.No)
{
//do nothing
}
} }
private void form_Main_FormClosing(object sender, FormClosingEventArgs e) private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
{ {
// Minimize to try // Minimize to try
if (e.CloseReason == CloseReason.UserClosing && !LetMeOut) if (e.CloseReason == CloseReason.UserClosing && !LetMeOut)
{ {
e.Cancel = true; e.Cancel = true;
@@ -352,7 +360,8 @@ namespace Perun_v1
{ {
con_txt_3rd_srs.Text = openFileDialog_SRS.FileName; con_txt_3rd_srs.Text = openFileDialog_SRS.FileName;
con_check_3rd_srs.Checked = true; con_check_3rd_srs.Checked = true;
} else }
else
{ {
con_txt_3rd_srs.Text = ""; con_txt_3rd_srs.Text = "";
con_check_3rd_srs.Checked = false; con_check_3rd_srs.Checked = false;
@@ -377,8 +386,8 @@ namespace Perun_v1
private void tim_10000ms_Tick(object sender, EventArgs e) private void tim_10000ms_Tick(object sender, EventArgs e)
{ {
// Main timer to send JSON files to MySQL // Main timer to send JSON files to MySQL
string strSRSJson =""; string strSRSJson = "";
string strLotATCJson=""; string strLotATCJson = "";
bool SRSdefault = true; bool SRSdefault = true;
bool LotATCdefault = true; bool LotATCdefault = true;
@@ -394,7 +403,8 @@ namespace Perun_v1
for (int i = 0; i < raw_lotatc.Count; i++) for (int i = 0; i < raw_lotatc.Count; i++)
{ {
if (raw_lotatc[i].RadioInfo != null) { if (raw_lotatc[i].RadioInfo != null)
{
int temp = raw_lotatc[i].RadioInfo.radios.Count - 1; int temp = raw_lotatc[i].RadioInfo.radios.Count - 1;
for (int j = temp; j >= 0; j--) for (int j = temp; j >= 0; j--)
@@ -440,8 +450,8 @@ namespace Perun_v1
} }
} }
if(SRSdefault) if (SRSdefault)
{ {
strSRSJson = "{'type':'100','payload':{'ignore':'true'}}"; strSRSJson = "{'type':'100','payload':{'ignore':'true'}}";
} }
@@ -463,8 +473,8 @@ namespace Perun_v1
{ {
LogHistoryAdd(ref LogHistory, "LotATC data ERROR"); LogHistoryAdd(ref LogHistory, "LotATC data ERROR");
} }
} }
if (LotATCdefault) if (LotATCdefault)
@@ -472,7 +482,7 @@ namespace Perun_v1
strLotATCJson = "{'type':'101','payload':{'ignore':'true'}}"; strLotATCJson = "{'type':'101','payload':{'ignore':'true'}}";
} }
SendToMySql(strLotATCJson); SendToMySql(strLotATCJson);
} }
} }
} }

View File

@@ -18,6 +18,23 @@ USE `m1081_perun`;
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `pe_DataPlayers`
--
DROP TABLE IF EXISTS `pe_DataPlayers`;
CREATE TABLE IF NOT EXISTS `pe_DataPlayers` (
`pe_DataPlayers_id` bigint(20) NOT NULL AUTO_INCREMENT,
`pe_DataPlayers_ucid` varchar(150) NOT NULL,
`pe_DataPlayers_lastip` varchar(100) NOT NULL,
`pe_DataPlayers_lastname` varchar(150) NOT NULL,
`pe_DataPlayers_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`pe_DataPlayers_id`),
UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
-- --
-- Struktura tabeli dla tabeli `pe_DataRaw` -- Struktura tabeli dla tabeli `pe_DataRaw`
-- --
@@ -39,7 +56,7 @@ CREATE TABLE IF NOT EXISTS `pe_DataRaw` (
DROP TABLE IF EXISTS `pe_LogChat`; DROP TABLE IF EXISTS `pe_LogChat`;
CREATE TABLE IF NOT EXISTS `pe_LogChat` ( CREATE TABLE IF NOT EXISTS `pe_LogChat` (
`pe_LogChat_id` bigint(20) NOT NULL AUTO_INCREMENT, `pe_LogChat_id` bigint(20) NOT NULL AUTO_INCREMENT,
`pe_LogChat_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `pe_LogChat_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pe_LogChat_playerid` varchar(100) NOT NULL, `pe_LogChat_playerid` varchar(100) NOT NULL,
`pe_LogChat_msg` text NOT NULL, `pe_LogChat_msg` text NOT NULL,
`pe_LogChat_all` varchar(10) NOT NULL, `pe_LogChat_all` varchar(10) NOT NULL,
@@ -56,11 +73,42 @@ DROP TABLE IF EXISTS `pe_LogEvent`;
CREATE TABLE IF NOT EXISTS `pe_LogEvent` ( CREATE TABLE IF NOT EXISTS `pe_LogEvent` (
`pe_LogEvent_id` bigint(20) NOT NULL AUTO_INCREMENT, `pe_LogEvent_id` bigint(20) NOT NULL AUTO_INCREMENT,
`pe_LogEvent_missionhash` varchar(150) DEFAULT NULL, `pe_LogEvent_missionhash` varchar(150) DEFAULT NULL,
`pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP,
`pe_LogEvent_type` varchar(100) NOT NULL, `pe_LogEvent_type` varchar(100) NOT NULL,
`pe_LogEvent_content` text NOT NULL, `pe_LogEvent_content` text NOT NULL,
PRIMARY KEY (`pe_LogEvent_id`) PRIMARY KEY (`pe_LogEvent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `pe_LogLogins`
--
DROP TABLE IF EXISTS `pe_LogLogins`;
CREATE TABLE IF NOT EXISTS `pe_LogLogins` (
`pe_LogLogins_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pe_LogLogins_ucid` varchar(150) NOT NULL,
`pe_LogLogins_name` varchar(150) NOT NULL,
`pe_LogLogins_ip` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `pe_LogStats`
--
DROP TABLE IF EXISTS `pe_LogStats`;
CREATE TABLE IF NOT EXISTS `pe_LogStats` (
`pe_LogStats_id` bigint(20) NOT NULL AUTO_INCREMENT,
`pe_LogStats_missionhash` varchar(150) DEFAULT NULL,
`pe_LogStats_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pe_LogStats_ucid` varchar(200) NOT NULL,
`pe_LogStats_debug` text,
PRIMARY KEY (`pe_LogStats_id`),
UNIQUE KEY `UNIQUE_STATS_PER_MISSION_AND_UCID` (`pe_LogStats_ucid`,`pe_LogStats_missionhash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT; COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;