Exemple #1
0
        public async Task Execute(IJobExecutionContext context)
        {
            _logger.Info("Start StaticJob.Execute()");
            try
            {
                IAppSettings       appSettings       = new AppSettings("appSettings.json");
                IJsonSerializer    jsonSerializer    = new JsonSerializer();
                IRestClientFactory restClientFactory = new RestClientFactory();
                var serverConnector = new ServerConnector(
                    null,
                    appSettings,
                    jsonSerializer,
                    restClientFactory);

                var stableCollector =
                    new StableDeviceCollector(
                        new CpuCollector(null),
                        new MemoryCollector(null),
                        new NetworkCollector(null),
                        new DriveCollector(null),
                        new OsCollector(null),
                        new SoftwareCollector(null));

                var stableDeviceInfo = stableCollector.Read();

                await serverConnector.Send(await stableDeviceInfo);
            }
            catch (Exception ex)
            {
                _logger.Error($"StaticJob.Execute(): {ex.Message}");
                _logger.Error($"Stack Trace: {ex.StackTrace}");
            }
        }
Exemple #2
0
        public async Task Execute(IJobExecutionContext context)

        {
            await Console.Out.WriteLineAsync("PingerJob is executing.");

            IAppSettings       appSettings       = new AppSettings("appSettings.json");
            IJsonSerializer    jsonSerializer    = new JsonSerializer();
            IRestClientFactory restClientFactory = new RestClientFactory();
            var serverConnector = new ServerConnector(
                null,
                appSettings,
                jsonSerializer,
                restClientFactory);
            var response    = serverConnector.SendPing().Result;
            var body        = response.Content;
            var commands    = JsonConvert.DeserializeObject <List <CommandInfo> >(body);
            var pingResults = await ProcessTasksAsync(commands); //.ConfigureAwait(false);

            if (pingResults.Count > 0)
            {
                await serverConnector.Send(pingResults);
            }
            await Console.Out.WriteLineAsync("PingerJob is finished.");
        }