public InstanceConfiguration(DataSetConfiguration dataSet, ObservableCollection <MessageHandlerConfiguration> availableHandlers, TraceEvent trace, Action onModification)
 {
     AvailableMessageHandlers  = availableHandlers;
     AssociatedMessageHandlers = new ObservableCollection <MessageHandlerConfiguration>(availableHandlers.Where <MessageHandlerConfiguration>(x => x.Associated(dataSet.AssociationName)).ToArray <MessageHandlerConfiguration>());
     DataSetConfiguration      = dataSet;
     PropertyChanged          += (x, y) => onModification();
 }
Exemplo n.º 2
0
        public void AfterCreationStateTest()
        {
            DataSetConfiguration _dataSet = new DataSetConfiguration();

            Assert.IsTrue(String.IsNullOrEmpty(_dataSet.Guid));
            Assert.AreEqual <Guid>(Guid.Empty, _dataSet.Id);
        }
 public DataSetConfigBuilder(
     DataSetConfiguration <TDb, TKey> dataSetConfig,
     INapDbConfigBuilder <TDb, TKey> parentBuilder)
 {
     _dataSetConfig = dataSetConfig;
     _parentBuilder = parentBuilder;
 }
Exemplo n.º 4
0
 public static void EntityConfigContainsConfigurableProperty <TDb, TKey>(DataSetConfiguration <TDb, TKey> config, PropertyInfo prop)
     where TDb : INapDb <TKey>
 {
     if (!config.PropertyConfigs.ContainsKey(prop.Name))
     {
         throw new NapDbException(typeof(TDb).Name, $"Dataset '{config.DataSet.Name}' doesn't contains property '{prop.Name}' or it's not configurable");
     }
 }
Exemplo n.º 5
0
        public void IdTest()
        {
            DataSetConfiguration _dataSet = new DataSetConfiguration();

            Assert.IsTrue(String.IsNullOrEmpty(_dataSet.Guid));
            Assert.AreEqual <Guid>(Guid.Empty, _dataSet.Id);
            Guid _newId = System.Guid.NewGuid();

            _dataSet.Id = _newId;
            Assert.IsFalse(String.IsNullOrEmpty(_dataSet.Guid));
            Assert.AreEqual <string>(XmlConvert.ToString(_newId), _dataSet.Guid);
        }
