private void CheckForSups() { if (_supCheckBlocked || SqlCe.GetAutoEnforceFlag()) { return; } try { var sups = CcmUtils.Updates; if (sups.Count() == 0) { _lastFoundSups = null; Globals.Log.Information("No updates available at this time"); return; } _lastFoundSups = _lastFoundSups ?? DateTime.Now; if (_lastFoundSups > DateTime.Now.AddMinutes(-5)) { return; } var jsonSups = JsonConvert.SerializeObject(sups); SqlCe.UpdateSupData("STD", jsonSups); Globals.Log.Information($"Found {sups.Count()} updates available for scheduling"); var nextSchedule = SqlCe.GetNextSupSchedule(); var supdeadline = sups.OrderBy(y => y.Deadline).First().Deadline; var nextServiceCycle = SqlCe.GetServiceSchedule(); if (nextSchedule.Id != 0) { Globals.Log.Information($"Next update enforcement time '{nextSchedule.EnforcementTime}' deadline for available updates = '{supdeadline}', 'toasting' user - reschedule necessary"); if (nextSchedule.EnforcementTime <= supdeadline) { Globals.Log.Information($"Next update enforcement time '{nextSchedule.EnforcementTime}' deadline for available updates = '{supdeadline}', skipping 'toast'"); return; } else { SqlCe.SetEnforcedFlag(nextSchedule.Id); } } var dtNextServiceCycle = CommonUtils.GetNextServiceCycleAsDateTime(); if (dtNextServiceCycle != null) { if (dtNextServiceCycle <= supdeadline) { Globals.Log.Information($"Detected an upcoming service cycle, a Toast notification was suppressed."); return; } } if (UnsafeNativeMethods.IsUserLoggedOn() && !RegistryMethods.GetIpuIsRunning()) { if (!UnsafeNativeMethods.IsSessionLocked()) { UnsafeNativeMethods.Run(_userApp, $"/ToastSup", false); } else { Globals.Log.Information($"Detected a locked or non existing user session, a Toast notification was suppressed."); } } } catch (Exception ex) { Globals.Log.Error(ex.Message); } }