Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ObservatoryExplorer/CustomCriteriaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ internal class CustomCriteriaManager
private Dictionary<String,LuaFunction> CriteriaFunctions;
private Dictionary<string, string> CriteriaWithErrors = new();
Action<Exception, String> ErrorLogger;
private Action<string, string, string, string> NotificationMethod;
private Action<string, string, string, string, int?> NotificationMethod;
private uint ScanCount;
private string eventTime = string.Empty;

public CustomCriteriaManager(Action<Exception, String> errorLogger, Action<string, string, string, string> notificationMethod)
public CustomCriteriaManager(Action<Exception, String> errorLogger, Action<string, string, string, string, int?> notificationMethod)
{
ErrorLogger = errorLogger;
CriteriaFunctions = new();
ScanCount = 0;
NotificationMethod = notificationMethod;
}

public void SendNotification(string title, string detail, string extendedDetail) => NotificationMethod(eventTime, title, detail, extendedDetail);
public void SendNotification(string title, string detail, string extendedDetail)
=> NotificationMethod(eventTime, title, detail, extendedDetail, null);
public void SendNotificationForBody(string title, string detail, string extendedDetail, int bodyId)
=> NotificationMethod(eventTime, title, detail, extendedDetail, bodyId);

public void RefreshCriteria(string criteriaPath)
{
Expand Down Expand Up @@ -156,6 +159,7 @@ local count
#region Convenience Functions

LuaState.RegisterFunction("notify", this, typeof(CustomCriteriaManager).GetMethod("SendNotification"));
LuaState.RegisterFunction("notifyForBody", this, typeof(CustomCriteriaManager).GetMethod("SendNotificationForBody"));

// Body type related functions and tests

Expand Down
8 changes: 4 additions & 4 deletions ObservatoryExplorer/Explorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ private void SendNotification(Scan scanEvent, string detail, string extendedDeta
ObservatoryCore.SendNotification(args);
}

private void SendNotification(string title, string detail, string extendedDetail)
private void SendNotification(string title, string detail, string extendedDetail, int? coalescingId = null)
{
NotificationArgs args = new()
{
Title = title,
Detail = detail,
Sender = ExplorerWorker.AboutInfo.ShortName,
ExtendedDetails = extendedDetail,
CoalescingId = -1,
CoalescingId = coalescingId ?? -1,
};

ObservatoryCore.SendNotification(args);
Expand All @@ -410,9 +410,9 @@ private void AddGridItem(string eventTime, string title, string detail, string e
ObservatoryCore.AddGridItem(ExplorerWorker, results);
}

private void HandleCustomNotification(string eventTime, string title, string detail, string extendedDetail)
private void HandleCustomNotification(string eventTime, string title, string detail, string extendedDetail, int? coalescingId = null)
{
SendNotification(title, detail, extendedDetail);
SendNotification(title, detail, extendedDetail, coalescingId);
AddGridItem(eventTime, title, detail, extendedDetail);
}

Expand Down