public bool NewAlertRequest(IActivityMonitor activityMonitor, AlertExpressionModel alertExpression) { _memoryStream.Seek(0, SeekOrigin.Begin); _memoryStream.Flush(); try { foreach (var sender in alertExpression.Senders) { switch (sender.SenderType) { case "Mail": sender.Configuration = JObject.FromObject(sender.Configuration).ToObject <MailSenderConfiguration>(); break; case "Http": sender.Configuration = JObject.FromObject(sender.Configuration).ToObject <HttpSenderConfiguration>(); break; default: return(false); } } } catch (Exception exception) { activityMonitor.Error("Alert initialization failed.", exception); return(false); } _formatter.Serialize(_memoryStream, alertExpression); _controlChannelClient.SendAsync("AddAlertSender", _memoryStream.ToArray()).GetAwaiter().GetResult(); return(true); }
public void Handle(IActivityMonitor m, GrandOutputEventInfo logEvent) { _memoryStream.SetLength(0); _memoryStream.Seek(0, SeekOrigin.Begin); logEvent.Entry.WriteLogEntry(_binaryWriter); _controlChannelClient.SendAsync("GrandOutputEventInfo", _memoryStream.ToArray()).GetAwaiter().GetResult(); }