예제 #1
0
     public NotificationSubscription[] GetSubscriptions(NotificationDefinition notificationDefinition)
     {
         if (!NotificationSubscriptions.TryGetValue(notificationDefinition, out var methodHandlers))
         {
             return new NotificationSubscription[] { }
         }
         ;
         return(methodHandlers.ToArray());
     }
 }
예제 #2
0
        public void RegisterSubscription(NotificationSubscription subscription)
        {
            if (!NotificationSubscriptions.TryGetValue(subscription.Notification, out var subscriptions))
            {
                subscriptions = new List <NotificationSubscription>();
                NotificationSubscriptions[subscription.Notification] = subscriptions;
            }

            if (subscriptions.Any(s => s.Notification == subscription.Notification && s.Method == subscription.Method))
            {
                throw new ArgumentException($"Already found subscription for topic to method Topic={subscription.Notification.Topic} Method={subscription.Method}");
            }

            if (null == _taskRegistry.GetTaskByMethod(subscription.Method))
            {
                throw new ArgumentException($"Method {subscription.Method} must be registered as task to accept notifications");
            }

            NotificationSubscriptions[subscription.Notification].Add(subscription);
        }
예제 #3
0
        private void RegisterSettings()
        {
            FlexKids                  flexKidsConfig            = _config.GetSection("FlexKids").Get <FlexKids>();
            GoogleCalendar            googleCalendarConfig      = _config.GetSection("GoogleCalendar").Get <GoogleCalendar>();
            Smtp                      smtpConfig                = _config.GetSection("SMTP").Get <Smtp>();
            NotificationSubscriptions notificationSubscriptions = _config.GetSection("NotificationSubscriptions").Get <NotificationSubscriptions>();

            var staticEmailServerConfig = new EmailServerConfig(
                smtpConfig.Host,
                smtpConfig.Port,
                smtpConfig.Username,
                smtpConfig.Password,
                smtpConfig.Secure);

            _container.RegisterInstance(staticEmailServerConfig);

            var staticGoogleCalendarConfig = new GoogleCalendarConfig(
                googleCalendarConfig.Account,
                googleCalendarConfig.CalendarId,
                googleCalendarConfig.PrivateKey);

            _container.RegisterInstance(staticGoogleCalendarConfig);

            var staticEmailConfig = new EmailConfig(
                new MailAddress(notificationSubscriptions.From.Email, "FlexKids rooster"),
                notificationSubscriptions.To.Select(x => new MailAddress(x.Email, x.Name)).ToArray());

            _container.RegisterInstance(staticEmailConfig);

            var staticFlexKidsHttpClientConfig = new FlexKidsHttpClientConfig(
                flexKidsConfig.Host,
                flexKidsConfig.Username,
                flexKidsConfig.Password);

            _container.RegisterInstance(staticFlexKidsHttpClientConfig);
        }
 public void AddToNotificationSubscriptions(NotificationSubscriptions notificationSubscriptions)
 {
     base.AddObject("NotificationSubscriptions", notificationSubscriptions);
 }
 public static NotificationSubscriptions CreateNotificationSubscriptions(global::System.Guid notificationSubscriptionsId, string mailRecipients)
 {
     NotificationSubscriptions notificationSubscriptions = new NotificationSubscriptions();
     notificationSubscriptions.NotificationSubscriptionsId = notificationSubscriptionsId;
     notificationSubscriptions.MailRecipients = mailRecipients;
     return notificationSubscriptions;
 }