コード例 #1
0
ファイル: SensorTelemetry.cs プロジェクト: lulzzz/NucuCar
 public SensorTelemetry(ILogger <SensorTelemetry> logger, IOptions <TelemetryConfig> options)
 {
     if (options.Value.ServiceEnabled)
     {
         Publisher = TelemetryPublisherFactory.Create(options.Value.Publisher, options.Value.ConnectionString,
                                                      "NucuCar.Sensors", logger);
     }
     else
     {
         Publisher = null;
     }
 }
コード例 #2
0
        public static async Task RunAzurePublisherTelemetryTest(AzureTelemetryPublishOptions opts)
        {
            var logger = LoggerFactory.Create(builder => { builder.AddConsole(); })
                         .CreateLogger <AzureTelemetryPublishCmd>();

            var telemetryPublisher = TelemetryPublisherFactory.Create(TelemetryPublisherType.Azure,
                                                                      opts.PublisherConnectionString, "NucuCar.TestClient", logger);

            var anonymousTelemeter =
                new DummyTelemeter(
                    JsonConvert.DeserializeObject <Dictionary <string, object> >(opts.PublisherJsonMessage));


            logger.LogInformation($"Publishing message: {opts.PublisherJsonMessage}");
            telemetryPublisher.RegisterTelemeter(anonymousTelemeter);
            await telemetryPublisher.PublishAsync(CancellationToken.None);
        }