private void Heartbeat_Elapsed(object sender, ElapsedEventArgs e)
        {
            int statusCode = 0;

            try
            {
                // Update LastReportedOn
                Heartbeat.LastReportedOn = DateTime.UtcNow;

                // Send HeartBeat to the Server
                statusCode = AgentsAPIManager.SendAgentHeartBeat(
                    _authAPIManager,
                    _connectionSettingsManager.ConnectionSettings.AgentId,
                    Heartbeat);

                if (statusCode != 201)
                {
                    _connectionSettingsManager.ConnectionSettings.ServerConnectionEnabled = false;
                    _connectionSettingsManager.UpdateConnectionSettings(_connectionSettingsManager.ConnectionSettings);
                }
            }
            catch (Exception ex)
            {
                _fileLogger.LogEvent("HeartBeat", $"Status Code: {statusCode} || Exception: {ex.ToString()}", LogEventLevel.Error);
                _connectionSettingsManager.ConnectionSettings.ServerConnectionEnabled = false;
                _connectionSettingsManager.UpdateConnectionSettings(_connectionSettingsManager.ConnectionSettings);

                // Invoke event to Stop Server Communication
                ServerConnectionLostEvent?.Invoke(this, EventArgs.Empty);
            }
        }
        private void SendHeartbeat()
        {
            int statusCode = 0;

            try
            {
                // Update LastReportedOn
                Heartbeat.LastReportedOn = DateTime.UtcNow;

                // Send HeartBeat to the Server
                var apiResponse = AgentsAPIManager.SendAgentHeartBeat(
                    _authAPIManager,
                    _connectionSettingsManager.ConnectionSettings.AgentId,
                    Heartbeat);

                statusCode = apiResponse.StatusCode;
                if (statusCode != 200)
                {
                    _connectionSettingsManager.ConnectionSettings.ServerConnectionEnabled = false;
                    _connectionSettingsManager.UpdateConnectionSettings(_connectionSettingsManager.ConnectionSettings);
                }
                else if (apiResponse.Data?.AssignedJob != null)
                {
                    ExecutionManager.JobsQueueManager.EnqueueJob(apiResponse.Data.AssignedJob);

                    // Log Event
                    _fileLogger.LogEvent("Job Fetch", "Job fetched and queued for execution");
                }
            }
            catch (Exception ex)
            {
                _fileLogger.LogEvent("HeartBeat", $"Status Code: {statusCode} || Exception: {ex.ToString()}", LogEventLevel.Error);
                _connectionSettingsManager.ConnectionSettings.ServerConnectionEnabled = false;
                _connectionSettingsManager.UpdateConnectionSettings(_connectionSettingsManager.ConnectionSettings);

                // Invoke event to Stop Server Communication
                ServerConnectionLostEvent?.Invoke(this, EventArgs.Empty);
            }
        }