diff --git a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs index dbad5ce..5f6c0a0 100644 --- a/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs @@ -109,24 +109,25 @@ public class DatabaseController { // General exception found Console.WriteLine(a_ex.ToString()); - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - package type: " + strUDPFrameType); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL >" + a_ex.Message); bStatus = false; } catch (MySqlException m_ex) { // MySQL exception found - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - package type: " + strUDPFrameType); switch (m_ex.Number) { case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port) - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - unable to connect"); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - unable to connect >" + m_ex.Message); break; case 0: // Access denied (Check DB name,username,password) - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - access denied"); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - access denied > " + m_ex.Message); break; default: - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - " + m_ex.Number); - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - " + m_ex.Message); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL > " + m_ex.Number); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL > " + m_ex.Message); break; } bStatus = false; @@ -134,9 +135,9 @@ public class DatabaseController connMySQL.Close(); Console.WriteLine("Sending data to MySQL - Done"); } - catch (ArgumentException) + catch (ArgumentException x_ex) { - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - wrong connection parameters"); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - unable to connect > " + x_ex.Message); } diff --git a/02_Windows_App/Perun_v1/01_Classes/Globals.cs b/02_Windows_App/Perun_v1/01_Classes/Globals.cs index efa6ebe..dd0c22b 100644 --- a/02_Windows_App/Perun_v1/01_Classes/Globals.cs +++ b/02_Windows_App/Perun_v1/01_Classes/Globals.cs @@ -10,8 +10,14 @@ internal class Globals public static int intInstanceId = 0; // Instance ID public static bool bStatusIconsForce = true; // Force icons reload public static bool bdcConnection = false; // Historic db connection status - public static bool btcpcServer = false; // Historic tcp connection status + public static bool bTCPServer = false; // Historic tcp connection status public static bool bSRSStatus = false; // Historic srs connection status public static bool bLotATCStatus = false; // Historic lotatc connection status + public static bool bClientConnected = false; // Is TCP connection alive + public static int intMysqlErros = 0; // Error counter + public static int intGameErros = 0; // Error counter + public static int intGameErrosHistory = 0; // Error counter + public static int intSRSErros = 0; // Error counter + public static int intLotATCErros = 0; // Error counter } diff --git a/02_Windows_App/Perun_v1/01_Classes/LogController.cs b/02_Windows_App/Perun_v1/01_Classes/LogController.cs index d1ba151..be6d8a9 100644 --- a/02_Windows_App/Perun_v1/01_Classes/LogController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/LogController.cs @@ -26,7 +26,14 @@ class LogController } else { - fileStream = new FileStream(logFilePath, FileMode.Append); + try + { + fileStream = new FileStream(logFilePath, FileMode.Append); + } + catch + { + + } } log = new StreamWriter(fileStream); log.WriteLine(strLog); diff --git a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs index 49c11ca..8287a0a 100644 --- a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs @@ -61,56 +61,61 @@ public class TCPController { // Start listening - Console.WriteLine("TCP: Waiting for packet"); - tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it - ns = tcpClient.GetStream(); //networkstream is used to send/receive messages - //ns.ReadTimeout = 100; - - while (tcpClient.Connected && !bDone) //while the client is connected, we look for incoming messages + // Wait for pending connection + if (tcpServer.Pending()) { - StringBuilder CompleteMessage = new StringBuilder(); - - if (ns.CanRead) + Console.WriteLine("TCP: Waiting for packet"); + tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it + ns = tcpClient.GetStream(); //networkstream is used to send/receive messages + //ns.ReadTimeout = 100; + Globals.bClientConnected = true; + while (tcpClient.Connected && !bDone) //while the client is connected, we look for incoming messages { - byte[] ReadBuffer = new byte[1024]; - CompleteMessage = new StringBuilder(); - int numberOfBytesRead = 0; + StringBuilder CompleteMessage = new StringBuilder(); + Globals.bClientConnected = true; - // Incoming message may be larger than the buffer size. - do + if (ns.CanRead) { - numberOfBytesRead = ns.Read(ReadBuffer, 0, ReadBuffer.Length); - CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead)); - } - while (ns.DataAvailable && !bDone); - } - strReceivedData = CompleteMessage.ToString(); - Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData); + byte[] ReadBuffer = new byte[1024]; + CompleteMessage = new StringBuilder(); + int numberOfBytesRead = 0; - try - { - dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame - string strRawTCPFrameType = dynamicRawTCPFrame.type; - - PerunHelper.LogHistoryAdd(ref arrLogHistory, "#" + Globals.intInstanceId + "> TCP packet received, type: " + strRawTCPFrameType); - - // Add to mySQL send buffer (find first empty slot) - for (int i = 0; i < arrSendBuffer.Length - 1; i++) - { - if (arrSendBuffer[i] == null) + // Incoming message may be larger than the buffer size. + do { - arrSendBuffer[i] = strReceivedData; - break; + numberOfBytesRead = ns.Read(ReadBuffer, 0, ReadBuffer.Length); + CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead)); + } + while (ns.DataAvailable && !bDone); + } + strReceivedData = CompleteMessage.ToString(); + Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData); + + try + { + dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame + string strRawTCPFrameType = dynamicRawTCPFrame.type; + + PerunHelper.LogHistoryAdd(ref arrLogHistory, "#" + Globals.intInstanceId + "> TCP packet received, type: " + strRawTCPFrameType); + + // Add to mySQL send buffer (find first empty slot) + for (int i = 0; i < arrSendBuffer.Length - 1; i++) + { + if (arrSendBuffer[i] == null) + { + arrSendBuffer[i] = strReceivedData; + break; + } } } - } - catch(Exception e) - { - Console.WriteLine(e.ToString()); - PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP ERROR incorrect JSON"); + catch (Exception e) + { + Globals.intGameErros++; + Console.WriteLine(e.ToString()); + PerunHelper.LogHistoryAdd(ref arrLogHistory, "#" + Globals.intInstanceId + " > TCP ERROR incorrect JSON > " + e.Message); + } } } - } tcpServer.Stop(); bStatus = false; @@ -120,8 +125,9 @@ public class TCPController // General exception found if (e.HResult != -2147467259) { + Globals.intGameErros++; Console.WriteLine(e.ToString()); - PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP error - connection closed or port in use"); + PerunHelper.LogHistoryAdd(ref arrLogHistory, "#" + Globals.intInstanceId + " > TCP error - connection closed or port in use > " + e.Message); } } diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs index fc3a6bf..c1ad029 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs @@ -65,14 +65,14 @@ this.con_txt_dcs_instance = new System.Windows.Forms.MaskedTextBox(); this.label7 = new System.Windows.Forms.Label(); this.con_txt_dcs_server_port = new System.Windows.Forms.MaskedTextBox(); - this.con_img_lotATC = new System.Windows.Forms.PictureBox(); - this.con_img_srs = new System.Windows.Forms.PictureBox(); - this.con_img_dcs = new System.Windows.Forms.PictureBox(); - this.con_img_db = new System.Windows.Forms.PictureBox(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); + this.con_img_lotATC = new System.Windows.Forms.PictureBox(); + this.con_img_srs = new System.Windows.Forms.PictureBox(); + this.con_img_dcs = new System.Windows.Forms.PictureBox(); + this.con_img_db = new System.Windows.Forms.PictureBox(); this.con_GroupBox_1.SuspendLayout(); this.con_GroupBox_2.SuspendLayout(); this.con_GroupBox_3.SuspendLayout(); @@ -89,10 +89,11 @@ this.con_List_Received.FormattingEnabled = true; this.con_List_Received.Items.AddRange(new object[] { "Not connected"}); - this.con_List_Received.Location = new System.Drawing.Point(6, 19); + this.con_List_Received.Location = new System.Drawing.Point(11, 19); this.con_List_Received.Name = "con_List_Received"; - this.con_List_Received.Size = new System.Drawing.Size(307, 147); + this.con_List_Received.Size = new System.Drawing.Size(307, 134); this.con_List_Received.TabIndex = 0; + this.con_List_Received.SelectedIndexChanged += new System.EventHandler(this.con_List_Received_SelectedIndexChanged); // // con_Button_Listen_ON // @@ -118,9 +119,9 @@ // con_GroupBox_1 // this.con_GroupBox_1.Controls.Add(this.con_List_Received); - this.con_GroupBox_1.Location = new System.Drawing.Point(12, 369); + this.con_GroupBox_1.Location = new System.Drawing.Point(12, 385); this.con_GroupBox_1.Name = "con_GroupBox_1"; - this.con_GroupBox_1.Size = new System.Drawing.Size(324, 176); + this.con_GroupBox_1.Size = new System.Drawing.Size(324, 162); this.con_GroupBox_1.TabIndex = 4; this.con_GroupBox_1.TabStop = false; this.con_GroupBox_1.Text = "Data log"; @@ -386,8 +387,53 @@ this.con_txt_dcs_server_port.Size = new System.Drawing.Size(207, 20); this.con_txt_dcs_server_port.TabIndex = 3; // + // label9 + // + this.label9.AutoSize = true; + this.label9.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.Location = new System.Drawing.Point(21, 369); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(61, 13); + this.label9.TabIndex = 1; + this.label9.Text = "Database"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.Location = new System.Drawing.Point(117, 369); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(39, 13); + this.label10.TabIndex = 14; + this.label10.Text = "Game"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.Location = new System.Drawing.Point(205, 369); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(32, 13); + this.label11.TabIndex = 15; + this.label11.Text = "SRS"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Location = new System.Drawing.Point(282, 369); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(49, 13); + this.label12.TabIndex = 16; + this.label12.Text = "LotATC"; + // // con_img_lotATC // + this.con_img_lotATC.Image = global::Perun_v1.Properties.Resources.status_disconnected; this.con_img_lotATC.Location = new System.Drawing.Point(292, 335); this.con_img_lotATC.Name = "con_img_lotATC"; this.con_img_lotATC.Size = new System.Drawing.Size(29, 28); @@ -397,7 +443,8 @@ // // con_img_srs // - this.con_img_srs.Location = new System.Drawing.Point(208, 335); + this.con_img_srs.Image = global::Perun_v1.Properties.Resources.status_disconnected; + this.con_img_srs.Location = new System.Drawing.Point(207, 335); this.con_img_srs.Name = "con_img_srs"; this.con_img_srs.Size = new System.Drawing.Size(29, 28); this.con_img_srs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -406,7 +453,8 @@ // // con_img_dcs // - this.con_img_dcs.Location = new System.Drawing.Point(135, 335); + this.con_img_dcs.Image = global::Perun_v1.Properties.Resources.status_disconnected; + this.con_img_dcs.Location = new System.Drawing.Point(122, 335); this.con_img_dcs.Name = "con_img_dcs"; this.con_img_dcs.Size = new System.Drawing.Size(29, 28); this.con_img_dcs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -416,49 +464,14 @@ // con_img_db // this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.con_img_db.Location = new System.Drawing.Point(69, 335); + this.con_img_db.Image = global::Perun_v1.Properties.Resources.status_disconnected; + this.con_img_db.Location = new System.Drawing.Point(37, 335); this.con_img_db.Name = "con_img_db"; this.con_img_db.Size = new System.Drawing.Size(29, 28); this.con_img_db.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.con_img_db.TabIndex = 10; this.con_img_db.TabStop = false; // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(15, 335); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(56, 13); - this.label9.TabIndex = 1; - this.label9.Text = "Database:"; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(101, 335); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(38, 13); - this.label10.TabIndex = 14; - this.label10.Text = "Game:"; - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(170, 335); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(32, 13); - this.label11.TabIndex = 15; - this.label11.Text = "SRS:"; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(243, 335); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(46, 13); - this.label12.TabIndex = 16; - this.label12.Text = "LotATC:"; - // // form_Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index 5cbb18a..fa21df8 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -157,8 +157,15 @@ namespace Perun_v1 Globals.intInstanceId= Int32.Parse(con_txt_dcs_instance.Text); Globals.bStatusIconsForce = true; - // Start listening - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Globals.intInstanceId + " > " + "Opening connections"); + Globals.intMysqlErros = 0; // Reset error counter + Globals.intGameErros = 0; // Reset error counter + Globals.intSRSErros = 0; // Reset error counter + Globals.intLotATCErros = 0; // Reset error counter + + Globals.bClientConnected = false; //no connection + + // Start listening + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Globals.intInstanceId + " > " + "Opening connections"); tcpcServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.arrLogHistory, ref arrSendBuffer); tcpcServer.thrTCPListener = new Thread(tcpcServer.StartListen); tcpcServer.thrTCPListener.Start(); @@ -209,10 +216,10 @@ namespace Perun_v1 } form_Main_EnableControls(); // Enable controls - con_img_db.Image = null; - con_img_dcs.Image = null; - con_img_lotATC.Image = null; - con_img_srs.Image = null; + con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); + con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); + con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); + con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected"); // Stop timmers tim_1000ms.Enabled = false; @@ -232,9 +239,10 @@ namespace Perun_v1 // Set helpers for updates Globals.bLogHistoryUpdate = false; Globals.bdcConnection = false; - Globals.btcpcServer = false; + Globals.bTCPServer = false; Globals.bSRSStatus = false; Globals.bLotATCStatus = false; + Globals.bClientConnected = false; } private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -384,45 +392,70 @@ namespace Perun_v1 if ((dcConnection.bStatus != Globals.bdcConnection) || Globals.bStatusIconsForce) { if (dcConnection.bStatus) { - con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_db"); + if (Globals.intMysqlErros == 0) + { + con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected"); + } else + { + con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_game"); + } } else { - con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error"); + con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error"); } Globals.bdcConnection = dcConnection.bStatus; } - if ((tcpcServer.bStatus != Globals.btcpcServer) || Globals.bStatusIconsForce) { - if (tcpcServer.bStatus) + if ((Globals.bClientConnected != Globals.bTCPServer) || Globals.bStatusIconsForce || Globals.intGameErros != Globals.intGameErrosHistory) { + if(Globals.bClientConnected) { - con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_game"); + if (Globals.intGameErros == 0 ) + { + con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected"); + } else + { + con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_game"); + } } else { - con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error"); + con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error"); } - Globals.btcpcServer = tcpcServer.bStatus; + Globals.bTCPServer = Globals.bClientConnected; + Globals.intGameErrosHistory = Globals.intGameErros; } if ((bSRSStatus != Globals.bSRSStatus) || Globals.bStatusIconsForce) { - if (bSRSStatus) + if (bSRSStatus && con_check_3rd_srs.Checked) { - con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_srs"); + if (Globals.intSRSErros == 0) + { + con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected"); + } else + { + con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_game"); + } } else - {; - con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error"); + { + con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error"); } Globals.bSRSStatus = bSRSStatus; } if ((bLotATCStatus != Globals.bLotATCStatus) || Globals.bStatusIconsForce) { - if (bLotATCStatus) + if (bLotATCStatus && con_check_3rd_lotatc.Checked) { - con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_lotatc"); + if (Globals.intLotATCErros == 0) + { + con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected"); + } else + { + con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_game"); + } } else { - con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error"); + con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error"); } Globals.bLotATCStatus = bLotATCStatus; } @@ -490,10 +523,11 @@ namespace Perun_v1 PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data loaded"); bSRSStatus = true; } - catch + catch (Exception exc_srs) { - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR"); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR > " + exc_srs.Message); bSRSStatus = false; + Globals.intSRSErros++; } @@ -517,10 +551,11 @@ namespace Perun_v1 PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data loaded"); bLotATCStatus = true; } - catch + catch(Exception exc_lotatc) { - PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR"); + PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR > " + exc_lotatc.Message); bLotATCStatus = false; + Globals.intLotATCErros++; } @@ -530,7 +565,19 @@ namespace Perun_v1 strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected } dcConnection.SendToMySql(strLotATCJson); + + // Let's do not risk int overload + Globals.intMysqlErros = (Globals.intMysqlErros > 999) ? 999 : Globals.intMysqlErros; + Globals.intGameErros = (Globals.intGameErros > 999) ? 999 : Globals.intGameErros; + Globals.intSRSErros = (Globals.intSRSErros > 999) ? 999 : Globals.intSRSErros; + Globals.intLotATCErros = (Globals.intLotATCErros > 999) ? 999 : Globals.intLotATCErros; + } + + private void con_List_Received_SelectedIndexChanged(object sender, EventArgs e) + { + + } } } diff --git a/02_Windows_App/Perun_v1/Perun_v1.csproj b/02_Windows_App/Perun_v1/Perun_v1.csproj index 2c076d4..efcb591 100644 --- a/02_Windows_App/Perun_v1/Perun_v1.csproj +++ b/02_Windows_App/Perun_v1/Perun_v1.csproj @@ -183,6 +183,11 @@ + + + + + diff --git a/02_Windows_App/Perun_v1/Properties/Resources.Designer.cs b/02_Windows_App/Perun_v1/Properties/Resources.Designer.cs index 5736650..66be48f 100644 --- a/02_Windows_App/Perun_v1/Properties/Resources.Designer.cs +++ b/02_Windows_App/Perun_v1/Properties/Resources.Designer.cs @@ -63,9 +63,9 @@ namespace Perun_v1.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ico_db { + internal static System.Drawing.Bitmap status_connected { get { - object obj = ResourceManager.GetObject("ico_db", resourceCulture); + object obj = ResourceManager.GetObject("status_connected", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -73,9 +73,9 @@ namespace Perun_v1.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ico_error { + internal static System.Drawing.Bitmap status_disconnected { get { - object obj = ResourceManager.GetObject("ico_error", resourceCulture); + object obj = ResourceManager.GetObject("status_disconnected", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -83,9 +83,9 @@ namespace Perun_v1.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ico_game { + internal static System.Drawing.Bitmap status_disconnected_error { get { - object obj = ResourceManager.GetObject("ico_game", resourceCulture); + object obj = ResourceManager.GetObject("status_disconnected_error", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -93,19 +93,9 @@ namespace Perun_v1.Properties { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ico_lotatc { + internal static System.Drawing.Bitmap status_disconnected_game { get { - object obj = ResourceManager.GetObject("ico_lotatc", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ico_srs { - get { - object obj = ResourceManager.GetObject("ico_srs", resourceCulture); + object obj = ResourceManager.GetObject("status_disconnected_game", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/02_Windows_App/Perun_v1/Properties/Resources.resx b/02_Windows_App/Perun_v1/Properties/Resources.resx index 3bef010..78d4f3b 100644 --- a/02_Windows_App/Perun_v1/Properties/Resources.resx +++ b/02_Windows_App/Perun_v1/Properties/Resources.resx @@ -118,19 +118,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\ico_db.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\status-connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ico_error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\status-disconnected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ico_game.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\status-disconnected-error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ico_lotatc.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\ico_srs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\status-connectedx.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/02_Windows_App/Perun_v1/Resources/status-connected.png b/02_Windows_App/Perun_v1/Resources/status-connected.png new file mode 100644 index 0000000..729fb81 Binary files /dev/null and b/02_Windows_App/Perun_v1/Resources/status-connected.png differ diff --git a/02_Windows_App/Perun_v1/Resources/status-connectedx.png b/02_Windows_App/Perun_v1/Resources/status-connectedx.png new file mode 100644 index 0000000..5e31a64 Binary files /dev/null and b/02_Windows_App/Perun_v1/Resources/status-connectedx.png differ diff --git a/02_Windows_App/Perun_v1/Resources/status-disconnected-error.png b/02_Windows_App/Perun_v1/Resources/status-disconnected-error.png new file mode 100644 index 0000000..893323b Binary files /dev/null and b/02_Windows_App/Perun_v1/Resources/status-disconnected-error.png differ diff --git a/02_Windows_App/Perun_v1/Resources/status-disconnected-game.png b/02_Windows_App/Perun_v1/Resources/status-disconnected-game.png new file mode 100644 index 0000000..c7f9b17 Binary files /dev/null and b/02_Windows_App/Perun_v1/Resources/status-disconnected-game.png differ diff --git a/02_Windows_App/Perun_v1/Resources/status-disconnected.png b/02_Windows_App/Perun_v1/Resources/status-disconnected.png new file mode 100644 index 0000000..7fd0e57 Binary files /dev/null and b/02_Windows_App/Perun_v1/Resources/status-disconnected.png differ