public List<LogAudioDetection> getAllLogAudioDetectionShortByDateForDataGrid() { string query = "SELECT log_audio_detected.log_id, audio_type.type_name,log_audio_detected.log_detected_time,log_audio_detected.log_message,log_audio_detected.log_seen_status from log_audio_detected,audio_type,fingerprint where log_audio_detected.fingerprint_id = fingerprint.fingerprint_id AND fingerprint.type_id = audio_type.type_id ORDER BY log_audio_detected.log_detected_time DESC "; List<LogAudioDetection> LogAudios = new List<LogAudioDetection>(); if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { LogAudioDetection logAudioDetection = new LogAudioDetection(); FingerPrint fingerPrint = new FingerPrint(); AudioType audioType = new AudioType(); //audioType.Type_ = dataReader["type_id"] + ""; //audioType.Type_name = dataReader["type_name"] + ""; logAudioDetection.LogId = dataReader["log_id"] + ""; audioType.Type_name = dataReader["type_name"] + ""; fingerPrint.AudioType = audioType; logAudioDetection.FingerprintId = fingerPrint; logAudioDetection.LogDetectionTime = dataReader["log_detected_time"] + ""; logAudioDetection.LogSeenStatus = dataReader["log_seen_status"] + ""; logAudioDetection.LogMessage = dataReader["log_message"] + ""; LogAudios.Add(logAudioDetection); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); //return list to be displayed return LogAudios; } else { return null; } }
private List<LogAudioDetection> ParseMessage(string rawMessage) { if(rawMessage != "") { string[] messageSeparator = { "||" }; String[] rawLogAudioMessage = rawMessage.Split(messageSeparator, StringSplitOptions.None); string message = ""; List<LogAudioDetection> log = new List<LogAudioDetection>(); for(int i=0; i<rawLogAudioMessage.Length-1;i++){ message = rawLogAudioMessage[i]; Console.WriteLine("In Worker :"); Console.WriteLine(message); string[] resultItem = message.Split('#'); LogAudioDetection item = new LogAudioDetection(); item.FingerprintId.FingerPrintId=resultItem[0]; item.CreateMessageSoundDetected(new string[] { resultItem[1], resultItem[2] }); DateTime current = DateTime.Now; item.LogDetectionTime = current.ToString(); item.LogSeenStatus = "false"; String messageCode = ""+current.Year; messageCode += GenerateStringNumber(current.Month); messageCode += GenerateStringNumber(current.Day); messageCode += GenerateStringNumber(current.Hour); messageCode += GenerateStringNumber(current.Minute); messageCode += GenerateStringNumber(current.Second); item.LogId = messageCode; log.Add(item); } return log; } else { return null; } }
public List<LogAudioDetection> getAllLogAudioDetectionShortByDate() { string query = "SELECT * FROM log_audio_detected ORDER BY log_audio_detected.LOG_DETECTED_TIME DESC "; //Create a list to store the result List<LogAudioDetection> LogAudios = new List<LogAudioDetection>(); if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { LogAudioDetection logAudioDetection = new LogAudioDetection(); //audioType.Type_ = dataReader["type_id"] + ""; //audioType.Type_name = dataReader["type_name"] + ""; //logAudioDetection.LogId = Console.WriteLine(dataReader["log_id"] + ""); logAudioDetection.FingerprintId = getFingerPrintById(dataReader["fingerprint_id"]+""); //logAudioDetection.LogDetectionTime = Console.WriteLine(dataReader["log_detected_time"] +""); //logAudioDetection.LogSeenStatus = Console.WriteLine(dataReader["log_seen_status"] + ""); //logAudioDetection.LogMessage = Console.WriteLine(dataReader["log_message"] + ""); LogAudios.Add(logAudioDetection); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); //return list to be displayed return LogAudios; } else { return null; } }