Example #1
0
        public async Task <IEnumerable <SentNotificationSummary> > GetSentNotificationsAsync()
        {
            var notificationEntities = await this.notificationDataRepository.GetMostRecentSentNotificationsAsync();

            var result = new List <SentNotificationSummary>();

            foreach (var notificationEntity in notificationEntities)
            {
                var summary = new SentNotificationSummary
                {
                    Id                 = notificationEntity.Id,
                    Title              = notificationEntity.Title,
                    CreatedDateTime    = notificationEntity.CreatedDate,
                    SentDate           = notificationEntity.SentDate,
                    Succeeded          = notificationEntity.Succeeded,
                    Failed             = notificationEntity.Failed,
                    Unknown            = this.GetUnknownCount(notificationEntity),
                    TotalMessageCount  = notificationEntity.TotalMessageCount,
                    SendingStartedDate = notificationEntity.SendingStartedDate,
                    Status             = notificationEntity.GetStatus(),
                };

                result.Add(summary);
            }

            return(result);
        }
        public async Task <IEnumerable <SentNotificationSummary> > GetScheduledNotificationsAsync()
        {
            var scheduleNotificationEntities = await this.scheduleNotificationDataRepository.GetScheduledNotificationsAsync();

            var result = new List <SentNotificationSummary>();

            foreach (var scheduleNotificationEntity in scheduleNotificationEntities)
            {
                var notificationEntity = await this.notificationDataRepository.GetScheduleSentNotificationAsync(scheduleNotificationEntity.NotificationId);

                if (notificationEntity != null)
                {
                    var summary = new SentNotificationSummary
                    {
                        Id                 = notificationEntity.Id,
                        Title              = notificationEntity.Title,
                        CreatedDateTime    = notificationEntity.CreatedDate,
                        SentDate           = scheduleNotificationEntity.NotificationDate,
                        Succeeded          = notificationEntity.Succeeded,
                        Failed             = notificationEntity.Failed,
                        Throttled          = notificationEntity.Throttled,
                        TotalMessageCount  = notificationEntity.TotalMessageCount,
                        IsCompleted        = notificationEntity.IsCompleted,
                        SendingStartedDate = notificationEntity.SendingStartedDate,
                        IsRecurrence       = notificationEntity.IsRecurrence,
                    };

                    result.Add(summary);
                }
            }

            return(result);
        }
        public async Task <IEnumerable <SentNotificationSummary> > GetSentNotificationsAsync()
        {
            var notificationEntities = await this.notificationDataRepository.GetMostRecentSentNotificationsAsync();

            var result        = new List <SentNotificationSummary>();
            var rowKeysFilter = string.Empty;

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

                if (string.IsNullOrWhiteSpace(rowKeysFilter))
                {
                    rowKeysFilter = singleRowKeyFilter;
                }
                else
                {
                    rowKeysFilter = TableQuery.CombineFilters(rowKeysFilter, TableOperators.Or, singleRowKeyFilter);
                }
            }

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

            foreach (var notificationEntity in notificationEntities)
            {
                int acknowledgementCount = sentNotificationLogs.ToList().Where(o => o.PartitionKey == notificationEntity.Id).Count();
                var summary = new SentNotificationSummary
                {
                    Id                 = notificationEntity.Id,
                    Title              = notificationEntity.Title,
                    CreatedDateTime    = notificationEntity.CreatedDate,
                    SentDate           = notificationEntity.SentDate,
                    Succeeded          = notificationEntity.Succeeded,
                    Failed             = notificationEntity.Failed,
                    Throttled          = notificationEntity.Throttled,
                    Acknowledged       = acknowledgementCount,
                    TotalMessageCount  = notificationEntity.TotalMessageCount,
                    IsCompleted        = notificationEntity.IsCompleted,
                    SendingStartedDate = notificationEntity.SendingStartedDate,
                    IsRecurrence       = notificationEntity.IsRecurrence,
                };

                result.Add(summary);
            }

            return(result);
        }