Exemplo n.º 6
0
 private static void CompareDataSetConfiguration(DataSetConfiguration source, DataSetConfiguration mirror)
 {
     Assert.AreEqual <string>(source.AssociationName, mirror.AssociationName);
     Assert.AreEqual <AssociationRole>(source.AssociationRole, mirror.AssociationRole);
     Assert.AreEqual <Guid>(source.ConfigurationGuid, mirror.ConfigurationGuid);
     Compare(source.ConfigurationVersion, mirror.ConfigurationVersion);
     Assert.AreEqual <string>(source.DataSymbolicName, mirror.DataSymbolicName);
     CompareArrays <FieldMetaData>(source.DataSet, mirror.DataSet, x => x.SymbolicName, CompareFieldMetaData);
     Assert.AreEqual <string>(source.Guid, mirror.Guid);
     Assert.AreEqual <Guid>(source.Id, mirror.Id);
     Assert.AreEqual <string>(source.InformationModelURI, mirror.InformationModelURI);
     Assert.AreEqual <double>(source.MaxBufferTime, mirror.MaxBufferTime);
     Assert.AreEqual <double>(source.PublishingInterval, mirror.PublishingInterval);
     Assert.AreEqual <string>(source.RepositoryGroup, mirror.RepositoryGroup);
     Compare(source.Root, mirror.Root);
 }
        internal void CreateConfiguration
            (XmlQualifiedName instanceType, string _associationName, XmlQualifiedName instanceSymbolicName, string fileName, Tuple <string, ushort, System.Guid> writerNameDataSetWriterIdPublisherId, ITraceSource _traceSource)
        {
            List <FieldMetaData> _lf = new List <FieldMetaData>();

            foreach (KeyValuePair <string, IVariable> _item in this)
            {
                if (_item.Value.ValueType.BuiltInType == BuiltInType.Null)
                {
                    continue;
                }
                FieldMetaData _field = new FieldMetaData()
                {
                    ProcessValueName = _item.Key,
                    SymbolicName     = _item.Key,
                    TypeInformation  = _item.Value.ValueType
                };
                _lf.Add(_field);
            }
            DataSetConfiguration _newDataSetConfiguration = new DataSetConfiguration()
            {
                AssociationName      = _associationName,
                AssociationRole      = AssociationRole.Producer,
                ConfigurationGuid    = System.Guid.NewGuid(),
                ConfigurationVersion = new ConfigurationVersionDataType()
                {
                    MajorVersion = 1, MinorVersion = 0
                },
                Id = System.Guid.NewGuid(),
                InformationModelURI = instanceSymbolicName.Namespace,
                DataSet             = _lf.ToArray(),
                DataSymbolicName    = _associationName,
                MaxBufferTime       = 1000,
                PublishingInterval  = 100,
                RepositoryGroup     = _associationName,
                Root = new NodeDescriptor()
                {
                    BindingDescription  = "Binding Description",
                    DataType            = instanceType,
                    InstanceDeclaration = false,
                    NodeClass           = InstanceNodeClassesEnum.Object,
                    NodeIdentifier      = instanceSymbolicName
                }
            };

            ConfigurationManagement.AddDataSetConfiguration(_newDataSetConfiguration, writerNameDataSetWriterIdPublisherId, fileName, fileName, _traceSource);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProducerAssociation"/> class.
 /// </summary>
 /// <param name="data">The semantic data description.</param>
 /// <param name="aliasName">Name of the alias - .</param>
 /// <param name="dataSet">The data set configuration.</param>
 /// <param name="bindingFactory">The binding factory.</param>
 /// <param name="encodingFactory">The encoding factory.</param>
 internal ProducerAssociation(ISemanticData data, string aliasName, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory)
     : base(data, dataSet.AssociationName)
 {
     m_ConfigurationVersion = dataSet.ConfigurationVersion;
     m_DataSetBindings      =
         dataSet.DataSet.Select <FieldMetaData, IProducerBinding>
             ((_fieldMetadata) =>
     {
         IProducerBinding _ret = _fieldMetadata.GetProducerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory);
         _ret.PropertyChanged += ProducerBinding_PropertyChanged;
         return(_ret);
     }).ToArray <IProducerBinding>();
     m_Timer = new Timer(1000)
     {
         AutoReset = true
     };
     m_Timer.Elapsed += M_Timer_Elapsed;
     m_Timer.Start();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Adds the data set configuration.
        /// </summary>
        /// <param name="newDataSetConfiguration">The new data set configuration.</param>
        /// <param name="inFileName">Name of the in file.</param>
        /// <param name="outFileName">Name of the out file.</param>
        /// <param name="writerId">The writer identifier.</param>
        /// <param name="traceSource">The trace source.</param>
        public static void AddDataSetConfiguration(this DataSetConfiguration newDataSetConfiguration, Tuple <string, ushort, Guid> writerId, string inFileName, string outFileName, ITraceSource traceSource)
        {
            traceSource.TraceData(TraceEventType.Verbose, 53, $"Entering {nameof(AddDataSetConfiguration)} method.");
            //open source configuration
            UANetworkingConfiguration <ConfigurationData> _newConfiguration = new UANetworkingConfiguration <ConfigurationData>();
            FileInfo _file2ReadConfiguration = new FileInfo(inFileName);

            _newConfiguration.ReadConfiguration(_file2ReadConfiguration);
            traceSource.TraceData(TraceEventType.Verbose, 53, $"I have read the configuration form the file {_file2ReadConfiguration.FullName}.");
            _newConfiguration.TraceSource = traceSource;
            ConfigurationData _currentConfiguration = _newConfiguration.CurrentConfiguration;
            // ddd new DataSetConfiguration
            List <DataSetConfiguration> _dataSets = _currentConfiguration.DataSets.ToList <DataSetConfiguration>();

            traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration contains {_dataSets.Count} item of type {nameof(DataSetConfiguration)}.");
            _dataSets.Add(newDataSetConfiguration);
            _currentConfiguration.DataSets = _dataSets.ToArray <DataSetConfiguration>();
            traceSource.TraceData(TraceEventType.Verbose, 53, $"New {nameof(DataSetConfiguration)} has been added to the copnfiguration.");
            // add new association for this DataSet in selected MessageWriterConfiguration
            ProducerAssociationConfiguration _newAssociation = new ProducerAssociationConfiguration()
            {
                AssociationName = newDataSetConfiguration.AssociationName,
                DataSetWriterId = writerId.Item2,
                FieldEncoding   = FieldEncodingEnum.VariantFieldEncoding,
                PublisherId     = writerId.Item3
            };
            MessageWriterConfiguration _selectedWriterConfiguration = _currentConfiguration.MessageHandlers
                                                                      .Where <MessageHandlerConfiguration>(_hn => (_hn.Name == writerId.Item1) && (_hn is MessageWriterConfiguration))
                                                                      .Cast <MessageWriterConfiguration>()
                                                                      .First <MessageWriterConfiguration>();
            List <ProducerAssociationConfiguration> _associationsInWriterConfiguration = _selectedWriterConfiguration.ProducerAssociationConfigurations.ToList <ProducerAssociationConfiguration>();

            _associationsInWriterConfiguration.Add(_newAssociation);
            _selectedWriterConfiguration.ProducerAssociationConfigurations = _associationsInWriterConfiguration.ToArray();
            traceSource.TraceData(TraceEventType.Verbose, 53, $"New {nameof (ProducerAssociationConfiguration)}  has been added to the {nameof(MessageWriterConfiguration)}[{writerId.Item1}].");
            //save the output file
            FileInfo _file2SaveConfiguration = new FileInfo(outFileName);

            _newConfiguration.SaveConfiguration(_file2SaveConfiguration);
            traceSource.TraceData(TraceEventType.Verbose, 53, $"Configuration has been saved to the file {_file2SaveConfiguration.FullName}.");
        }
Exemplo n.º 10
0
        private void NormalizSymbolicName(DataSetConfiguration dataSet, ILoggerFacade logger)
        {
            Warning _warning = null;

            if (string.IsNullOrEmpty(dataSet.DataSymbolicName))
            {
                dataSet.DataSymbolicName = GetUniqueName("DataSymbolicName");
                _warning = new Warning($"{nameof(dataSet.DataSymbolicName)} cannot be null or empty; replaced by {dataSet.DataSymbolicName}", Category.Warn, Priority.High);
            }
            else if (m_StringDictionary.ContainsKey(dataSet.DataSymbolicName))
            {
                string _oldDataSymbolicName = dataSet.DataSymbolicName;
                dataSet.DataSymbolicName = GetUniqueName(_oldDataSymbolicName);
                _warning = new Warning($"The {nameof(dataSet.DataSymbolicName)} = {_oldDataSymbolicName} must be unique; replaced by {dataSet.DataSymbolicName}", Category.Warn, Priority.High);
            }
            if (_warning != null)
            {
                m_WarningsList.Add(_warning);
                logger.Log($"Configuration error: {_warning}", Category.Warn, Priority.Medium);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsumerAssociation" /> class.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="dataSet">The members.</param>
 /// <param name="bindingFactory">The binding factory.</param>
 /// <param name="encodingFactory">The encoding factory.</param>
 internal ConsumerAssociation(ISemanticData data, DataSetConfiguration dataSet, IBindingFactory bindingFactory, IEncodingFactory encodingFactory) :
     base(data, dataSet.AssociationName)
 {
     m_DataSetBindings = dataSet.DataSet.Select <FieldMetaData, IConsumerBinding>(x => x.GetConsumerBinding4DataMember(dataSet.RepositoryGroup, bindingFactory, encodingFactory)).ToArray <IConsumerBinding>();
 }
 private void TestDataSet(DataSetConfiguration dataSetConfiguration)
 {
     RepositoryGroupDictionary.Add(dataSetConfiguration.RepositoryGroup, dataSetConfiguration);
     TestConfiguration(dataSetConfiguration.DataSet);
 }
 public IInstanceConfiguration GetIInstanceConfiguration(DataSetConfiguration dataSet, ObservableCollection <MessageHandlerConfiguration> availableHandlers, TraceEvent trace, Action onModification)
 {
     return(new InstanceConfiguration(dataSet, availableHandlers, trace, onModification));
 }
 private void TestDataSets(DataSetConfiguration dataSetConfiguration)
 {
     Assert.IsNotNull(dataSetConfiguration.DataSet);
     TestMembers(dataSetConfiguration.DataSet);
 }