private async Task RunTaskForTargetDevices(TargetDevice targetDevice) { targetBaseUrl = targetDevice.HostName; thermoDataRequester = RequestFactory.CreateRestService(targetBaseUrl, _logger); var checkpointSourceFileName = targetDevice.CheckPointFileName; var checkPoint = await _checkPointLogger.ReadCheckPoint(checkpointSourceFileName); checkPoint.LastSequence = checkPoint.LastSequence == 0 ? 1 : checkPoint.LastSequence; var attendanceRequestInfo = new AttendanceRequest { StartId = checkPoint.LastSequence, ReqCount = targetDevice.AttendanceRequestCount == 0 ? 10 : targetDevice.AttendanceRequestCount, NeedImg = targetDevice.NeedImage }; // parse request var attendanceRequest = RequestFactory.CreatePostBodyRequest( targetDevice.AttendanceUrl, attendanceRequestInfo); _logger.LogInformation($"Executing ThermoDataLogic Main Component {DateTimeOffset.Now}"); // Get data var result = await thermoDataRequester. GetAttendanceRecordAsync <AttendanceResponse>(attendanceRequest); var attendanceRecResult = MessageConverter.DeSerializeCamelCase <AttendanceResponse>(result.Content); if (attendanceRecResult != null && attendanceRecResult.Command == 523) { _logger.LogError($"Invalida requrest made to the server: Status 523. {targetDevice.HostName}: {DateTime.Now}. Maybe your request count is zero. Please ensure it is atleast 1."); } else if (attendanceRecResult != null && attendanceRecResult.Data != null) { await this._channelMessageSender.SendMessagesToAzureServiceBus(attendanceRecResult); // Update configuration checkPoint.LastSequence += attendanceRecResult.RecordCount; checkPoint.LastUpdate = DateTime.UtcNow; // Save checkpoint await _checkPointLogger.WriteCheckPoint(checkpointSourceFileName, checkPoint); } else { // Send heartbeat messages // _logger.LogWarning($"No records retrieve from Rest Service. {targetDevice.HostName}: {DateTime.Now}"); await this._channelMessageSender.SendHeartBeatMessagesToAzureServiceBus(targetDevice); } }