diff --git a/BetterGenshinImpact/Service/Notification/Model/BaseNotificationData.cs b/BetterGenshinImpact/Service/Notification/Model/BaseNotificationData.cs index 70f1ad97..1f19ef13 100644 --- a/BetterGenshinImpact/Service/Notification/Model/BaseNotificationData.cs +++ b/BetterGenshinImpact/Service/Notification/Model/BaseNotificationData.cs @@ -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 /// [JsonConverter(typeof(JsonStringEnumConverter))] public NotificationEventResult Result { get; set; } - + /// /// 事件触发时间 /// [JsonConverter(typeof(DateTimeJsonConverter))] public DateTime Timestamp { get; set; } = DateTime.Now; - + /// /// 事件触发时的截图 /// @@ -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;