internal void AddEvent(int requestId, short eventId, EpcisEvent currentEvent) { Events.Add(EventDto.Create(currentEvent, eventId, requestId)); Epcs.AddRange(currentEvent.Epcs.Select(x => EpcDto.Create(x, eventId, requestId))); SourceDests.AddRange(currentEvent.SourceDestinationList.Select(x => SourceDestDto.Create(x, eventId, requestId))); Transactions.AddRange(currentEvent.BusinessTransactions.Select(x => TransactionDto.Create(x, eventId, requestId))); CorrectiveIds.AddRange(currentEvent.CorrectiveEventIds?.Select(x => CorrectiveIdDto.Create(x, eventId, requestId))); CustomFields.AddRange(currentEvent.CustomFields.ToFlattenedDtos(eventId, requestId)); }
private void Load() { var path = HostingEnvironment.MapPath(@"/config/formEditor.config"); if (string.IsNullOrEmpty(path)) { return; } var configFile = new FileInfo(path); if (configFile.Exists == false) { return; } XDocument configXml = null; try { configXml = XDocument.Load(configFile.FullName); if (configXml.Root == null) { throw new ConfigurationErrorsException("Missing root node in configuration file."); } } catch (Exception ex) { // bad config XML Log.Error(ex, "Could not parse the configuration file."); return; } var customFields = configXml.Root.Element("CustomFields"); if (customFields != null) { CustomFields.AddRange( customFields.Elements("Field").Where(e => e.Attribute("type") != null).Select(e => new CustomField { Name = e.Attribute("name") != null ? e.Attribute("name").Value : "No name", Type = e.Attribute("type").Value } ) ); } var storage = configXml.Root.Element("Storage"); if (storage != null) { var index = storage.Element("Index"); if (index != null) { var indexTypeAttribute = index.Attribute("type"); if (indexTypeAttribute != null && string.IsNullOrEmpty(indexTypeAttribute.Value) == false) { try { var indexType = Type.GetType(indexTypeAttribute.Value); if (indexType == null) { throw new ConfigurationErrorsException(string.Format("Custom Index type \"{0}\" could not be found", indexTypeAttribute.Value)); } if (indexType.GetInterfaces().Contains(typeof(IIndex)) == false) { throw new ConfigurationErrorsException(string.Format("Custom Index type \"{0}\" does not implement IIndex interface", indexTypeAttribute.Value)); } // make sure the type has a constructor that takes an integer (content ID) as it's only parameter if (indexType.GetConstructors().Any(c => { var parameters = c.GetParameters(); return(parameters.Count() == 1 && parameters.First().ParameterType == typeof(int)); }) == false) { throw new ConfigurationErrorsException(string.Format("Custom Index type \"{0}\" does not contain a constructor that takes an integer (content ID) as it's only parameter", indexTypeAttribute.Value)); } IndexType = indexType; } catch (Exception ex) { Log.Error(ex, "Could not load custom Index type"); } } } } }
private void Load() { var path = HostingEnvironment.MapPath(@"/config/formEditor.config"); if (string.IsNullOrEmpty(path)) { return; } var configFile = new FileInfo(path); if (configFile.Exists == false) { return; } XDocument configXml = null; try { configXml = XDocument.Load(configFile.FullName); if (configXml.Root == null) { throw new ConfigurationErrorsException("Missing root node in configuration file."); } } catch (Exception ex) { // bad config XML Log.Error(ex, "Could not parse the configuration file."); return; } var customFields = configXml.Root.Element("CustomFields"); if (customFields != null) { CustomFields.AddRange( customFields.Elements("Field").Where(e => e.Attribute("type") != null).Select(e => new CustomField { Name = e.Attribute("name") != null ? e.Attribute("name").Value : "No name", Type = e.Attribute("type").Value, FixedValues = e.Attribute("fixedValues") != null && e.Attribute("fixedValues").Value == "true" } ) ); } var storage = configXml.Root.Element("Storage"); if (storage != null) { var index = storage.Element("Index"); if (index != null) { var type = ParseType(index, typeof(IIndex), t => t.GetConstructors().Any(c => { var parameters = c.GetParameters(); return(parameters.Count() == 1 && parameters.First().ParameterType == typeof(int)); }) ? null : string.Format("Custom Index type \"{0}\" does not contain a constructor that takes an integer (content ID) as it's only parameter", t) ); if (type != null) { IndexType = type; } } } var limitations = configXml.Root.Element("Limitations"); if (limitations != null) { var maxSubmissionsForCurrentUserHandler = limitations.Element("MaxSubmissionsForCurrentUserHandler"); if (maxSubmissionsForCurrentUserHandler != null) { var type = ParseType(maxSubmissionsForCurrentUserHandler, typeof(IMaxSubmissionsForCurrentUserHandler), t => t.GetConstructors().Any(c => c.GetParameters().Any() == false) ? null : string.Format("Custom MaxSubmissionsForCurrentUserHandler type \"{0}\" does not contain a parameterless constructor", t) ); if (type != null) { MaxSubmissionsForCurrentUserHandlerType = type; } } } }