Ejemplo n.º 1
0
 public void QueuedItemShouldAppearInTheQueue()
 {
     var queue = new PendingItemsQueue();
     var sentNotification = new SentNotification(new AppleNotification());
     queue.QueueItem(sentNotification);
     Assert.IsTrue(queue.Contains(sentNotification));
 }
        public async Task <IActionResult> GetSentNotificationByIdAsync(string id)
        {
            var notificationEntity = await this.notificationDataRepository.GetAsync(
                PartitionKeyNames.NotificationDataTable.SentNotificationsPartition,
                id);

            if (notificationEntity == null)
            {
                return(this.NotFound());
            }

            var result = new SentNotification
            {
                Id                 = notificationEntity.Id,
                Title              = notificationEntity.Title,
                ImageLink          = notificationEntity.ImageLink,
                Summary            = notificationEntity.Summary,
                Author             = notificationEntity.Author,
                ButtonTitle        = notificationEntity.ButtonTitle,
                ButtonLink         = notificationEntity.ButtonLink,
                CreatedDateTime    = notificationEntity.CreatedDate,
                SentDate           = notificationEntity.SentDate,
                Succeeded          = notificationEntity.Succeeded,
                Failed             = notificationEntity.Failed,
                Throttled          = notificationEntity.Throttled,
                TeamNames          = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Teams),
                RosterNames        = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Rosters),
                AllUsers           = notificationEntity.AllUsers,
                SendingStartedDate = notificationEntity.SendingStartedDate,
            };

            return(this.Ok(result));
        }
        public async Task <IActionResult> GetSentNotificationByIdAsync(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var notificationEntity = await this.notificationDataRepository.GetAsync(
                NotificationDataTableNames.SentNotificationsPartition,
                id);

            if (notificationEntity == null)
            {
                return(this.NotFound());
            }

            var groupNames = await this.groupsService.
                             GetByIdsAsync(notificationEntity.Groups).
                             Select(x => x.DisplayName).
                             ToListAsync();

            var userId = this.HttpContext.User.FindFirstValue(Common.Constants.ClaimTypeUserId);
            var userNotificationDownload = await this.exportDataRepository.GetAsync(userId, id);

            var result = new SentNotification
            {
                Id                   = notificationEntity.Id,
                Title                = notificationEntity.Title,
                ImageLink            = notificationEntity.ImageLink,
                Summary              = notificationEntity.Summary,
                Author               = notificationEntity.Author,
                ButtonTitle          = notificationEntity.ButtonTitle,
                ButtonLink           = notificationEntity.ButtonLink,
                Buttons              = notificationEntity.Buttons,
                ChannelId            = notificationEntity.ChannelId,
                IsScheduled          = notificationEntity.IsScheduled,
                IsImportant          = notificationEntity.IsImportant,
                CreatedDateTime      = notificationEntity.CreatedDate,
                SentDate             = notificationEntity.SentDate,
                Succeeded            = notificationEntity.Succeeded,
                Failed               = notificationEntity.Failed,
                Unknown              = this.GetUnknownCount(notificationEntity),
                Canceled             = notificationEntity.Canceled > 0 ? notificationEntity.Canceled : (int?)null,
                TeamNames            = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Teams),
                RosterNames          = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Rosters),
                GroupNames           = groupNames,
                AllUsers             = notificationEntity.AllUsers,
                SendingStartedDate   = notificationEntity.SendingStartedDate,
                ErrorMessage         = notificationEntity.ErrorMessage,
                WarningMessage       = notificationEntity.WarningMessage,
                CanDownload          = userNotificationDownload == null,
                SendingCompleted     = notificationEntity.IsCompleted(),
                Reads                = notificationEntity.Reads,
                CsvUsers             = notificationEntity.CsvUsers,
                ButtonTrackingClicks = notificationEntity.ButtonTrackingClicks,
            };

            return(this.Ok(result));
        }
        private static ISentNotification CreateSentObject(DataRow dr)
        {
            var notification = new SentNotification
            {
                TockaId        = int.Parse(dr["fk_tocka"].ToString()),
                IzvestuvanjeId = int.Parse(dr["fk_izvestuvanje"].ToString())
            };

            return(notification);
        }
