Example #1
0
 public void AddEvent(DateTime time, Event.EnumSeverity severity, Event.EnumType type, string description)
 {
     try
     {
         EventList.Add(new EventViewModel
         {
             Time        = time,
             Severity    = (EnumEventSeverity)severity,
             Type        = (EnumEventType)type,
             Description = description
         });
         if (EventList.Count > MAX_COUNT)
         {
             while (EventList.Count > MAX_COUNT - 100)
             {
                 EventList.Remove(EventList.First());
             }
         }
     }
     catch (Exception e)
     {
         // _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, e.Message);
         throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
     }
 }
Example #2
0
 public void UIAddEvent(DateTime time, Event.EnumSeverity s, Event.EnumType t, string text)
 {
     try
     {
         Warehouse?.OnNewEvent.ForEach(prop => { try { prop.Invoke(time, s, t, text); } catch { } });
         // Warehouse?.AddEvent((Event.EnumSeverity) s, (Event.EnumType) t, text);
     }
     catch (Exception ex)
     {
         Log.AddLog(Log.Severity.EXCEPTION, "WCFClient", "UIAddEvent", ex.Message);
     }
 }
Example #3
0
        public void CallOnNewEvent(DateTime dt, Event.EnumSeverity s, Event.EnumType t, string text)
        {
            var l = new List <Action <DateTime, Event.EnumSeverity, Event.EnumType, string> >();

            foreach (var n in OnNewEvent)
            {
                try
                {
                    n.Invoke(dt, s, t, text);
                }
                catch (Exception)
                {
                    l.Add(n);
                }
            }
            l.ForEach(p => OnNewEvent.Remove(p));
        }
Example #4
0
        public void AddEvent(Event.EnumSeverity s, Event.EnumType t, string text)
        {
            string   str = text.Substring(0, text.Length > MAX_EVENTSTRLEN ? MAX_EVENTSTRLEN : text.Length);
            DateTime dt  = DateTime.Now;

            try
            {
                CallOnNewEvent(dt, s, t, text);
            }
            catch { }
            if (TxtLog)
            {
                Log.AddLog(s == Event.EnumSeverity.Error ? Log.Severity.EXCEPTION : Log.Severity.EVENT, "", "BasicWarehouse.AddEvent", text);
            }
            else
            {
                DBService?.AddEvent(s, t, str, dt);
            }
        }