From 64c8abd108d276ea8f7efa07acc291fc66a501a2 Mon Sep 17 00:00:00 2001 From: Yinyin Liu Date: Tue, 21 Apr 2026 14:05:35 +0200 Subject: [PATCH] email support team when an installation turns to eror status --- .../Backend/DataTypes/Methods/Installation.cs | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/csharp/App/Backend/DataTypes/Methods/Installation.cs b/csharp/App/Backend/DataTypes/Methods/Installation.cs index 074b62638..fd01696cc 100644 --- a/csharp/App/Backend/DataTypes/Methods/Installation.cs +++ b/csharp/App/Backend/DataTypes/Methods/Installation.cs @@ -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}" + }; } \ No newline at end of file