public object isHoliday(DateTime date)
            {
                if (_device == null)
                {
                    _log.Warn("Unable to get variable value because the device was not found.");
                    return(null);
                }

                return(_calculator.GetHolidays(_device, date.Date, date.Date).Any());
            }
Пример #2
0
        private void UpdateVariables(WorkdayDevice device)
        {
            var workdays = _calculator.GetWorkdays(device, DateTime.Today, DateTime.Today.AddDays(1)).ToList();
            var holidays = _calculator.GetHolidays(device, DateTime.Today, DateTime.Today.AddDays(1)).ToList();

            _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, "TodayIsWorkday", workdays.Contains(DateTime.Today)));
            _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, "TomorrowIsWorkday", workdays.Contains(DateTime.Today.AddDays(1))));

            _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, "TodayIsHoliday", holidays.Contains(DateTime.Today)));
            _messageQueue.Publish(new UpdateVariableMessage(Name, device.Id, "TomorrowIsHoliday", holidays.Contains(DateTime.Today.AddDays(1))));
        }