Example #4
0
        public async Task <ActionResult <SentNotificationSummary> > GetSentNotificationsDashboardAsync(string userID)
        {
            var result = new List <SentNotificationSummary>();
            var notificationEntities = await this.notificationDataRepository.GetMostRecentSentNotificationsAsync();

            foreach (var notificationEntity in notificationEntities)
            {
                // var userDetails = await this.reactionService.GetLoggedinUserDetails();
                // Console.WriteLine(userDetails.Id);
                var getUserSpecificSentItems = await this.sentNotificationDataRepstry.GetWithFilterAsync("RecipientId eq '" + userID + "' and RecipientType eq 'User' ", notificationEntity.Id);

                var channelDataEntity = await this.channelDataRepository.GetFilterAsync("RowKey eq '" + notificationEntity.Channel + "'", null);

                foreach (ChannelDataEntity channelData in channelDataEntity)
                {
                    this.account = channelData.ChannelName;
                }

                foreach (var sentnotificationEntity in getUserSpecificSentItems)
                {
                    if (sentnotificationEntity.PartitionKey == notificationEntity.Id)
                    {
                        var summary = new SentNotificationSummary
                        {
                            Id                 = notificationEntity.Id,
                            Title              = notificationEntity.Title,
                            Account            = this.account,
                            CreatedDateTime    = notificationEntity.CreatedDate,
                            SentDate           = notificationEntity.SentDate,
                            Succeeded          = notificationEntity.Succeeded,
                            Edited             = notificationEntity.Edited,
                            Failed             = notificationEntity.Failed,
                            Unknown            = this.GetUnknownCount(notificationEntity),
                            TotalMessageCount  = notificationEntity.TotalMessageCount,
                            SendingStartedDate = notificationEntity.SendingStartedDate,
                            Status             = notificationEntity.GetStatus(),
                            ImageLink          = notificationEntity.ImageLink,
                            Summary            = notificationEntity.Summary,
                        };

                        result.Add(summary);
                    }
                }
            }
            return(this.Ok(result));
        }
Example #5
0
        public async Task <IEnumerable <SentNotificationSummary> > GetSentNotificationsAsync()
        {
            var authorizedCreatorUpns = this.configuration["AuthorizedCreatorUpns"];

            string[] superAdminsArray = authorizedCreatorUpns.Split(",");
            var      superAdmins      = string.Join(",", superAdminsArray).ToLower();

            this.loggedinUser = this.HttpContext.User?.Identity?.Name;
            var sLoggedin = string.Empty + this.loggedinUser;

            this.loggedinUser = sLoggedin;

            var result = new List <SentNotificationSummary>();

            if (superAdmins.Contains(this.loggedinUser.ToLower()))
            {
                var notificationEntities = await this.notificationDataRepository.GetMostRecentSentNotificationsAsync();

                foreach (var notificationEntity in notificationEntities)
                {
                    string likes = await this.GetActivityIDandLikes(notificationEntity);

                    var summary = new SentNotificationSummary
                    {
                        Id                 = notificationEntity.Id,
                        Title              = notificationEntity.Title,
                        Account            = this.account,
                        CreatedDateTime    = notificationEntity.CreatedDate,
                        SentDate           = notificationEntity.SentDate,
                        Succeeded          = notificationEntity.Succeeded,
                        Edited             = notificationEntity.Edited,
                        Failed             = notificationEntity.Failed,
                        Unknown            = this.GetUnknownCount(notificationEntity),
                        TotalMessageCount  = notificationEntity.TotalMessageCount,
                        SendingStartedDate = notificationEntity.SendingStartedDate,
                        Status             = notificationEntity.GetStatus(),
                        Likes              = likes,
                        ImageLink          = notificationEntity.ImageLink,
                        Summary            = notificationEntity.Summary,
                    };

                    result.Add(summary);
                }

                return(result);
            }
            else
            {
                this.loggedinUser = sLoggedin;
                string channelIds        = string.Empty;
                var    channelDataEntity = await this.channelDataRepository.GetAllAsync();

                foreach (ChannelDataEntity channelData in channelDataEntity)
                {
                    if (channelData.ChannelAdminEmail.ToLower().Contains(this.loggedinUser.ToLower()))
                    {
                        channelIds += channelData.RowKey;
                        channelIds += ",";
                    }
                }

                //var notificationEntities = await this.notificationDataRepository.GetWithFilterAsync("CreatedBy eq '" + this.loggedinUser + "'", "SentNotifications");
                var notificationEntities = await this.notificationDataRepository.GetMostRecentSentNotificationsAsync();

                foreach (var notificationEntity in notificationEntities)
                {
                    if (channelIds.Contains(notificationEntity.Channel))
                    {
                        string likes = await this.GetActivityIDandLikes(notificationEntity);

                        var summary = new SentNotificationSummary
                        {
                            Id                 = notificationEntity.Id,
                            Title              = notificationEntity.Title,
                            Account            = this.account,
                            CreatedDateTime    = notificationEntity.CreatedDate,
                            SentDate           = notificationEntity.SentDate,
                            Succeeded          = notificationEntity.Succeeded,
                            Edited             = notificationEntity.Edited,
                            Failed             = notificationEntity.Failed,
                            Unknown            = this.GetUnknownCount(notificationEntity),
                            TotalMessageCount  = notificationEntity.TotalMessageCount,
                            SendingStartedDate = notificationEntity.SendingStartedDate,
                            Status             = notificationEntity.GetStatus(),
                            Likes              = likes,
                            ImageLink          = notificationEntity.ImageLink,
                            Summary            = notificationEntity.Summary,
                        };

                        result.Add(summary);
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            return(result);
        }