private void EvalStatus()
        {
            var existingSchedule = SqlCe.GetServiceSchedule();

            if (existingSchedule != null)
            {
                if (existingSchedule.ExecuteTime < _firstDeadline)
                {
                    SetStatus(ScheduleStatus.Green);
                    DtPicker.SelectedDate = existingSchedule.ExecuteTime;
                }
                else
                {
                    SqlCe.DeleteServiceSchedule();
                    SetStatus(ScheduleStatus.Blue);
                }
            }
            else if (_canSchedule)
            {
                SetStatus(ScheduleStatus.Blue);
            }
            else
            {
                SetStatus(ScheduleStatus.Orange);
            }
        }
        public static DateTime?GetNextServiceCycleAsDateTime()
        {
            var retDt = (DateTime?)DateTime.MinValue;

            var nextAutoTime = GetNextAutoSchedulesAsDateTime();

            var nextServiceCycle   = SqlCe.GetServiceSchedule();
            var dtNextServiceCycle = nextServiceCycle != null ? nextServiceCycle.ExecuteTime : DateTime.MaxValue;

            retDt = nextAutoTime < dtNextServiceCycle ? nextAutoTime : dtNextServiceCycle;

            return(retDt == DateTime.MaxValue ? null : retDt);
        }
Beispiel #3
0
        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);
            }
        }