Email格式: 異常通知和報表的信件,寄件人的部分,FIC 改為 公司名稱
This commit is contained in:
parent
3e9130bbf4
commit
d7586ff6a0
@ -55,7 +55,10 @@ namespace SolarPower.Quartz.Jobs
|
||||
attachments = notice.Attachment.Split(',').ToList();
|
||||
}
|
||||
|
||||
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments);
|
||||
var getCompany = noticeScheduleRepository.GetCompanyNameById(notice.Id);
|
||||
string companyName = getCompany.Result;
|
||||
|
||||
var result = Send(recipientEmails, notice.Subject, notice.Content, attachments, companyName);
|
||||
|
||||
if (result.CompareTo("成功") == 0)
|
||||
{
|
||||
@ -96,7 +99,7 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
}
|
||||
|
||||
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments)
|
||||
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments, string companyName)
|
||||
{
|
||||
var reason = string.Empty;
|
||||
var CanDoSend = true;
|
||||
@ -105,7 +108,8 @@ 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 = $"FIC 太陽能電站管理系統通知 <{smtp.UserName}>";
|
||||
var kkk = companyName + $" 太陽能電站管理系統通知 <{smtp.UserName}>";
|
||||
MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人
|
||||
foreach (var email in recipientEmails)
|
||||
{
|
||||
|
||||
@ -160,5 +160,36 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetCompanyNameById(int noticeId)
|
||||
{
|
||||
string result;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = @$"select c.Name
|
||||
from notice_schedule ns
|
||||
left join user u on ns.UserId = u.id
|
||||
left join company c on u.CompanyId = c.id
|
||||
where ns.id = {noticeId}";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<string>(sql);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,5 +12,6 @@ namespace SolarPower.Repository.Interface
|
||||
Task UpdateList(List<NoticeSchedule> noticeSchedules, List<string> properties);
|
||||
Task<List<OperationPersonnel>> GetPowerStationOperationPersonnel(int Userid);
|
||||
Task<List<NoticeScheduleTable>> GetNoticeTable(NoticeTableSearch info);
|
||||
Task<string> GetCompanyNameById(int noticeId);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user