public DiagnosticsEvents( ILogDiagnostics logDiagnosticsService, IServicesConfig servicesConfig) { this.logDiagnosticsService = logDiagnosticsService; this.servicesConfig = servicesConfig; }
public Config(IConfigData configData) { this.Port = configData.GetInt(PORT_KEY); var storageType = configData.GetString(STORAGE_TYPE_KEY).ToLowerInvariant(); var documentDbConnString = configData.GetString(DOCUMENT_DB_CONNECTION_STRING_KEY); if (storageType == "documentdb" && (string.IsNullOrEmpty(documentDbConnString) || documentDbConnString.StartsWith("${") || documentDbConnString.Contains("..."))) { // In order to connect to the storage, the service requires a connection // string for Document Db. The value can be found in the Azure Portal. // The connection string can be stored in the 'appsettings.ini' configuration // file, or in the PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING environment variable. // When working with VisualStudio, the environment variable can be set in the // WebService project settings, under the "Debug" tab. throw new Exception("The service configuration is incomplete. " + "Please provide your DocumentDb connection string. " + "For more information, see the environment variables " + "used in project properties and the 'documentdb_connstring' " + "value in the 'appsettings.ini' configuration file."); } this.ServicesConfig = new ServicesConfig { StorageType = storageType, DocumentDbConnString = documentDbConnString, DocumentDbDatabase = configData.GetString(DOCUMENT_DB_DATABASE_KEY), DocumentDbCollection = configData.GetString(DOCUMENT_DB_COLLECTION_KEY), DocumentDbRUs = configData.GetInt(DOCUMENT_DB_RUS_KEY), }; }
public Storage( IStorageAdapterClient client, IServicesConfig config) { this.client = client; this.config = config; }
public ActionManager(ILogger logger, IServicesConfig servicesConfig, IHttpClient httpClient) { this.emailActionExecutor = new EmailActionExecutor( servicesConfig, httpClient, logger); }
public DeviceSimulationClient( IHttpClientWrapper httpClient, IServicesConfig config) { this.httpClient = httpClient; this.serviceUri = config.DeviceSimulationApiUrl; }
public TelemetryClient CreateTelemetryClient(IServicesConfig config) { return(new TelemetryClient { InstrumentationKey = config.AppInsightsInstrumentationKey }); }
public DiagnosticsLogger(IHttpClient httpClient, IServicesConfig servicesConfig, ILogger log) { this.httpClient = httpClient; this.servicesConfig = servicesConfig; this.log = log; this.diagnosticsEndpoint = this.servicesConfig.DiagnosticsEndpointUrl; }
public AlarmsByRuleControllerTest() { ConfigData configData = new ConfigData(new Logger(Uptime.ProcessId, LogLevel.Info)); Config config = new Config(configData); IServicesConfig servicesConfig = config.ServicesConfig; Mock <IStorageAdapterClient> storageAdapterClient = new Mock <IStorageAdapterClient>(); this.log = new Mock <ILogger>(); this.storage = new StorageClient(servicesConfig, this.log.Object); string dbName = servicesConfig.AlarmsConfig.DocumentDbDatabase; string collName = servicesConfig.AlarmsConfig.DocumentDbCollection; this.storage.CreateCollectionIfNotExistsAsync(dbName, collName); this.sampleAlarms = this.getSampleAlarms(); foreach (Alarm sampleAlarm in this.sampleAlarms) { this.storage.UpsertDocumentAsync( dbName, collName, this.AlarmToDocument(sampleAlarm)); } Alarms alarmService = new Alarms(servicesConfig, this.storage, this.log.Object); Rules rulesService = new Rules(storageAdapterClient.Object, this.log.Object, alarmService); this.controller = new AlarmsByRuleController(alarmService, rulesService, this.log.Object); }
public ConfigService( IServicesConfig config, IHttpClientWrapper httpClient) { this.url = $"{config.ConfigServiceUri}/devicegroupfilters"; this.httpClient = httpClient; }
public Agent( IServicesConfig servicesConfig, IAppConcurrencyConfig appConcurrencyConfig, ISimulations simulations, IFactory factory, ILogger logger, IDiagnosticsLogger diagnosticsLogger) { this.appConcurrencyConfig = appConcurrencyConfig; this.simulations = simulations; this.factory = factory; this.log = logger; this.logDiagnostics = diagnosticsLogger; this.startingOrStopping = false; this.running = false; this.deviceTwinEnabled = servicesConfig.DeviceTwinEnabled; this.runningToken = new CancellationTokenSource(); this.lastPolledTime = DateTimeOffset.UtcNow; this.lastPrintStatisticsTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); this.lastSaveStatisticsTime = DateTimeOffset.UtcNow; this.simulationManagers = new ConcurrentDictionary <string, ISimulationManager>(); this.deviceStateActors = new ConcurrentDictionary <string, IDeviceStateActor>(); this.deviceConnectionActors = new ConcurrentDictionary <string, IDeviceConnectionActor>(); this.deviceTelemetryActors = new ConcurrentDictionary <string, IDeviceTelemetryActor>(); this.devicePropertiesActors = new ConcurrentDictionary <string, IDevicePropertiesActor>(); }
// Check whether the simulation is running with the conn string in the configuration private async Task <bool> IsPreprovisionedIoTHubInUseAsync(IServicesConfig servicesConfig, IIotHubConnectionStringManager connectionStringManager) { var csInUse = (await connectionStringManager.GetConnectionStringAsync()).ToLowerInvariant().Trim(); var csInConf = servicesConfig?.IoTHubConnString?.ToLowerInvariant().Trim(); return(csInUse == csInConf); }
public JavascriptInterpreter( IServicesConfig config, ILogger logger) { this.folder = config.DeviceModelsScriptsFolder; this.log = logger; }
// Check whether the simulation is running with the conn string in the configuration private bool IsPreprovisionedIoTHubInUse(IServicesConfig servicesConfig, IIotHubConnectionStringManager connectionStringManager) { var csInUse = connectionStringManager.GetIotHubConnectionString().ToLowerInvariant().Trim(); var csInConf = servicesConfig?.IoTHubConnString?.ToLowerInvariant().Trim(); return(csInUse == csInConf); }
public Config(IConfigData configData) { this.Port = configData.GetInt(PortKey); this.ServicesConfig = new ServicesConfig { PcsConfigUrl = configData.GetString(PCS_CONFIG_URL), SolutionType = configData.GetString(PCS_SOLUTION_TYPE), DeploymentId = configData.GetString(PCS_DEPLOYMENT_ID), SubscriptionId = configData.GetString(PCS_SUBSCRIPTION_ID), CloudType = configData.GetString(PCS_CLOUD_TYPE), IoTHubName = configData.GetString(PCS_IOTHUB_NAME), SolutionName = configData.GetString(PCS_SOLUTION_NAME), UserConsentPollingIntervalSecs = configData.GetInt(USER_CONSENT_POLLING_INTERVAL_KEY, 300), AppInsightsInstrumentationKey = configData.GetString(APPINSIGHTS_INSTRUMENTATION_KEY) }; this.ClientAuthConfig = new ClientAuthConfig { // By default CORS is disabled CorsWhitelist = configData.GetString(CORS_WHITELIST_KEY, string.Empty), // By default Auth is required AuthRequired = configData.GetBool(AUTH_REQUIRED_KEY, true), // By default auth type is JWT AuthType = configData.GetString(AUTH_TYPE_KEY, "JWT"), // By default the only trusted algorithms are RS256, RS384, RS512 JwtAllowedAlgos = configData.GetString(JWT_ALGOS_KEY, "RS256,RS384,RS512").Split(','), JwtIssuer = configData.GetString(JWT_ISSUER_KEY, String.Empty), JwtAudience = configData.GetString(JWT_AUDIENCE_KEY, String.Empty), // By default the allowed clock skew is 2 minutes JwtClockSkew = TimeSpan.FromSeconds(configData.GetInt(JWT_CLOCK_SKEW_KEY, 120)), }; }
public DeviceTelemetryClient( IHttpClientWrapper httpClient, IServicesConfig config) { this.httpClient = httpClient; this.serviceUri = config.TelemetryApiUrl; }
/// <summary> /// Create controller with service. /// </summary> /// <param name="certificateRequest"></param> /// <param name="servicesConfig"></param> public CertificateRequestController( ICertificateRequest certificateRequest, IServicesConfig servicesConfig) { _certificateRequest = certificateRequest; _servicesConfig = servicesConfig; }
public Rules( IHttpClientWrapper httpClient, IServicesConfig config) { this.httpClient = httpClient; this.uri = $"{config.MonitoringRulesUrl}/rules"; }
public Users( IServicesConfig config, ILogger log) { this.config = config; this.log = log; }
public Config(IConfigData configData) { IoTHubConfig = new IoTHubConfig { ConnectionConfig = new ConnectionConfig { HubName = configData.GetString(HubNameKey), HubEndpoint = configData.GetString(HubEndpointKey), AccessConnString = configData.GetString(AccessConnStringKey) }, StreamingConfig = new StreamingConfig { ConsumerGroup = configData.GetString(ConsumerGroupKey), ReceiveBatchSize = configData.GetInt(ReceiveBatchSizeKey), ReceiveTimeout = configData.GetTimeSpan(ReceiveTimeoutKey) }, CheckpointingConfig = new CheckpointingConfig { Frequency = configData.GetTimeSpan(FrequencyKey), CountThreshold = configData.GetInt(CountThresholdKey), TimeThreshold = configData.GetTimeSpan(TimeThresholdKey), StorageConfig = new CheckpointingStorageConfig { BackendType = configData.GetString(BackendTypeKey), Namespace = configData.GetString(NamespaceKey), AzureBlobConfig = new CheckpointingStorageBlobConfig { Protocol = configData.GetString(ProtocolKey), Account = configData.GetString(AccountKey), Key = configData.GetString(KeyKey), EndpointSuffix = configData.GetString(EndpointSuffixKey) } } } }; ServicesConfig = new ServicesConfig { MonitoringRulesUrl = configData.GetString(MonitoringRulesUrlKey), DeviceGroupsUrl = configData.GetString(DeviceGroupsUrlKey), DevicesUrl = configData.GetString(DevicesUrlKey), MessagesStorageServiceConfig = new StorageServiceConfig { StorageType = configData.GetString(MessagesStorageTypeKey), DocumentDbConnString = configData.GetString(MessagesDocDbConnStringKey), DocumentDbDatabase = configData.GetString(MessagesDocDbDatabaseKey), DocumentDbCollection = configData.GetString(MessagesDocDbCollectionKey), DocumentDbRUs = configData.GetInt(MessagesDocDbRUsKey) }, AlarmsStorageServiceConfig = new StorageServiceConfig { StorageType = configData.GetString(AlarmsStorageTypeKey), DocumentDbConnString = configData.GetString(AlarmsDocDbConnStringKey), DocumentDbDatabase = configData.GetString(AlarmsDocDbDatabaseKey), DocumentDbCollection = configData.GetString(AlarmsDocDbCollectionKey), DocumentDbRUs = configData.GetInt(AlarmsDocDbRUsKey) } }; }
public PreprovisionedIotHub( IServicesConfig config, ILogger logger) { this.log = logger; this.connectionString = config.IoTHubConnString; this.setupDone = false; }
public static IApplicationsDatabase Create( ILifetimeScope scope, IServicesConfig config, IDocumentDBRepository db, ILogger logger) { return(new CosmosDBApplicationsDatabase(scope, config, db, logger)); }
public Agent(IDevices devices, IServicesConfig config) { this._devices = devices; this._config = config; var system = ActorSystem.Create("sensewire"); _deviceManager = system.ActorOf(Props.Create <DeviceManager>(), "device-manager"); }
public IotHubConnectionStringManager( IServicesConfig config, ILogger logger) { this.config = config; this.connStringFilePath = config.IoTHubDataFolder + CONNSTRING_FILE_NAME; this.log = logger; }
public JavascriptInterpreter( IDeviceFileManager deviceFileManager, IServicesConfig config, ILogger logger) { this.log = logger; this.deviceFileManager = deviceFileManager; }
public ReplayFileService( IServicesConfig config, IEngines engines, ILogger logger) { this.replayFilesStorage = engines.Build(config.ReplayFilesStorage); this.log = logger; }
public StatusService( ILogger logger, IServicesConfig servicesConfig ) { this.log = logger; this.servicesConfig = servicesConfig; }
public ActionsEventProcessorFactory( ILogger logger, IServicesConfig servicesConfig, IHttpClient httpClient) { this.logger = logger; this.actionManager = new ActionManager(logger, servicesConfig, httpClient); }
public DiagnosticsEventsService( IDiagnosticsClient diagnosticsClient, IServicesConfig servicesConfig, ILogger logger) { this.log = logger; this.diagnosticsClient = diagnosticsClient; this.servicesConfig = servicesConfig; }
public StockDeviceModels( IServicesConfig config, ILogger logger) { this.config = config; this.log = logger; this.deviceModelFiles = null; this.deviceModels = null; }
public DeviceProperties( IServicesConfig servicesConfig, ILogger logger) { this.log = logger; this.deviceTwinEnabled = servicesConfig.DeviceTwinEnabled; this.deviceId = string.Empty; this.isRegistered = false; }