private void PopulatePublicFields(ConfigData configData) { var publicFieldConfigs = configData.GetConfigSections(Constants.CustomFieldConfig); foreach (var pubConfig in publicFieldConfigs) { var name = pubConfig.RequiredValue(Constants.CustomFieldName); var label = pubConfig.Value(Constants.CustomFieldLabel); var type = pubConfig.Value(Constants.CustomFieldType); var searchable = pubConfig.BoolValue(Constants.CustomFieldSearchable, false); var pub = pubConfig.BoolValue(Constants.CustomFieldPublic, false); var field = new CustomFieldDefinition(name, type) { Label = label, Searchable = searchable, Public = pub }; customFields.Add(field); } }
/// <summary> /// Populate the set of operations which this station supports. /// Required: opCode /// Optional: opLabel (defaults to opCode) /// Optional: operandCount (defaults to zero) /// </summary> /// <param name="configData">ConfigData for this station</param> protected virtual void PopulateOperations(ConfigData configData) { operations = new List<OperationDefinition>(Criterion.Definitions); // start with copy of the standard operations // add the custom operations var opConfig = configData.GetConfigSections(Constants.Operation); foreach (var cd in opConfig) { var code = cd.RequiredValue(Constants.OperationCode); var operandCount = cd.IntValue(Constants.OperationOperandCount); if (!operandCount.HasValue) operandCount = 0; var label = cd.Value(Constants.OperationLabel); if (label == null) label = code; operations.Add(new OperationDefinition(code, operandCount.Value, label)); } }
protected virtual List<StationEntity> LoadStationEntities(ConfigData configData) { var entitiesList = new List<StationEntity>(); var entityConfigs = configData.GetConfigSections(Constants.StationEntity); foreach (var entityConfig in entityConfigs) { var entityName = entityConfig.RequiredValue(Constants.StationEntityName); var entity = new StationEntity(entityName); var entityLocation = entityConfig.Value(Constants.StationEntityLocation); entity.Location = (entityLocation); var fieldConfigs = entityConfig.GetConfigSections(Constants.StationField); foreach (var fieldConfig in fieldConfigs) { var field = new StationField(fieldConfig.RequiredValue(Constants.StationFieldName)); field.Type = (fieldConfig.RequiredValue(Constants.StationFieldType)); // if location is empty, just use field name as default location var location = fieldConfig.Value(Constants.StationFieldLocation); if (location == null) location = field.Name; field.Location = (location); field.Level = (fieldConfig.IntValue(Constants.StationFieldLevel)); // TODO set other field properties - referredEntity, referredEntityField entity.AddField(field); } var sortField = entityConfig.Value(Constants.StationEntitySortField); if (sortField != null) { entity.SortField = (sortField); var sortOrder = entityConfig.Value(Constants.StationEntitySortOrder); if (sortOrder != null && sortOrder.ToUpper().StartsWith("DESC")) { entity.DescendingSort = (true); } } entitiesList.Add(entity); } return entitiesList; }
/// <summary> /// initialization using data in ConfigData object. /// This should be called immediately after the constructor. /// Each Station subclass should call base.initialize(configData, memory) from its own initialize() method. /// </summary> public override void Initialize(ConfigData configData, InstanceMemory memory, Resolver commandResolver) { base.Initialize(configData, memory, commandResolver); // do any other Station specific initialization here HomePath = configData.RequiredValue("homePath"); if (!(HomePath.EndsWith(@"\") || HomePath.EndsWith(@"/"))) HomePath += "/"; User = configData.Value("user"); Password = configData.Value("password"); IncludeSubfolders = configData.BoolValue("includeSubfolders", false); string possibleError; var unc = ConnectUnc(out possibleError); try { EntityName = configData.RequiredValue("entityName"); List<ConfigData> folderConfigs = configData.GetConfigSections("folder"); if (folderConfigs.Count == 0) throw new Exception("No folders configured for station " + this.GetType()); foreach (ConfigData folderConfig in folderConfigs) { string name = folderConfig.RequiredValue("name"); string status = folderConfig.Value("status"); if (status == null) status = name; string path = HomePath + name; if (Directory.Exists(path)) { Folder f = new Folder(name, status, path); Folders.Add(f); } else { Console.Error.WriteLine("WARNING: Directory not found: {0}", path); } } if (Folders.Count == 0) { string error = "No folders accessible for station " + this.GetType(); if (possibleError != null) error += "; " + possibleError; throw new Exception(error); } List<ConfigData> extConfigs = configData.GetConfigSections("extension"); foreach (ConfigData extConfig in extConfigs) { string ext = extConfig.Value(); if (string.IsNullOrEmpty(ext)) { throw new Exception("Property is empty: extension"); } Extensions.Add(ext); } } finally { if (unc != null) unc.Dispose(); } }
private void ConfigureStations(InstanceMemory mem, ConfigData config) { // for each station element in the configStream file, // create a station and add it to the stations list List<ConfigData> stationConfigs = config.GetConfigSections(Constants.StationConfig); int index = 0; foreach (ConfigData sConfig in stationConfigs) { ConfiguredStation cs = new ConfiguredStation(index++, sConfig); cs.Description = sConfig.Value(Constants.StationDescription); if (string.IsNullOrWhiteSpace(cs.Description)) cs.Description = sConfig.Value(Constants.StationClassName); configuredStations.Add(cs); // if the Station is configured to be inactive, don't initialize bool active = sConfig.BoolValue(Constants.ActiveStation, true); if (active) { InitializeStation(mem, cs); } } }
private void ConfigureCommands(ConfigData config) { // for each command element in the configStream file, // create a StationCommand and add it to the Commands list List<ConfigData> commandConfigs = config.GetConfigSections(Constants.CommandConfig); int index = 0; foreach (ConfigData cmdConfig in commandConfigs) { ConfiguredStationCommand cc = new ConfiguredStationCommand(index++); cc.Description = cmdConfig.Value(Constants.CommandDescription); if (string.IsNullOrWhiteSpace(cc.Description)) cc.Description = cmdConfig.Value(Constants.CommandClassName); configuredCommands.Add(cc); InitializeCommand(cmdConfig, cc); //// if the Command is configured to be inactive, don't initialize //String active = cmdConfig.value(Constants.ACTIVE_STATION); //if (active == null || !active.Equals(Constants.FALSE, StringComparison.InvariantCultureIgnoreCase)) //{ // InitializeCommand(cmdConfig, cc); //} } }