Beispiel #1
0
 private async Task ProcessPushNotifications(CampaignQueueItem campaign)
 {
     if (campaign.IsGlobal)
     {
         var globalMessage = new PushNotificationQueueItem {
             Campaign  = campaign,
             Broadcast = true
         };
         await EventDispatcher.RaiseEventAsync(globalMessage, options =>
                                               options.WrapInEnvelope(false)
                                               .WithQueueName(QueueNames.SendPushNotification)
                                               );
     }
     else
     {
         foreach (var userCode in campaign.SelectedUserCodes)
         {
             var userMessage = new PushNotificationQueueItem {
                 UserCode  = userCode,
                 Campaign  = campaign,
                 Broadcast = false
             };
             await EventDispatcher.RaiseEventAsync(userMessage, options =>
                                                   options.WrapInEnvelope(false)
                                                   .WithQueueName(QueueNames.SendPushNotification)
                                                   );
         }
     }
 }
Beispiel #2
0
 private async Task ProcessPushNotifications(CampaignQueueItem campaign) {
     if (campaign.IsGlobal) {
         var globalMessage = new PushNotificationQueueItem {
             Campaign = campaign,
             Broadcast = true
         };
         await MessageQueue.Enqueue(globalMessage, campaign.ActivePeriod?.From?.DateTime ?? DateTime.UtcNow);
     } else {
         foreach (var userCode in campaign.SelectedUserCodes) {
             var userMessage = new PushNotificationQueueItem {
                 UserCode = userCode,
                 Campaign = campaign,
                 Broadcast = false
             };
             await MessageQueue.Enqueue(userMessage, campaign.ActivePeriod?.From?.DateTime ?? DateTime.UtcNow);
         }
     }
 }
Beispiel #3
0
        public async Task Process(PushNotificationQueueItem pushNotification)
        {
            var data           = pushNotification.Campaign?.Data ?? new ExpandoObject();
            var dataDictionary = data as IDictionary <string, object>;

            if (!dataDictionary.ContainsKey("id"))
            {
                data.TryAdd("id", pushNotification.Campaign.Id);
            }
            if (pushNotification.Broadcast)
            {
                await PushNotificationService.BroadcastAsync(pushNotification.Campaign.Title, pushNotification.Campaign.Content, data, pushNotification.Campaign?.Type?.Name);
            }
            else
            {
                await PushNotificationService.SendAsync(pushNotification.Campaign.Title, pushNotification.Campaign.Content, data, pushNotification.UserCode, classification : pushNotification.Campaign?.Type?.Name);
            }
        }