Compare commits
No commits in common. "e1a16b3c67c423f47386535e6eeef5ca4b7591fa" and "5de052488aa4d5f8f7fe70e247de1bfcbae50a7a" have entirely different histories.
e1a16b3c67
...
5de052488a
|
|
@ -1,6 +1,5 @@
|
||||||
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;
|
||||||
|
|
@ -173,38 +172,4 @@ 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}"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,6 @@ using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using InnovEnergy.App.Backend.Database;
|
using InnovEnergy.App.Backend.Database;
|
||||||
using InnovEnergy.App.Backend.DataTypes;
|
using InnovEnergy.App.Backend.DataTypes;
|
||||||
using InnovEnergy.App.Backend.DataTypes.Methods;
|
|
||||||
using InnovEnergy.Lib.Utils;
|
using InnovEnergy.Lib.Utils;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using RabbitMQ.Client.Events;
|
using RabbitMQ.Client.Events;
|
||||||
|
|
@ -187,20 +186,6 @@ public static class RabbitMqManager
|
||||||
|
|
||||||
Db.UpdateInstallationStatus(installationId, receivedStatusMessage.Status);
|
Db.UpdateInstallationStatus(installationId, receivedStatusMessage.Status);
|
||||||
|
|
||||||
const int AlarmStatus = 2;
|
|
||||||
var isSodistore = installation.Product is 2 or 3 or 4 or 5;
|
|
||||||
if (isSodistore
|
|
||||||
&& prevStatus != AlarmStatus
|
|
||||||
&& receivedStatusMessage.Status == AlarmStatus)
|
|
||||||
{
|
|
||||||
var prev = prevStatus;
|
|
||||||
_ = Task.Run(async () =>
|
|
||||||
{
|
|
||||||
try { await installation.SendAlarmNotificationToSupport(prev); }
|
|
||||||
catch (Exception ex) { Console.WriteLine($"[AlarmNotify] failed for {installationId}: {ex.Message}"); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//Console.WriteLine("----------------------------------------------");
|
//Console.WriteLine("----------------------------------------------");
|
||||||
//If the status has changed, update all the connected front-ends regarding this installation
|
//If the status has changed, update all the connected front-ends regarding this installation
|
||||||
if(prevStatus != receivedStatusMessage.Status && WebsocketManager.InstallationConnections[installationId].Connections.Count > 0)
|
if(prevStatus != receivedStatusMessage.Status && WebsocketManager.InstallationConnections[installationId].Connections.Count > 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue