Пример #1
0
        internal static void BroadcastLog(LogBase logModule, LogEventType eventType, DateTime Timestamp, params object[] Arguments)
        {
            var message = LogLiveEvent.Create(logModule, eventType, Timestamp, Arguments);

            var connectionManager = GlobalHost.ConnectionManager;
            var context = connectionManager.GetHubContext<LogNotificationsHub>();
            var targets = new List<string> { AllLoggingNotification, NotificationsModulePrefix + logModule.ModuleName };
            context.Clients.Groups(targets).receiveLog(message);
        }
Пример #2
0
 public static LogEventTypeModel FromLogEventType(LogEventType EventType)
 {
     return new LogEventTypeModel()
     {
         Id = EventType.Id,
         Name = EventType.Name,
         Severity = EventType.Severity
     };
 }
Пример #3
0
        private static void InitalizeDatabase(Persistance.LogPersistContext LogDatabase)
        {
            // Add Modules
            var existingModules = LogDatabase.Modules.Include("EventTypes").ToDictionary(m => m.Id);
            foreach (var module in LogModules)
            {
                // Update/Insert Module
                Models.LogModule dbModule;
                if (existingModules.TryGetValue(module.Key, out dbModule))
                {
                    // Update
                    if (dbModule.Name != module.Value.ModuleName)
                        dbModule.Name = module.Value.ModuleName;
                    if (dbModule.Description != module.Value.ModuleDescription)
                        dbModule.Description = module.Value.ModuleDescription;
                }
                else
                {
                    // Insert
                    dbModule = new Models.LogModule()
                    {
                        Id = module.Key,
                        Name = module.Value.ModuleName,
                        Description = module.Value.ModuleDescription
                    };
                    LogDatabase.Modules.Add(dbModule);
                }
                // Update/Insert Event Types
                Dictionary<int, Models.LogEventType> existingEventTypes = (dbModule.EventTypes == null) ? new Dictionary<int, Models.LogEventType>() : dbModule.EventTypes.ToDictionary(et => et.Id);
                foreach (var eventType in module.Value.EventTypes)
                {
                    Models.LogEventType dbEventType;
                    if (existingEventTypes.TryGetValue(eventType.Key, out dbEventType))
                    {
                        // Update
                        if (dbEventType.Name != eventType.Value.Name)
                            dbEventType.Name = eventType.Value.Name;
                        if (dbEventType.Severity != eventType.Value.Severity)
                            dbEventType.Severity = eventType.Value.Severity;
                        if (dbEventType.Format != eventType.Value.Format)
                            dbEventType.Format = eventType.Value.Format;
                    }
                    else
                    {
                        // Insert
                        dbEventType = new Models.LogEventType()
                        {
                            Id = eventType.Key,
                            ModuleId = module.Key,
                            Name = eventType.Value.Name,
                            Severity = eventType.Value.Severity,
                            Format = eventType.Value.Format
                        };
                        LogDatabase.EventTypes.Add(dbEventType);
                    }
                }
            }

            LogDatabase.SaveChanges();
        }