public async Task Invoke()
        {
            var executionList = new List <DateTime>();
            var times         = _apexConfigs.Apex1.ALK.Split(",");

            if (times.Length == 1 & string.IsNullOrEmpty(times[0]))
            {
                _logger.LogInformation($"Apex1 Alk test schedule not configured");
                return;
            }
            foreach (var time in times)
            {
                var splitTime = time.Split(":");
                if (splitTime.Length == 2)
                {
                    executionList.Add(new DateTime(1, 1, 1, Convert.ToInt32(splitTime[0]), Convert.ToInt32(splitTime[1]), 0, 0));
                }
            }

            var currentTime = DateTime.Now;

            if (executionList.Any(p => p.Hour == currentTime.Hour && p.Minute == currentTime.Minute))
            {
                _logger.LogInformation($"Apex1 Alk test requested {DateTime.Now}");
                _apexService.SetContext(_apexConfigs.Apex1);
                await _apexService.RequestALKTest();

                return;
            }

            _logger.LogInformation($"RSM650AlkSchedule invoke completed {DateTime.Now.ToShortDateString()}:{DateTime.Now.ToShortTimeString()}");
            await Task.CompletedTask;
        }
Example #2
0
        public async Task Invoke()
        {
            if (!string.IsNullOrEmpty(_apexConfigs.Apex1.ALK))
            {
                var apex1Times = _apexConfigs.Apex1.ALK.Split(',');
                if (apex1Times.Contains(DateTime.Now.Second.ToString()))
                {
                    Console.WriteLine($"Apex1 yes {DateTime.Now}");
                    _apexService.SetContext(_apexConfigs.Apex1);
                    await _apexService.RequestALKTest();
                }
            }

            if (!string.IsNullOrEmpty(_apexConfigs.Apex2.ALK))
            {
                var apex2Times = _apexConfigs.Apex2.ALK.Split(',');
                if (apex2Times.Contains(DateTime.Now.Second.ToString()))
                {
                    Console.WriteLine($"Apex2 yes {DateTime.Now}");
                }
            }

            Console.WriteLine(DateTime.Now);
            await Task.CompletedTask;
        }