using System; using System.Linq; using System.Globalization; using System.Text; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using AyaNova.Util; using AyaNova.Models; //using System.Diagnostics; namespace AyaNova.Biz { //This class handles word breaking, processing keywords and searching for results public static class NotifyEventProcessor { private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("NotifyEventProcessor"); //Add operations message public static async Task AddOpsProblemEvent(string message, Exception ex = null) { if (string.IsNullOrWhiteSpace(message) && ex == null) return; //Log as a backup in case there is no one to notify and also for the record and support if (ex != null) { log.LogError(ex, $"Ops problem notification: \"{message}\""); message += $"\nException error: {ExceptionUtil.ExtractAllExceptionMessages(ex)}"; } else log.LogWarning($"Ops problem notification: \"{message}\""); await AddEvent(new NotifyEvent() { EventType = NotifyEventType.ServerOperationsProblem, Message = message }); } public static async Task AddEvent(NotifyEvent ev) { log.LogTrace($"AddEvent processing: [{ev.ToString()}]"); try { log.LogTrace("Notify set to RUNNING state and starting now"); using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext) { //iterate subs, figure out who gets this event //add to table for any that do var subs=await ct.NotifySubscription.AsNoTracking().Where(z=>z.EventType==ev.EventType &&) } } catch (Exception ex) { log.LogError(ex, $"Error adding notification event: [{ev.ToString()}]"); } finally { log.LogTrace($"Notify event processed: [{ev.ToString()}]"); } } }//eoc }//eons