Ejemplo n.º 5
0
        public void addSentNotification(int orderId)
        {
            SentNotification sentNotification = new SentNotification();

            db.SentNotifications.Add(new SentNotification
            {
                isSent  = false,
                OrderId = orderId
            });
            db.SaveChanges();
        }
        public async Task <IActionResult> GetScheduleNotificationByIdAsync(string id)
        {
            var notificationEntity = await this.notificationDataRepository.GetAsync(
                PartitionKeyNames.NotificationDataTable.ScheduleSentNotificationsPartition,
                id);

            if (notificationEntity == null)
            {
                return(this.NotFound());
            }

            var scheduleNotificationEntity = await this.scheduleNotificationDataRepository.GetAsync(
                PartitionKeyNames.ScheduleNotificationDataTable.ScheduleNotificationsPartition,
                id);

            if (scheduleNotificationEntity == null)
            {
                return(this.NotFound());
            }

            var result = new SentNotification
            {
                Id                 = notificationEntity.Id,
                Title              = notificationEntity.Title,
                ImageLink          = notificationEntity.ImageLink,
                Summary            = notificationEntity.Summary,
                Author             = notificationEntity.Author,
                ButtonTitle        = notificationEntity.ButtonTitle,
                ButtonLink         = notificationEntity.ButtonLink,
                ButtonTitle2       = notificationEntity.ButtonTitle2,
                ButtonLink2        = notificationEntity.ButtonLink2,
                CreatedDateTime    = notificationEntity.CreatedDate,
                IsRecurrence       = notificationEntity.IsRecurrence,
                SentDate           = scheduleNotificationEntity.NotificationDate,
                Succeeded          = notificationEntity.Succeeded,
                Failed             = notificationEntity.Failed,
                Throttled          = notificationEntity.Throttled,
                Acknowledged       = 0,
                TeamNames          = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Teams),
                RosterNames        = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Rosters),
                AllUsers           = notificationEntity.AllUsers,
                SendingStartedDate = notificationEntity.SendingStartedDate,
                Repeats            = notificationEntity.Repeats,
                RepeatStartDate    = notificationEntity.RepeatStartDate,
                RepeatFor          = notificationEntity.RepeatFor,
                RepeatFrequency    = notificationEntity.RepeatFrequency,
                WeekSelection      = notificationEntity.WeekSelection,
                RepeatEndDate      = notificationEntity.RepeatEndDate,
            };

            return(this.Ok(result));
        }
        public async Task <IActionResult> GetSentNotificationByIdAsync(string id)
        {
            var notificationEntity = await this.notificationDataRepository.GetAsync(
                PartitionKeyNames.NotificationDataTable.SentNotificationsPartition,
                id);

            if (notificationEntity == null)
            {
                return(this.NotFound());
            }

            var rowKeysFilter = string.Empty;

            var singleRowKeyFilter = TableQuery.GenerateFilterCondition(
                nameof(TableEntity.PartitionKey),
                QueryComparisons.Equal,
                notificationEntity.Id);

            var sentNotificationLogs = await this.sentNotificationDataRepository.GetCustomWithFilterAsync(singleRowKeyFilter);

            var result = new SentNotification
            {
                Id                 = notificationEntity.Id,
                Title              = notificationEntity.Title,
                ImageLink          = notificationEntity.ImageLink,
                Summary            = notificationEntity.Summary,
                Author             = notificationEntity.Author,
                ButtonTitle        = notificationEntity.ButtonTitle,
                ButtonLink         = notificationEntity.ButtonLink,
                ButtonTitle2       = notificationEntity.ButtonTitle2,
                ButtonLink2        = notificationEntity.ButtonLink2,
                CreatedDateTime    = notificationEntity.CreatedDate,
                IsRecurrence       = notificationEntity.IsRecurrence,
                SentDate           = notificationEntity.SentDate,
                Succeeded          = notificationEntity.Succeeded,
                Failed             = notificationEntity.Failed,
                Throttled          = notificationEntity.Throttled,
                Acknowledged       = sentNotificationLogs.Count(),
                TeamNames          = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Teams),
                RosterNames        = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Rosters),
                AllUsers           = notificationEntity.AllUsers,
                SendingStartedDate = notificationEntity.SendingStartedDate,
                Repeats            = notificationEntity.Repeats,
                RepeatStartDate    = notificationEntity.RepeatStartDate,
                RepeatFor          = notificationEntity.RepeatFor,
                RepeatFrequency    = notificationEntity.RepeatFrequency,
                WeekSelection      = notificationEntity.WeekSelection,
                RepeatEndDate      = notificationEntity.RepeatEndDate,
            };

            return(this.Ok(result));
        }
