@@ -1,6 +1,7 @@
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Learun.Application.OA.Email.EmailSend
{
@@ -14,6 +15,7 @@ namespace Learun.Application.OA.Email.EmailSend
public class EmailSendBLL : EmailSendIBLL
{
private EmailSendService emailSendService = new EmailSendService();
private ShowAuthorizeService showAuthorizeService = new ShowAuthorizeService();
#region 获取数据
/// <summary>
@@ -113,6 +115,55 @@ namespace Learun.Application.OA.Email.EmailSend
}
}
}
#endregion
/// <summary>
/// 授权到期前发送邮件提醒
/// </summary>
/// <param name="ExpirationDate">授权到期时间</param>
public void Send(string ExpirationDate)
{
try
{
//授权到期发送邮件配置信息
var showAuthorize = showAuthorizeService.GetShowAuthorizeEntity();
if (showAuthorize != null && showAuthorize.IsRemind == 1)
{
//授权到期时间
DateTime expirationDate = Convert.ToDateTime(ExpirationDate);
DateTime now = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
//计算授权到期时间与当前时间相差的天数
var ts = (expirationDate - now).Days;
//到期前{ExpirationTime}天,每天发送一封邮件
if (ts >= 0 && ts <= showAuthorize.ExpirationTime)
{
//判断今天有没有发送过邮件,如果今天已经发送,不再重复发送
if (emailSendService.GetTodayList(showAuthorize.EmailAddr).Count() <= 0)
{
//发送邮件
if (MailHelper.Send(showAuthorize.EmailAddr, showAuthorize.EmailTitle,
showAuthorize.EmailContent))
{
EmailSendEntity entity = new EmailSendEntity();
entity.F_Sender = Config.GetValue("MailUserName");
entity.F_To = showAuthorize.EmailAddr;
entity.F_Subject = showAuthorize.EmailTitle;
entity.F_BodyText = showAuthorize.EmailContent;
entity.F_Description = "授权到期提醒";
emailSendService.SaveSendEntity("", entity);
}
}
}
}
}
catch (Exception ex)
{
return;
}
}
}
}