fix notify bug

This commit is contained in:
辉鸭蛋
2025-02-08 22:25:00 +08:00
parent 3053e1aeb3
commit 040f40d94b

View File

@@ -5,6 +5,7 @@ using System.Drawing;
using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.GameTask.Common;
using BetterGenshinImpact.Service.Notification.Converter;
using Microsoft.Extensions.Logging;
namespace BetterGenshinImpact.Service.Notification.Model;
@@ -21,13 +22,13 @@ public class BaseNotificationData
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public NotificationEventResult Result { get; set; }
/// <summary>
/// 事件触发时间
/// </summary>
[JsonConverter(typeof(DateTimeJsonConverter))]
public DateTime Timestamp { get; set; } = DateTime.Now;
/// <summary>
/// 事件触发时的截图
/// </summary>
@@ -46,14 +47,28 @@ public class BaseNotificationData
public void Send()
{
if (TaskContext.Instance().Config.NotificationConfig.IncludeScreenShot)
try
{
Screenshot = (Bitmap)TaskControl.CaptureToRectArea().SrcBitmap.Clone();
if (TaskContext.Instance().Config.NotificationConfig.IncludeScreenShot)
{
Screenshot = (Bitmap)TaskControl.CaptureToRectArea().SrcBitmap.Clone();
}
}
catch (Exception e)
{
TaskControl.Logger.LogDebug(e, "补充通知截图失败");
}
try
{
NotificationService.Instance().NotifyAllNotifiers(this);
}
catch (Exception e)
{
TaskControl.Logger.LogDebug(e, "发送通知失败");
}
NotificationService.Instance().NotifyAllNotifiers(this);
}
public void Send(string message)
{
Message = message;