private static void NotifyAbouFutureEvent(DateTime scheduleDate)
        {
            using (var dataProvider = new DataProvider())
            {
                var notifications = dataProvider.ExtractAndRecountNotifications(scheduleDate);
                foreach (var data in notifications)
                {
                    if (data.Event == null) continue;

                    var tenant = CoreContext.TenantManager.GetTenant(data.TenantId);
                    if (tenant == null || tenant.Status != TenantStatus.Active) continue;

                    CoreContext.TenantManager.SetCurrentTenant(tenant);
                    var r = CalendarNotifySource.Instance.GetRecipientsProvider().GetRecipient(data.UserId.ToString());


                    var startDate = data.GetUtcStartDate().Add(data.TimeZone.GetUtcOffset(DateTime.UtcNow));
                    var endDate = data.GetUtcEndDate();
                    endDate = (endDate == DateTime.MinValue ? DateTime.MinValue : endDate.Add(data.TimeZone.GetUtcOffset(DateTime.UtcNow)));

                    _notifyClient.SendNoticeAsync(CalendarNotifySource.EventAlert, null, r, true,
                        new TagValue(new Tag("EventName"), data.Event.Name),
                        new TagValue(new Tag("EventDescription"), data.Event.Description ?? ""),
                        new TagValue(new Tag("EventStartDate"), startDate.ToShortDateString() + " " + startDate.ToShortTimeString()),
                        new TagValue(new Tag("EventEndDate"), (endDate > startDate) ? (endDate.ToShortDateString() + " " + endDate.ToShortTimeString()) : ""));
                }
            }
        }
        private static void NotifyAbouFutureEvent(DateTime scheduleDate)
        {
            try
            {
                using (var dataProvider = new DataProvider())
                {
                    foreach (var data in dataProvider.ExtractAndRecountNotifications(scheduleDate))
                    {
                        if (data.Event == null)
                        {
                            continue;
                        }

                        var tenant = CoreContext.TenantManager.GetTenant(data.TenantId);
                        if (tenant == null || 
                            tenant.Status != TenantStatus.Active ||
                            TariffState.NotPaid <= CoreContext.PaymentManager.GetTariff(tenant.TenantId).State)
                        {
                            continue;
                        }
                        CoreContext.TenantManager.SetCurrentTenant(tenant);

                        var r = CalendarNotifySource.Instance.GetRecipientsProvider().GetRecipient(data.UserId.ToString());
                        if (r == null)
                        {
                            continue;
                        }

                        var startDate = data.GetUtcStartDate();
                        var endDate = data.GetUtcEndDate();

                        if (!data.Event.AllDayLong)
                        {
                            startDate = startDate.Add(data.TimeZone.BaseUtcOffset);
                            endDate = (endDate == DateTime.MinValue ? DateTime.MinValue : endDate.Add(data.TimeZone.BaseUtcOffset));
                        }

                        _notifyClient.SendNoticeAsync(CalendarNotifySource.EventAlert,
                            null,
                            r,
                            true,
                            new TagValue("EventName", data.Event.Name),
                            new TagValue("EventDescription", data.Event.Description ?? ""),
                            new TagValue("EventStartDate", startDate.ToShortDateString() + " " + startDate.ToShortTimeString()),
                            new TagValue("EventEndDate", (endDate > startDate) ? (endDate.ToShortDateString() + " " + endDate.ToShortTimeString()) : ""),
                            new TagValue("Priority", 1));
                    }
                }
            }
            catch (Exception error)
            {
                LogManager.GetLogger("ASC.Notify.Calendar").Error(error);
            }
        }