public static EventType GetEvent(Type type) { if (!EventTypes.TryGetValue(type, out EventType value)) { return(EventType.None); } return(value); }
public EventXmlData[] GetXmlEvents(AccountDbContext accountDbContext) { // загрузим все свойства var eventIdArray = Events.Select(x => x.Id).ToArray(); var allProperties = accountDbContext.EventProperties .Where(x => eventIdArray.Contains(x.EventId)) .ToArray(); var eventPropertiesGroups = allProperties .GroupBy(x => x.EventId) .ToDictionary(x => x.Key, x => x.ToArray()); var events = new List <EventXmlData>(); foreach (var item in Events) { // тип события EventsListEventTypeModel eventType = null; EventTypes.TryGetValue(item.EventTypeId, out eventType); if (eventType == null) { continue; } // компонент EventsListComponentModel component = null; Components.TryGetValue(item.OwnerId, out component); if (component == null) { continue; } var eventObj = new EventXmlData() { Id = item.Id, EventTypeId = eventType.Id, Count = item.Count, ActualDate = item.ActualDate, EndDate = item.EndDate, EventTypeDisplayName = eventType.DisplayName, EventTypeSystemName = eventType.SystemName, JoinKeyHash = item.JoinKey, Message = item.Message, Category = item.Category.ToString(), StartDate = item.StartDate, TypeCode = eventType.Code, OwnerId = item.OwnerId, ComponentId = component.Id, ComponentSystemName = component.SystemName, ComponentDisplayName = component.DisplayName }; EventProperty[] eventProperties = null; if (eventPropertiesGroups.TryGetValue(eventObj.Id, out eventProperties)) { eventObj.Properties = eventProperties.Select(x => new EventPropertyXml() { Key = x.Name, Type = x.DataType.ToString(), Vaue = x.Value }).ToArray(); } events.Add(eventObj); } return(events.ToArray()); }