Email格式: 異常通知、日報表、月報表、綜合報表,主旨更改

This commit is contained in:
wanling040@gmail.com 2022-08-24 19:44:08 +08:00
parent ddb2c14de9
commit d2d8fbddf1
3 changed files with 23 additions and 14 deletions

View File

@ -72,15 +72,20 @@ namespace SolarPower.Quartz.Jobs
{
Content += $"當前數值:{Exception.errValue}" + "<br>";
}
Content += $"發生時間:{Exception.dev_time}";
//Content += $"發生時間:{Exception.dev_time}";
string subTime = $",發生時間:{Exception.dev_time}";
foreach (var user in UserListWithPowerstation)
{
var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id);
string companyName = getCompany.Result;
NoticeSchedule DaySchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 4,
RecipientEmail = user.Email,
Subject = "異常通知",
Subject = companyName + "太陽能監控" + Exception.alarmClassName + "-異常通知" + subTime,
Content = Content,
RecipientName = user.Name,
Type = 1,

View File

@ -250,6 +250,9 @@ namespace SolarPower.Quartz.Jobs
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
if (stationReportName != "")
{
var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id);
string companyName = getCompany.Result;
if (user.Email != null && IsValidEmail(user.Email))
{
NoticeSchedule DaySchedule = new NoticeSchedule()
@ -257,7 +260,7 @@ namespace SolarPower.Quartz.Jobs
UserId = user.Id,
EmailType = 0,
RecipientEmail = user.Email,
Subject = "日報表",
Subject = companyName + "太陽能監控-日報表",
Attachment = stationReportName,
RecipientName = user.Name,
Type = 1
@ -290,12 +293,14 @@ namespace SolarPower.Quartz.Jobs
var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented));
if (user.Email != null && IsValidEmail(user.Email))
{
var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id);
string companyName = getCompany.Result;
NoticeSchedule MaxSchedule = new NoticeSchedule()
{
UserId = user.Id,
EmailType = 2,
RecipientEmail = user.Email,
Subject = "綜合報表",
Subject = companyName + "太陽能監控-綜合報表",
Attachment = stationMaxReportName,
RecipientName = user.Name,
Type = 1
@ -326,10 +331,12 @@ namespace SolarPower.Quartz.Jobs
var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented));
if (user.Email != null && IsValidEmail(user.Email))
{
var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id);
string companyName = getCompany.Result;
NoticeSchedule MaxmonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "綜合報表",
Subject = companyName + "太陽能監控-綜合報表",
Attachment = stationReportmaxmonthName,
RecipientName = user.Name,
Type = 1,
@ -372,10 +379,12 @@ namespace SolarPower.Quartz.Jobs
{
if (user.Email != null && IsValidEmail(user.Email))
{
var getCompany = noticeScheduleRepository.GetCompanyNameById(user.Id);
string companyName = getCompany.Result;
NoticeSchedule MonthSchedule = new NoticeSchedule()
{
RecipientEmail = user.Email,
Subject = "月報表",
Subject = companyName + "太陽能監控-月報表",
Attachment = stationReportmonthName,
RecipientName = user.Name,
Type = 1,

View File

@ -54,11 +54,7 @@ namespace SolarPower.Quartz.Jobs
{
attachments = notice.Attachment.Split(',').ToList();
}
var getCompany = noticeScheduleRepository.GetCompanyNameById(notice.Id);
string companyName = getCompany.Result;
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments, companyName);
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments);
if (result.CompareTo("成功") == 0)
{
@ -99,7 +95,7 @@ namespace SolarPower.Quartz.Jobs
}
}
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments, string companyName)
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments)
{
var reason = string.Empty;
var CanDoSend = true;
@ -108,8 +104,7 @@ namespace SolarPower.Quartz.Jobs
MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼
MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼
MyMail.IsBodyHtml = true; //是否使用html格式
//var kkk = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>";
var kkk = companyName + $" 太陽能電站管理系統通知 <{smtp.UserName}>";
var kkk = $"太陽能電站管理系統通知 <{smtp.UserName}>";
MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人
foreach (var email in recipientEmails)
{