email support team when an installation turns to eror status

This commit is contained in:
Yinyin Liu 2026-04-21 14:05:35 +02:00
parent 5666191a6b
commit 64c8abd108
1 changed files with 36 additions and 1 deletions

View File

@ -1,5 +1,6 @@
using InnovEnergy.App.Backend.Database;
using InnovEnergy.App.Backend.Relations;
using InnovEnergy.Lib.Mailer;
using InnovEnergy.Lib.Utils;
namespace InnovEnergy.App.Backend.DataTypes.Methods;
@ -171,5 +172,39 @@ public static class InstallationMethods
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}"
};
}