Exemplo n.º 1
0
 public void SendSummaryNotification(string emailAddress, SummaryNotificationModel notification) {}
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 public Task SendSummaryNotificationAsync(string emailAddress, SummaryNotificationModel notification)
 {
     return Task.FromResult(0);
 }
        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<ErrorStack> 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 = _errorStatsHelper.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;
        }
Exemplo n.º 5
0
 public Task SendSummaryNotificationAsync(string emailAddress, SummaryNotificationModel notification) {
     return Task.Run(() => SendSummaryNotification(emailAddress, notification));
 }
Exemplo n.º 6
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);
 }