Example #1
0
        //public static List<Notification> _Last;

        public static List <Notification> SendSubscriptionNotifications(
            Guid accountId,
            Core.Api.EventImportance importance,
            Guid componentId,
            NotificationType notificationType)
        {
            using (var accountDbContext = AccountDbContext.CreateFromAccountId(accountId))
            {
                // получим новые, неотправленные уведомления
                var notifications = accountDbContext.Notifications
                                    .Include("Event")
                                    .Include("Subscription")
                                    .Include("NotificationHttp")
                                    .Where(x => x.Event.OwnerId == componentId &&
                                           x.Status == NotificationStatus.InQueue &&
                                           x.Event.Importance == importance &&
                                           x.Type == notificationType)
                                    .ToList();

                foreach (var notification in notifications)
                {
                    // сделаем вид, что уведомления отправлены
                    notification.SendDate = DateTime.Now;
                    notification.Status   = NotificationStatus.Sended;
                }

                accountDbContext.SaveChanges();
                //_Last = notifications;
                return(notifications);
            }
        }
Example #2
0
        protected string GetEventImportanceText(Core.Api.EventImportance importance)
        {
            if (importance == Core.Api.EventImportance.Alarm)
            {
                return("ОШИБКА");
            }

            if (importance == Core.Api.EventImportance.Warning)
            {
                return("ПРЕДУПРЕЖДЕНИЕ");
            }

            if (importance == Core.Api.EventImportance.Success)
            {
                return("ВСЁ ХОРОШО");
            }

            return("НЕИЗВЕСТНО");
        }
        protected static string EventImportanceToColor(Core.Api.EventImportance eventImportance)
        {
            if (eventImportance == Core.Api.EventImportance.Alarm)
            {
                return("darkred");
            }

            if (eventImportance == Core.Api.EventImportance.Warning)
            {
                return("darkgoldenrod");
            }

            if (eventImportance == Core.Api.EventImportance.Success)
            {
                return("darkgreen");
            }

            return("gray");
        }