private KeyValuePair <Guid, string>[] GetBadContents(ContentsAvailabilitySettings settings, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); string reportName; var report = _specialReportManager.GetSpecalReport(ReportName, true, out reportName); var badContents = report.AsEnumerable() .Select( c => new BadContent { ProviderId = (Guid)c["PROVIDER_ID"], ContentId = (Guid)c["CONTENT_ID"], Prefix = (string)c["PREFIX"], ErrorCount = (int)c["ERR_CNT"], SuccessCount = (int)c["SUCCESS_CNT"] }) .Where(c => c.ErrorCount > settings.AbsoluteErrorsThreshold || (c.ErrorCount / (c.ErrorCount + c.SuccessCount)) * 100 > settings.RelativeErrorsThreshold) ; var groupedByProviders = badContents.GroupBy(c => c.ProviderId) .Select(c => new KeyValuePair <Guid, string>(c.Key, CreateText(c))) .ToArray(); return(groupedByProviders); }
private void SendToDefaultMails(string[] badContents, ContentsAvailabilitySettings settings) { if (settings.MailAddresses == null) { _logger.Error("Не указаны адресаты по умолчанию"); } try { var body = string.Format("{0} <br /> {1}", Header, string.Join(" ", badContents)); _smtpService.Send(Subject, body, settings.MailAddresses); } catch (Exception ex) { _logger.Fatal("Не удалось отправить сообщение адресатам по умолчанию"); _logger.Info(ex, ex.Message); } }
private void SendToDefaultMails(string[] badContents, ContentsAvailabilitySettings settings) { if (settings.MailAddresses == null) _logger.Error("Не указаны адресаты по умолчанию"); try { var body = string.Format("{0} <br /> {1}", Header, string.Join(" ", badContents)); _smtpService.Send(Subject, body, settings.MailAddresses); } catch (Exception ex) { _logger.Fatal("Не удалось отправить сообщение адресатам по умолчанию"); _logger.Info(ex, ex.Message); } }
private KeyValuePair<Guid, string>[] GetBadContents(ContentsAvailabilitySettings settings, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); string reportName; var report = _specialReportManager.GetSpecalReport(ReportName, true, out reportName); var badContents = report.AsEnumerable() .Select( c => new BadContent { ProviderId = (Guid) c["PROVIDER_ID"], ContentId = (Guid) c["CONTENT_ID"], Prefix = (string) c["PREFIX"], ErrorCount = (int) c["ERR_CNT"], SuccessCount = (int) c["SUCCESS_CNT"] }) .Where(c => c.ErrorCount > settings.AbsoluteErrorsThreshold || (c.ErrorCount/(c.ErrorCount + c.SuccessCount))*100 > settings.RelativeErrorsThreshold) ; var groupedByProviders = badContents.GroupBy(c => c.ProviderId) .Select(c => new KeyValuePair<Guid, string>(c.Key, CreateText(c))) .ToArray(); return groupedByProviders; }