Пример #1
0
        private bool IsWorkingHour(ZonedDateTime currentDateTime, ProductSpecificSettings productSettings, string supportTopic)
        {
            ChatHoursDuration[] chatDuration = chatConfig.GlobalChatHours;
            if (productSettings != null && productSettings.ChatHours != null && productSettings.ChatHours.Any())
            {
                chatDuration = productSettings.ChatHours;
            }

            bool result = false;

            foreach (var duration in chatDuration)
            {
                result = result || IsTimeWithinDuration(currentDateTime, duration, supportTopic);
            }

            return(result);
        }
Пример #2
0
        public ChatStatus GetChatStatus(string product, string supportTopic)
        {
            var currentDateTime = new ZonedDateTime(SystemClock.Instance.GetCurrentInstant(), DateTimeZoneProviders.Tzdb["America/Los_Angeles"]);

            ProductSpecificSettings productSettings = null;

            ChatHoursDuration[] chatHours = null;
            if (!string.IsNullOrWhiteSpace(product))
            {
                productSettings = chatConfig.ProductSpecificSettings.FirstOrDefault(p => p.Name.Equals(product, StringComparison.OrdinalIgnoreCase));
                if (productSettings != null)
                {
                    chatHours = productSettings.ChatHours;
                }
            }

            return(new ChatStatus
            {
                FreshToken = overallConfig["Chat:FreshToken"],
                IsEnabled = chatConfig.GlobalEnabled,
                IsValidTime = IsWorkingHour(currentDateTime, productSettings, supportTopic) && !IsBreakTime(currentDateTime, chatHours) && !IsHoliday(currentDateTime, chatHours)
            });
        }