Esempio n. 1
0
        public PSFileService(ConfigurationService config, ILogger logger)
        {
            _logger = logger.ForContext <PSFileService>();

            string scriptPath = config.GetSetting("scriptpath", Path.GetDirectoryName(typeof(PSExecutor).Assembly.Location));

            _scriptPaths = scriptPath.Split(',', ';')
                           .Where(x => !string.IsNullOrWhiteSpace(x))
                           .Select(x => x.Trim())
                           .ToArray();

            _logger.Information("{PathCount} script paths configured", _scriptPaths.Length);
        }
Esempio n. 2
0
        public IoTDevice(PSExecutor psExecutor, ConfigurationService config, ILogger logger)
        {
            _logger     = logger.ForContext <IoTDevice>();
            _psExecutor = psExecutor;

            _handlers = new Dictionary <string, MethodCallback>
            {
                { nameof(ListScripts), ListScripts },
                { nameof(ExecuteScript), ExecuteScriptAsyncWrapper }
            };

            string connectionString = config.GetSetting("iothub");

            _deviceClient = DeviceClient.CreateFromConnectionString(connectionString);
        }
Esempio n. 3
0
        public IoTHubDevice(PSExecutor psExecutor, ConfigurationService config, ILogger logger)
        {
            _logger     = logger.ForContext <IoTHubDevice>();
            _psExecutor = psExecutor;

            _handlers = new Dictionary <string, MethodCallback>
            {
                { nameof(ListScripts), ListScripts },
                { nameof(ExecuteScript), ExecuteScriptAsyncWrapper }
            };

            string connectionString = config.GetSetting("iothub");

            _deviceClient = DeviceClient.CreateFromConnectionString(connectionString);

            IRetryPolicy retryPolicy = new ExponentialBackoff(int.MaxValue,
                                                              TimeSpan.FromSeconds(1),
                                                              TimeSpan.FromSeconds(30),
                                                              TimeSpan.FromSeconds(1));

            _deviceClient.SetRetryPolicy(retryPolicy);
        }
Esempio n. 4
0
 public PSExecutor(ConfigurationService config, ILogger logger)
 {
     _scriptPath = config.GetSetting("scriptpath", Path.GetDirectoryName(typeof(PSExecutor).Assembly.Location));
     _logger     = logger.ForContext <PSExecutor>();
 }