Example #1
0
        public void sendGeneratedAlert(GeneratedAlert alert)
        {
            if (alert == null)
            {
                return;
            }

            MQTTHandler.Instance.sendGeneratedAlert(alert);
        }
Example #2
0
        public void sendGeneratedAlert(GeneratedAlert alert)
        {
            if (alert == null)
            {
                return;
            }

            string json = JsonConvert.SerializeObject(alert);

            publishData("alerts_data/data", json);
        }
Example #3
0
        public void generateAlert(int alertID)
        {
            /*CREATE GENERATED ALERT*/
            GeneratedAlert generatedAlert = new GeneratedAlert
            {
                alert_id  = alertID,
                timestamp = DateTime.Now.ToString()
            };

            generatedAlerts.Add(generatedAlert);

            sendGeneratedAlert(generatedAlert);
        }
 public void SaveGeneratedAlert(GeneratedAlert alert)
 {
     try
     {
         SqlConnection sql = new SqlConnection(connectionString);
         sql.Open();
         SqlCommand sqlCommand = new SqlCommand("INSERT INTO t_generated_alerts VALUES(@id_alert,@timestamp)", sql);
         sqlCommand.Parameters.AddWithValue("@id_alert", alert.alert_id);
         sqlCommand.Parameters.AddWithValue("@timestamp", alert.timestamp);
         sqlCommand.ExecuteNonQuery();
         sql.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine("Failed creating a new generated alert! Reason:" + e.Message);
         Console.ReadKey();
     }
 }