private void CheckForRebootRequired(AppProperties aProperties) { GetCurrentTime(out int iHours, out int iMinutes); TimeSpan dTimeNow = new TimeSpan(0, iHours, iMinutes, 0); Boolean bPerformReboot = false; // 5 minute period that we should try to reboot within TimeSpan dEndTime = aProperties.RebootTime.Add(TimeSpan.FromMinutes(5)); // Ensure we are within the reboot time Boolean bScheduleTimeReached = aProperties.ScheduleReboot && (dTimeNow >= aProperties.RebootTime && dTimeNow <= dEndTime); if (aProperties.MaxUpTimeReboot) { // Check if we have reached the maximum up time. Boolean bMaxupTimeReached = aProperties.MaxUpTimeReboot && (aProperties.CurrentModem.UpTimeHours >= aProperties.MaxUpTime); bPerformReboot = bMaxupTimeReached && bScheduleTimeReached; if (bPerformReboot) { aProperties.LogMessage(aProperties, "Schedule reboot time and maximum uptime reached."); } } else if (aProperties.ScheduleReboot) { bPerformReboot = bScheduleTimeReached; if (bPerformReboot) { aProperties.LogMessage(aProperties, "Schedule reboot time reached."); } } if (aProperties.RebootOnStart || bPerformReboot) { if (aProperties.CurrentModem.PerformReboot(aProperties)) { aProperties.LastReboot = DateTime.Now; aProperties.HasReboot = true; aProperties.RebootOnStart = false; } else { aProperties.LogMessage(aProperties, "Failed to send reboot command."); } } }
public void LogSyncRates(AppProperties aProperties) { // Only log if stats have changed if (GetSyncRates(aProperties) & (!String.Equals(Downrate + Uprate, aProperties.LastStats, StringComparison.OrdinalIgnoreCase))) { // Remember these stats aProperties.LastStats = Downrate + Uprate; aProperties.LogMessage(aProperties, $"Downstream (Kbps): {Downrate}, Upstream (Kbps): {Uprate}, Uptime: {UpTime}"); } }
public virtual Boolean PerformReboot(AppProperties aProperties) { GetSyncRates(aProperties); // Log the current stats just before the reboot aProperties.LogMessage(aProperties, $"Sending Reboot Command. Current Stats: Downstream (Kbps): {Downrate}, Upstream (Kbps): {Uprate}, Uptime: {UpTime}"); string sRebootHtml = GetPageHtml(aProperties, string.Format(GetRebootUrl(), aProperties.ModemIP)); return(!string.IsNullOrEmpty(sRebootHtml)); }