send email to support team if there are >=2 limb strings in a battery
This commit is contained in:
parent
be325dd90c
commit
d34a1c287b
|
@ -6,6 +6,7 @@ using InnovEnergy.App.Backend.Database;
|
|||
using InnovEnergy.App.Backend.DataTypes;
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using InnovEnergy.Lib.Mailer;
|
||||
|
||||
namespace InnovEnergy.App.Backend.Websockets;
|
||||
|
||||
|
@ -61,6 +62,20 @@ public static class RabbitMqManager
|
|||
Console.WriteLine("----------------------------------------------");
|
||||
|
||||
int installationId = (int)Db.Installations.Where(f => f.Product == receivedStatusMessage.Product && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.Id).FirstOrDefault();
|
||||
string installationName = (string)Db.Installations.Where(f => f.Product == receivedStatusMessage.Product && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.InstallationName).FirstOrDefault();
|
||||
int bucketId = (int)Db.Installations.Where(f => f.Product == receivedStatusMessage.Product && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.S3BucketId).FirstOrDefault();
|
||||
int productId = (int)Db.Installations.Where(f => f.Product == receivedStatusMessage.Product && f.S3BucketId == receivedStatusMessage.InstallationId).Select(f => f.Product).FirstOrDefault();
|
||||
string monitorLink = "";
|
||||
if (productId == 0)
|
||||
{
|
||||
monitorLink =
|
||||
$"https://monitor.innov.energy/installations/list/installation/{bucketId}/batteryview";
|
||||
}
|
||||
else
|
||||
{
|
||||
monitorLink =
|
||||
$"https://monitor.innov.energy/salidomo_installations/list/installation/{bucketId}/batteryview";
|
||||
}
|
||||
Console.WriteLine("Received a message from installation: " + installationId + " , product is: "+receivedStatusMessage.Product+ " and status is: " + receivedStatusMessage.Status);
|
||||
|
||||
//This is a heartbit message, just update the timestamp for this installation.
|
||||
|
@ -109,6 +124,25 @@ public static class RabbitMqManager
|
|||
DeviceCreatedTheMessage = alarm.CreatedBy,
|
||||
Seen = false
|
||||
}; Console.WriteLine("Add an alarm for installation "+installationId);
|
||||
// Send replace battery email to support team if this alarm is "NeedToReplaceBattery"
|
||||
if (alarm.Description == "NeedToReplaceBattery")
|
||||
{
|
||||
Console.WriteLine("Send replace battery email to the support team for installation "+installationId);
|
||||
string recipient = "support@innov.energy";
|
||||
string subject = "Battery Alarm: 2 or more strings broken";
|
||||
string text = $"Dear InnovEnergy Support Team,\n" +
|
||||
$"\n"+
|
||||
$"Installation Name: {installationName}\n"+
|
||||
$"\n"+
|
||||
$"Installation Monitor Link: {monitorLink}\n"+
|
||||
$"\n"+
|
||||
$"Please exchange: {alarm.CreatedBy}\n"+
|
||||
$"\n"+
|
||||
$"Error created date and time: {alarm.Date} {alarm.Time}\n"+
|
||||
$"\n"+
|
||||
$"Thank you for your great support:)";
|
||||
Mailer.Send("InnovEnergy Support Team", recipient, subject, text);
|
||||
}
|
||||
//Create a new error and add it to the database
|
||||
Db.HandleError(newError, installationId);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue