Пример #1
0
        // GET: /Action/AllOff
        public ActionResult AllOff(
            string keep)
        {
            try
            {
                Security.ClearSavedProfile();

                Running.ExitAllPrograms(!string.IsNullOrEmpty(keep));
                DesktopClient.SendSpecialkey("ClearDesktop");
                return(Content(Receiver.VolumeDisplay));
            }
            catch (System.Exception ex)
            {
                logger.Error(ex, "Error in AllOff: {0}", ex.Message);
                return(Content("Error"));
            }
        }
Пример #2
0
    /// <summary>
    /// Apply any initial on/off settings in the current schedule, recording the current state for each device
    /// </summary>
    static void InitSchedule()
    {
        if (CurrentProfileSchedules.radioSchedule != null)
        {
            if (CurrentProfileSchedules.radioSchedule.initiallyOn || CurrentProfileSchedules.radioSchedule.initiallyOff || CurrentProfileSchedules.radioSchedule.onPeriods.Any())
            {
                Running.ExitAllPrograms();
                DesktopClient.SendSpecialkey("ClearDesktop");
            }

            if (CurrentProfileSchedules.radioSchedule.initiallyOn)
            {
                Receiver.Security();
                RadioState = "on";
            }

            if (CurrentProfileSchedules.radioSchedule.initiallyOff)
            {
                RadioState = "off";
            }
        }

        foreach (var zoneKV in CurrentProfileSchedules.zoneSchedules)
        {
            if (zoneKV.Value.initiallyOn && Zones.ContainsKey(zoneKV.Key))
            {
                foreach (Device d in Zones[zoneKV.Key])
                {
                    TP_Link.TurnOn(d.ipAddress, d.name, d.isSocket);
                }
                ZoneStates[zoneKV.Key] = "on";
            }
            if (zoneKV.Value.initiallyOff && Zones.ContainsKey(zoneKV.Key))
            {
                foreach (Device d in Zones[zoneKV.Key])
                {
                    TP_Link.TurnOff(d.ipAddress, d.name, d.isSocket);
                }
                ZoneStates[zoneKV.Key] = "off";
            }
        }
    }