示例#1
0
        public async Task SendSummaryNotificationAsync(string emailAddress, SummaryNotificationModel notification)
        {
            notification.BaseUrl = Settings.Current.BaseURL;
            MailMessage msg = _emailGenerator.GenerateMessage(notification, "SummaryNotification");

            msg.To.Add(emailAddress);
            await QueueMessage(msg);
        }
示例#2
0
        public void SendSummaryNotification(string emailAddress, SummaryNotificationModel notification)
        {
            notification.BaseUrl = Settings.Current.BaseURL;
            MailMessage msg = _emailGenerator.GenerateMessage(notification, "SummaryNotification");

            msg.To.Add(emailAddress);
            msg.Headers.Add("X-Mailer-Machine", Environment.MachineName);
            msg.Headers.Add("X-Mailer-Date", DateTime.Now.ToString());
            SendMessage(msg);
        }
        private object ProcessSummaryNotification(IMessage <SummaryNotification> message)
        {
            var project      = _projectRepository.GetByIdCached(message.GetBody().Id);
            var organization = _organizationRepository.GetByIdCached(project.OrganizationId);
            var userIds      = project.NotificationSettings.Where(n => n.Value.SendDailySummary).Select(n => n.Key).ToList();

            if (userIds.Count == 0)
            {
                return(null);
            }

            var users = _userRepository.GetByIds(userIds).Where(u => u.IsEmailAddressVerified).ToList();

            if (users.Count == 0)
            {
                return(null);
            }

            long         count;
            List <Stack> newest = _stackRepository.GetNew(project.Id, message.GetBody().UtcStartTime, message.GetBody().UtcEndTime, 0, 5, out count).ToList();

            DateTime start        = _projectRepository.UtcToDefaultProjectLocalTime(project.Id, message.GetBody().UtcStartTime);
            DateTime end          = _projectRepository.UtcToDefaultProjectLocalTime(project.Id, message.GetBody().UtcEndTime);
            var      result       = _eventStatsHelper.GetProjectErrorStats(project.Id, _projectRepository.GetDefaultTimeOffset(project.Id), start, end);
            var      mostFrequent = result.MostFrequent.Results.Take(5).ToList();
            var      errorStacks  = _stackRepository.GetByIds(mostFrequent.Select(s => s.Id));

            foreach (var frequent in mostFrequent)
            {
                var stack = errorStacks.SingleOrDefault(s => s.Id == frequent.Id);
                if (stack == null)
                {
                    mostFrequent.RemoveAll(r => r.Id == frequent.Id);
                    continue;
                }

                // Stat's Id and Total properties are already calculated in the Results.
                frequent.Type   = stack.SignatureInfo.ContainsKey("ExceptionType") ? stack.SignatureInfo["ExceptionType"] : null;
                frequent.Method = stack.SignatureInfo.ContainsKey("Method") ? stack.SignatureInfo["Method"] : null;
                frequent.Path   = stack.SignatureInfo.ContainsKey("Path") ? stack.SignatureInfo["Path"] : null;
                frequent.Is404  = stack.SignatureInfo.ContainsKey("Path");

                frequent.Title = stack.Title;
                frequent.First = stack.FirstOccurrence;
                frequent.Last  = stack.LastOccurrence;
            }

            var notification = new SummaryNotificationModel {
                ProjectId          = project.Id,
                ProjectName        = project.Name,
                StartDate          = start,
                EndDate            = end,
                Total              = result.Total,
                PerHourAverage     = result.PerHourAverage,
                NewTotal           = result.NewTotal,
                New                = newest,
                UniqueTotal        = result.UniqueTotal,
                MostFrequent       = mostFrequent,
                HasSubmittedErrors = project.TotalErrorCount > 0,
                IsFreePlan         = organization.PlanId == BillingManager.FreePlan.Id
            };

            foreach (var user in users.Where(u => u.EmailNotificationsEnabled))
            {
                _mailer.SendSummaryNotification(user.EmailAddress, notification);
            }

            return(null);
        }
示例#4
0
 public Task SendSummaryNotificationAsync(string emailAddress, SummaryNotificationModel notification)
 {
     return(Task.Run(() => SendSummaryNotification(emailAddress, notification)));
 }
示例#5
0
        private void ProcessSummaryNotification(SummaryNotification data)
        {
            var project      = _projectRepository.GetById(data.Id, true);
            var organization = _organizationRepository.GetById(project.OrganizationId, true);
            var userIds      = project.NotificationSettings.Where(n => n.Value.SendDailySummary).Select(n => n.Key).ToList();

            if (userIds.Count == 0)
            {
                return;
            }

            var users = _userRepository.GetByIds(userIds).Where(u => u.IsEmailAddressVerified).ToList();

            if (users.Count == 0)
            {
                return;
            }

            long count;
            var  paging = new PagingOptions {
                Limit = 5
            };
            List <Stack> newest = _stackRepository.GetNew(project.Id, data.UtcStartTime, data.UtcEndTime, paging).ToList();

            var result       = _stats.GetTermsStats(data.UtcStartTime, data.UtcEndTime, "stack_id", "project:" + data.Id, max: 5);
            var mostFrequent = result.Terms.Take(5).ToList();
            var stacks       = _stackRepository.GetByIds(mostFrequent.Select(s => s.Term).ToList());

            foreach (var frequent in mostFrequent)
            {
                var stack = stacks.SingleOrDefault(s => s.Id == frequent.Term);
                if (stack == null)
                {
                    mostFrequent.RemoveAll(r => r.Term == frequent.Term);
                    continue;
                }

                // Stat's Id and Total properties are already calculated in the Results.
                //frequent.Type = stack.SignatureInfo.ContainsKey("ExceptionType") ? stack.SignatureInfo["ExceptionType"] : null;
                //frequent.Method = stack.SignatureInfo.ContainsKey("Method") ? stack.SignatureInfo["Method"] : null;
                //frequent.Path = stack.SignatureInfo.ContainsKey("Path") ? stack.SignatureInfo["Path"] : null;
                //frequent.Is404 = stack.SignatureInfo.ContainsKey("Path");

                //frequent.Title = stack.Title;
                //frequent.First = stack.FirstOccurrence;
                //frequent.Last = stack.LastOccurrence;
            }

            var notification = new SummaryNotificationModel {
                ProjectId   = project.Id,
                ProjectName = project.Name,
                StartDate   = data.UtcStartTime,
                EndDate     = data.UtcEndTime,
                //Total = result.Total,
                //PerHourAverage = result.PerHourAverage,
                //NewTotal = result.NewTotal,
                //New = newest,
                //UniqueTotal = result.UniqueTotal,
                //MostFrequent = mostFrequent,
                //HasSubmittedErrors = project.TotalErrorCount > 0,
                IsFreePlan = organization.PlanId == BillingManager.FreePlan.Id
            };

            foreach (var user in users.Where(u => u.EmailNotificationsEnabled))
            {
                _mailer.SendSummaryNotification(user.EmailAddress, notification);
            }
        }
示例#6
0
 public void SendSummaryNotification(string emailAddress, SummaryNotificationModel notification)
 {
 }
示例#7
0
 public Task SendSummaryNotificationAsync(string emailAddress, SummaryNotificationModel notification)
 {
     return(Task.FromResult(0));
 }