Ejemplo n.º 8
0
        private async static void SendNotification(MailManager mailRepository, User user, SearchPharmaciesNearPoint location, CovidSearchDatabase database)
        {
            var result = await mailRepository.SendVaccineAvailability(location.location, user);

            if (result)
            {
                var sentNotification = new SentNotification()
                {
                    UserID     = user.UserID,
                    LocationID = location.location.locationId,
                    SentDate   = DateTime.Now.ToString()
                };

                var task = Task.Run(async() => { var test = await database.AsyncInsert(sentNotification); });
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> GetSentNotificationByIdAsync(string id)
        {
            int likes              = 0;
            int likeCount          = 0;
            var notificationEntity = await this.notificationDataRepository.GetAsync(
                NotificationDataTableNames.SentNotificationsPartition,
                id);

            if (notificationEntity == null)
            {
                return(this.NotFound());
            }

            var sentNotificationEntities = await this.sentNotificationDataRepstry.GetActivityIDAsync(id);

            foreach (var sentNotificationEntity in sentNotificationEntities)
            {
                if (sentNotificationEntity != null && !string.IsNullOrEmpty(sentNotificationEntity.ConversationId))
                {
                    var teamsDataEntity = await this.teamDataRepository.GetWithFilterAsync("RowKey eq '" + sentNotificationEntity.ConversationId + "'");

                    if (teamsDataEntity != null && teamsDataEntity.ToArray().Length > 0)
                    {
                        foreach (var teamsData in teamsDataEntity)
                        {
                            string teamsID = await this.groupsService.SearchTeamsGroupAsync("displayname eq '" + teamsData.Name + "'");

                            if (!string.IsNullOrEmpty(teamsID))
                            {
                                var messageResponse = await this.reactionService.GetMessagesAsync(teamsID, sentNotificationEntity.ConversationId, sentNotificationEntity.ActivtyId);

                                if (messageResponse != null && messageResponse.Reactions != null && messageResponse.Reactions.ToArray().Length > 0)
                                {
                                    foreach (var reaction in messageResponse.Reactions)
                                    {
                                        if (reaction.ReactionType.ToString() == "like")
                                        {
                                            likeCount++;
                                        }
                                    }

                                    likes = likeCount;
                                }
                            }
                        }
                    }
                }
            }

            // var groupNames = await this.groupsService.
            // GetByIdsAsync(notificationEntity.Groups).
            //   Select(x => x.DisplayName).
            // ToListAsync();
            var userId = this.HttpContext.User.FindFirstValue(Common.Constants.ClaimTypeUserId);
            var userNotificationDownload = await this.exportDataRepository.GetAsync(userId, id);

            var result = new SentNotification
            {
                Id                 = notificationEntity.Id,
                Channel            = notificationEntity.Channel,
                TemplateID         = notificationEntity.TemplateID,
                Title              = notificationEntity.Title,
                ImageLink          = notificationEntity.ImageLink,
                Summary            = notificationEntity.Summary,
                Author             = notificationEntity.Author,
                ButtonTitle        = notificationEntity.ButtonTitle,
                ButtonLink         = notificationEntity.ButtonLink,
                CreatedDateTime    = notificationEntity.CreatedDate,
                SentDate           = notificationEntity.SentDate,
                Succeeded          = notificationEntity.Succeeded,
                Failed             = notificationEntity.Failed,
                Unknown            = this.GetUnknownCount(notificationEntity),
                TeamNames          = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Teams),
                RosterNames        = await this.teamDataRepository.GetTeamNamesByIdsAsync(notificationEntity.Rosters),
                GroupNames         = await this.distributionListDataRepository.GetDLsByIdsAsync(notificationEntity.Groups),
                AllUsers           = notificationEntity.AllUsers,
                SendingStartedDate = notificationEntity.SendingStartedDate,
                ErrorMessage       = notificationEntity.ErrorMessage,
                WarningMessage     = notificationEntity.WarningMessage,
                CanDownload        = userNotificationDownload == null,
                SendingCompleted   = notificationEntity.IsCompleted(),
                Likes              = likes,
            };

            return(this.Ok(result));
        }
Ejemplo n.º 10
0
        public async Task <HttpStatusCodeResult> Notify()
        {
            await SentNotification.Notify();

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }