迁移7项目签名邮件等等功能
This commit is contained in:
@@ -698,7 +698,38 @@ namespace BLL
|
||||
|
||||
#endregion
|
||||
|
||||
#region 邮箱发送
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
public const string SendEmailMenuId = "97143EDB-6A32-4BBA-9F49-E33E87912BC8";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件配置
|
||||
/// </summary>
|
||||
public const string SendEmailPopMenuId = "9E9DD8E3-D91B-4FD4-B922-2F5CC23D2745";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件记录
|
||||
/// </summary>
|
||||
public const string SendEmailLogMenuId = "5941BE0C-C262-48C7-899F-F0BE5A779926";
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱模板设置
|
||||
/// </summary>
|
||||
public const string SendEmailTemplateListMenuId = "06EB7C08-6F6E-433B-91A7-579BFC435A0C";
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱参数设置
|
||||
/// </summary>
|
||||
public const string MailParametersMenuId = "F19A6438-C757-4BC2-ADC2-72AAF02089E5";
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public const string CCType = "1";//抄送人
|
||||
|
||||
public const string SenderType = "0";//发送人
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
using BLL;
|
||||
using Model;
|
||||
using Org.BouncyCastle.Bcpg.OpenPgp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Web;
|
||||
using System.Web.Mail;
|
||||
|
||||
namespace FineUIPro.Web.common
|
||||
{
|
||||
public class MailHelper
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 私有构造方法,不允许创建实例
|
||||
/// </summary>
|
||||
private MailHelper()
|
||||
{
|
||||
// TODO: Add constructor logic here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SendNetMail(须配置SMTP服务器地址)(多个收件人、抄送人、附件其参数用";"隔开,最后一个不能有";")
|
||||
/// </summary>
|
||||
/// <param name="mailFrom">发件人</param>
|
||||
/// <param name="mailTo">收件人(多个收件人用";"隔开,最后一个不能有";")</param>
|
||||
/// <param name="mailSubject">主题</param>
|
||||
/// <param name="mailBody">内容</param>
|
||||
/// <param name="mailAttch">附件(多个附件用";"隔开,最后一个不能有";")</param>
|
||||
/// <param name="mailCode">密码(对加密过的)</param>
|
||||
/// <param name="mailPriority">优先级</param>
|
||||
/// <param name="mailCC">抄送(多个抄送人用";"隔开,最后一个不能有";")</param>
|
||||
/// <param name="resultMessage">输出信息</param>
|
||||
public static bool SendNetMail(Email_Pop ps, string mailFrom, string[] mailTo, string mailSubject, string mailBody, string mailAttch, string mailCode, string mailPriority, string[] mailCC, out string resultMessage)
|
||||
{
|
||||
//初始化输出参数
|
||||
resultMessage = "";
|
||||
|
||||
//发件人和收件人不为空
|
||||
if (string.IsNullOrEmpty(ps.EmailYx) || mailTo == null)
|
||||
{
|
||||
resultMessage = "Please Fill Email Addresser Or Addressee . ";
|
||||
return false;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(ps.EmailYx))
|
||||
{
|
||||
mailFrom = ps.EmailYx;
|
||||
}
|
||||
|
||||
//MailMessage email = new MailMessage();
|
||||
////MailAddress emailFrom = new MailAddress(mailFrom);
|
||||
|
||||
////发件人
|
||||
//email.From = new MailAddress(mailFrom, ps.EmailYx);//发件人地址
|
||||
|
||||
////收件人
|
||||
//if (mailTo != null && mailTo.Length > 0)
|
||||
//{
|
||||
// foreach (string send in mailTo)
|
||||
// {
|
||||
// if (!String.IsNullOrEmpty(send))
|
||||
// {
|
||||
// email.To.Add(send);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
////加抄送
|
||||
//if (mailCC != null && mailCC.Length > 0)
|
||||
//{
|
||||
|
||||
// foreach (string cc in mailCC)
|
||||
// {
|
||||
// if (!String.IsNullOrEmpty(cc))
|
||||
// {
|
||||
// email.CC.Add(cc);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
////主题
|
||||
//email.Subject = mailSubject;
|
||||
////内容
|
||||
//email.Body = mailBody;
|
||||
////附件
|
||||
//if (!string.IsNullOrEmpty(mailAttch))
|
||||
//{
|
||||
// string[] attachments = mailAttch.Split(';');
|
||||
// foreach (string file in attachments)
|
||||
// {
|
||||
// System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(file, System.Net.Mime.MediaTypeNames.Application.Octet);
|
||||
// //为附件添加发送时间
|
||||
// System.Net.Mime.ContentDisposition disposition = attach.ContentDisposition;
|
||||
// disposition.CreationDate = System.IO.File.GetCreationTime(file);
|
||||
// disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
|
||||
// disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
|
||||
// //添加附件
|
||||
// email.Attachments.Add(attach);
|
||||
// }
|
||||
//}
|
||||
//优先级
|
||||
//email.Priority = (mailPriority == "High") ? System.Net.Mail.MailPriority.High : System.Net.Mail.MailPriority.Normal;
|
||||
////内容编码、格式
|
||||
//email.BodyEncoding = System.Text.Encoding.UTF8;
|
||||
//email.IsBodyHtml = true;
|
||||
//SMTP服务器
|
||||
//System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(ps.EmailFwq);
|
||||
//client.EnableSsl = false;
|
||||
//client.UseDefaultCredentials = true;
|
||||
////验证(Credentials 凭证)
|
||||
//client.Credentials = new System.Net.NetworkCredential(mailFrom, ps.EmailPass);
|
||||
|
||||
////处理待发的电子邮件的方法 (Delivery 发送,传输)
|
||||
//client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
|
||||
|
||||
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
|
||||
try
|
||||
{
|
||||
mail.From = ps.EmailYx;
|
||||
mail.To = string.Join(",", mailTo);
|
||||
mail.Subject = mailSubject;
|
||||
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
|
||||
mail.Body = mailBody;
|
||||
if (mailCC != null && mailCC.Length > 0)
|
||||
mail.Cc = string.Join(",", mailCC);
|
||||
|
||||
if (!string.IsNullOrEmpty(mailAttch))
|
||||
{
|
||||
string[] arr = mailAttch.Split(',');
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
|
||||
mail.Attachments.Add(new System.Web.Mail.MailAttachment(@arr[i]));
|
||||
}
|
||||
}
|
||||
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
|
||||
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", ps.EmailYx);
|
||||
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ps.EmailPass);
|
||||
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", ps.EmailDk);
|
||||
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
|
||||
System.Web.Mail.SmtpMail.SmtpServer = ps.EmailFwq;
|
||||
System.Web.Mail.SmtpMail.Send(mail);
|
||||
BLL.ErrLogInfo.WriteLog("开始发送邮件");
|
||||
//发送邮件
|
||||
//client.Send(email);
|
||||
BLL.ErrLogInfo.WriteLog("发送中...");
|
||||
if (mailTo != null && mailTo.Length > 0)
|
||||
{
|
||||
foreach (string send in mailTo)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(send))
|
||||
{
|
||||
Email_SendLog newSendEmail = new Email_SendLog();
|
||||
newSendEmail.EmailId = Guid.NewGuid().ToString();
|
||||
newSendEmail.EmailTile = mailSubject;
|
||||
newSendEmail.EmailContent = mailBody;
|
||||
newSendEmail.EmailURL = send;
|
||||
newSendEmail.EmailName = send;
|
||||
newSendEmail.EmailStatus = "发送成功";
|
||||
newSendEmail.CreateTime = DateTime.Now;
|
||||
newSendEmail.CreateName = "sys";
|
||||
BLL.Email_Send.Email_SendLogService.AddEmail_SendLog(newSendEmail);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog(ex, "发送邮件失败");
|
||||
if (mailTo != null && mailTo.Length > 0)
|
||||
{
|
||||
List<Email_SendLog> ss = new List<Email_SendLog>();
|
||||
foreach (string send in mailTo)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(send))
|
||||
{
|
||||
Email_SendLog newSendEmail = new Email_SendLog();
|
||||
newSendEmail.EmailId = Guid.NewGuid().ToString();
|
||||
newSendEmail.EmailTile = mailSubject;
|
||||
newSendEmail.EmailContent = mailBody;
|
||||
newSendEmail.EmailURL = send;
|
||||
newSendEmail.EmailName = send;
|
||||
newSendEmail.EmailStatus = "发送失败";
|
||||
newSendEmail.CreateTime = DateTime.Now;
|
||||
newSendEmail.ErrorMsg = ex.Message;
|
||||
newSendEmail.CreateName = "sys";
|
||||
BLL.Email_Send.Email_SendLogService.AddEmail_SendLog(newSendEmail);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultMessage = ex.Message;
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//及时释放占用的资源
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Email_Pop getEmailPop()
|
||||
{
|
||||
var pp = Funs.DB.Email_Pop.FirstOrDefault();
|
||||
|
||||
return pp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,30 @@ namespace BLL
|
||||
|
||||
public static class Sys_UserService
|
||||
{
|
||||
public static (string, string) GetSingtrueImageUrl(string userId)
|
||||
{
|
||||
var result = (from a in Funs.DB.Sys_User
|
||||
join
|
||||
b in Funs.DB.Base_Unit on a.UnitId equals b.UnitId
|
||||
into bb
|
||||
from bu in bb.DefaultIfEmpty()
|
||||
join c in Funs.DB.Base_UnitType on bu.UnitTypeId equals c.UnitTypeId
|
||||
into dd
|
||||
from ss in dd.DefaultIfEmpty()
|
||||
where a.UserId == userId
|
||||
select new
|
||||
{
|
||||
a.SigntrueImage,
|
||||
ss.UnitTypeName
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return (result.SigntrueImage, result.UnitTypeName);
|
||||
}
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户登陆方法
|
||||
/// </summary>
|
||||
@@ -220,6 +244,7 @@ namespace BLL
|
||||
newUser.Email = user.Email;
|
||||
newUser.EmailPassword = user.EmailPassword;
|
||||
newUser.AllowLoginSystem = user.AllowLoginSystem;
|
||||
newUser.SigntrueImage = user.SigntrueImage;
|
||||
|
||||
db.Sys_User.InsertOnSubmit(newUser);
|
||||
db.SubmitChanges();
|
||||
@@ -243,6 +268,7 @@ namespace BLL
|
||||
newUser.RoleIds = user.RoleIds;
|
||||
newUser.IsPost = user.IsPost;
|
||||
newUser.Email = user.Email;
|
||||
newUser.SigntrueImage = user.SigntrueImage;
|
||||
if (!String.IsNullOrEmpty(user.EmailPassword))
|
||||
{
|
||||
newUser.EmailPassword = user.EmailPassword;
|
||||
|
||||
Reference in New Issue
Block a user