Пример #1
0
        private void SinkFromFactory(SinkData sink)
        {
            LogSinkFactory factory = new LogSinkFactory(Context);
            ILogSink       output  = factory.CreateSink(sink.Name);

            Assert.IsNotNull(output);
        }
Пример #2
0
        protected override Type GetConfigurationType(string sinkName)
        {
            LoggingConfigurationView loggingConfigurationView = (LoggingConfigurationView)CreateConfigurationView();
            SinkData data = loggingConfigurationView.GetSinkData(sinkName);

            return(GetType(data.TypeName));
        }
Пример #3
0
 /// <summary>
 /// Creates node with specified configuration data.
 /// </summary>
 protected SinkNode(SinkData sinkData) : base()
 {
     if (sinkData == null)
     {
         throw new ArgumentNullException("sinkData");
     }
     this.sinkData = sinkData;
 }
Пример #4
0
        public SinkData AllocateSink(MyDefinitionId id)
        {
            var td   = Type(id);
            var sink = new SinkData(this, id);

            td.Sinks.Add(sink);
            return(sink);
        }
Пример #5
0
        private MsmqSinkData GetMsmqSinkDataFromCursor()
        {
            SinkData sinkData = loggingConfigurationView.GetSinkData(ConfigurationName);

            ArgumentValidation.CheckExpectedType(sinkData, typeof(MsmqSinkData));

            return((MsmqSinkData)sinkData);
        }
Пример #6
0
        private EmailSinkData GetEmailSinkDataFromView()
        {
            SinkData sinkData = loggingConfigurationView.GetSinkData(ConfigurationName);

            ArgumentValidation.CheckExpectedType(sinkData, typeof(EmailSinkData));

            return((EmailSinkData)sinkData);
        }
Пример #7
0
        private DatabaseSink CreateSink(SinkData sinkData)
        {
            DatabaseSink databaseSink = new DatabaseSink();

            databaseSink.Initialize(new TestLoggingConfigurationView(sinkData, Context));

            return(databaseSink);
        }
Пример #8
0
 public override void OnBeforeRemovedFromContainer()
 {
     if (_operationalSink != null)
     {
         FreeSink(_operationalSink);
         _operationalSink = null;
     }
     base.OnBeforeRemovedFromContainer();
     _resourceSink.OnBeforeRemovedFromContainer();
 }
Пример #9
0
 public override void OnAddedToContainer()
 {
     base.OnAddedToContainer();
     _resourceSink.OnAddedToContainer();
     if (Entity is IMyFunctionalBlock)
     {
         _operationalSink = AllocateSink(ConstantDefs.ElectricityId);
         _operationalSink.RequiredPower = _operationalSink.MaxPower = 50e-3f; // 50 W
     }
 }
Пример #10
0
        public void FreeSink(SinkData sink)
        {
            var td = Type(sink.Id);

            td.Sinks.Remove(sink);
            if (td.Sinks.Count == 0)
            {
                _sinks.Remove(sink.Id);
            }
        }
Пример #11
0
        /// <summary>
        /// Gets the <see cref="SinkData"></see> associated with the named logging sink
        /// </summary>
        /// <param name="sinkName">Name of the sink as defined in configuration</param>
        /// <returns><see cref="SinkData"></see> defined for named logging sink</returns>
        public virtual SinkData GetSinkData(string sinkName)
        {
            ArgumentValidation.CheckForNullReference(sinkName, "sinkName");
            ArgumentValidation.CheckForEmptyString(sinkName, "sinkName");

            DistributorSettings settings = GetDistributorSettings();

            SinkData sinkData = settings.SinkDataCollection[sinkName];

            if (null == sinkData)
            {
                throw new ConfigurationException(SR.ExceptionNoSinkDefined(sinkName));
            }
            return(sinkData);
        }
 public TestLogSinkConfigurationView(SinkData data) : base(new ConfigurationContext(new ConfigurationDictionary()))
 {
     this.data = data;
 }
Пример #13
0
 public TestLoggingConfigurationView(SinkData data, ConfigurationContext context) : base(context)
 {
     this.data = data;
 }
Пример #14
0
        public void UpdateIncomingMessageSinksCompanyServiceNetworkTest()
        {
            var managementClient = new ManagementClient(ManagementApi);

            managementClient.User.Register(new Register
            {
                Email    = Guid.NewGuid() + "@test.hu",
                Name     = "test user",
                Password = "******"
            });

            var companyId = managementClient.Company.Create(new Company {
                Name = "company"
            });
            var serviceId = managementClient.Service.Create(new Service {
                CompanyId = companyId, Name = "árvíztűrő tükörfúrógép"
            });
            var networkId = managementClient.Network.Create(new Network {
                CompanyId = companyId, ServiceId = serviceId, Name = "árvíztűrő tükörfúrógép"
            });

            var telemetryDataSinkParameters = new List <TelemetryDataSinkParameters>
            {
                new TelemetryDataSinkParameters
                {
                    SinkName   = SinkData,
                    Parameters = new Dictionary <string, string>()
                },
                new TelemetryDataSinkParameters
                {
                    SinkName   = SinkTimeSeries,
                    Parameters = new Dictionary <string, string>()
                }
            };

            managementClient.Company.UpdateIncomingTelemetryDataSinks(companyId, telemetryDataSinkParameters);
            managementClient.Service.UpdateIncomingTelemetryDataSinks(serviceId, telemetryDataSinkParameters);
            managementClient.Network.UpdateIncomingTelemetryDataSinks(networkId, telemetryDataSinkParameters);

            var company = managementClient.Company.Get(companyId);
            var service = managementClient.Service.Get(serviceId);
            var network = managementClient.Network.Get(networkId);

            Assert.AreEqual(2, company.TelemetryDataSinkSettings.Incoming.Count);
            Assert.IsTrue(company.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkData.ToLowerInvariant()));
            Assert.IsTrue(company.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkTimeSeries.ToLowerInvariant()));

            Assert.AreEqual(2, service.TelemetryDataSinkSettings.Incoming.Count);
            Assert.IsTrue(service.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkData.ToLowerInvariant()));
            Assert.IsTrue(service.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkTimeSeries.ToLowerInvariant()));

            Assert.AreEqual(2, network.TelemetryDataSinkSettings.Incoming.Count);
            Assert.IsTrue(network.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkData.ToLowerInvariant()));
            Assert.IsTrue(network.TelemetryDataSinkSettings.Incoming.Any(i => i.SinkName == SinkTimeSeries.ToLowerInvariant()));
        }