email support team when an installation turns to eror status
This commit is contained in:
parent
5666191a6b
commit
64c8abd108
|
|
@ -1,5 +1,6 @@
|
||||||
using InnovEnergy.App.Backend.Database;
|
using InnovEnergy.App.Backend.Database;
|
||||||
using InnovEnergy.App.Backend.Relations;
|
using InnovEnergy.App.Backend.Relations;
|
||||||
|
using InnovEnergy.Lib.Mailer;
|
||||||
using InnovEnergy.Lib.Utils;
|
using InnovEnergy.Lib.Utils;
|
||||||
|
|
||||||
namespace InnovEnergy.App.Backend.DataTypes.Methods;
|
namespace InnovEnergy.App.Backend.DataTypes.Methods;
|
||||||
|
|
@ -172,4 +173,38 @@ public static class InstallationMethods
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const String SupportEmail = "support@inesco.energy";
|
||||||
|
private const String SupportName = "inesco energy Support Team";
|
||||||
|
|
||||||
|
public static Task SendAlarmNotificationToSupport(this Installation installation, Int32 prevStatus)
|
||||||
|
{
|
||||||
|
var productName = ProductName(installation.Product);
|
||||||
|
var fromStatus = StatusName(prevStatus);
|
||||||
|
|
||||||
|
var subject = $"[inesco energy] Alarm: {installation.Name}";
|
||||||
|
var body =
|
||||||
|
$"Installation \"{installation.Name}\" (ID {installation.Id}, {productName})\n" +
|
||||||
|
$"status changed from {fromStatus} to Alarm.\n\n" +
|
||||||
|
"Please check the Log tab on the Monitor to see detailed errors and warnings.\n";
|
||||||
|
|
||||||
|
return Mailer.Send(SupportName, SupportEmail, subject, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String StatusName(Int32 status) => status switch
|
||||||
|
{
|
||||||
|
-1 => "Offline",
|
||||||
|
0 => "Green",
|
||||||
|
1 => "Warning",
|
||||||
|
2 => "Alarm",
|
||||||
|
_ => "Unknown"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static String ProductName(Int32 product) => product switch
|
||||||
|
{
|
||||||
|
2 => "Sodistore Home",
|
||||||
|
3 => "Sodistore Max",
|
||||||
|
4 => "Sodistore Grid",
|
||||||
|
5 => "Sodistore Pro",
|
||||||
|
_ => $"Product {product}"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue