예제 #1
0
 public void publish(NotificationCategories category, string message, int storeId)
 {
     foreach (StoreRole sR in usersPreferences[category])
     {
         if (sR.store.getStoreId() == storeId)
         {
             NotificationManager.getInstance().notifyUser(sR.user.getUserName(), message);
         }
     }
 }
예제 #2
0
 public void removeFromCategory(StoreRole storeRole, NotificationCategories category)
 {
     if (!usersPreferences.ContainsKey(category))
     {
         return;
     }
     foreach (StoreRole sR in usersPreferences[category])
     {
         if (sR.user.getUserName() == storeRole.user.getUserName() && sR.store.getStoreId() == storeRole.store.getStoreId())
         {
             UNPDB.Remove(new Tuple <int, string, int>((int)category, storeRole.getUser().getUserName(), storeRole.getStore().getStoreId()));
             usersPreferences[category].Remove(sR);
             return;
         }
     }
 }
예제 #3
0
 public void signToCategory(StoreRole storeRole, NotificationCategories category)
 {
     if (!usersPreferences.ContainsKey(category))
     {
         usersPreferences.Add(category, new LinkedList <StoreRole>());
     }
     foreach (StoreRole sR in usersPreferences[category])
     {
         if (sR.user.getUserName() == storeRole.user.getUserName() && sR.store.getStoreId() == storeRole.store.getStoreId())
         {
             return;
         }
     }
     UNPDB.Add(new Tuple <int, string, int>((int)category, storeRole.getUser().getUserName(), storeRole.getStore().getStoreId()));
     usersPreferences[category].AddLast(storeRole);
 }
        private IEnumerable <INotifyerDaemon> GetDemonsForMonitor(string monitorName)
        {
            if (_monitorNames.ContainsKey(monitorName))
            {
                throw new Exception("developer error. did you forget to uniquely name your monitor ehh");
            }

            _monitorNames.Add(monitorName, monitorName);
            var cats      = Settings.GetSetting($"{monitorName}.NotificationCategories").Split(new [] { "," }, StringSplitOptions.RemoveEmptyEntries);
            var notifyers = new Dictionary <string, INotifyerDaemon>();

            foreach (string cat in cats)
            {
                NotificationCategories en = (NotificationCategories)Enum.Parse(typeof(NotificationCategories), cat, true);
                if (_slack.Contains(cat))
                {
                    notifyers["slack"] = (new SlackNotifyerDaemon(() => new EirWebClient(), en));
                }
                if (_email.Contains(cat))
                {
                    notifyers["mail"] = (new MailerDaemon(en));
                }
                if (_teams.Contains(cat))
                {
                    notifyers["teams"] = (new MsTeamsNotifyerDaemon(() => new EirWebClient(), en));
                }
                if (_post.Contains(cat))
                {
                    notifyers["post"] = (new HttpPostNotifyerDaemon(() => new EirWebClient(), en));
                }
                if (_db.Contains(cat))
                {
                    notifyers["db"] = (new DbNotifyerDeamon());
                }
            }

            return(notifyers.Values.ToList());
        }
예제 #5
0
 public MailerDaemon(NotificationCategories notificationCategories)
 {
     _slackSettingsGropName = notificationCategories.ToString().ToLower();
 }
예제 #6
0
 public HttpPostNotifyerDaemon(Func <IEirWebClient> webClientFactory, NotificationCategories settingsGropName)
 {
     _webClientFactory = webClientFactory;
     _settingsGropName = settingsGropName.ToString().ToLower();
 }
예제 #7
0
 public MsTeamsNotifyerDaemon(Func <IEirWebClient> webClientFactory, NotificationCategories slackSettingsGropName)
 {
     //_httpClient = httpClient;
     _webClientFactory      = webClientFactory;
     _slackSettingsGropName = slackSettingsGropName.ToString().ToLower();
 }