11
This commit is contained in:
@@ -302,7 +302,6 @@ namespace FineUIPro.Web.SES
|
||||
punishment.PunishmentId = PunishmentId;
|
||||
BLL.PunishmentService.UpdatePunishment(punishment);
|
||||
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify Contractor Safety Punishment!");
|
||||
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -310,59 +309,83 @@ namespace FineUIPro.Web.SES
|
||||
punishment.PunishmentId = PunishmentId;
|
||||
punishment.CreateDate = DateTime.Now;
|
||||
BLL.PunishmentService.AddPunishment(punishment);
|
||||
|
||||
#region 承包商EHSS违规关联SES号的填写通知 改在Golbal里触发
|
||||
//Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||||
//if (pops == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//string[] mailTo = null;
|
||||
//string[] mailCC = null;
|
||||
//string resultMessage = "";
|
||||
|
||||
//var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("承包商EHSS违规关联SES号的填写通知"));
|
||||
//if (emailTemplate.Count() > 0)
|
||||
//{
|
||||
// var dep = BLL.DepartService.GetDepartById(drpBYC_RU.SelectedValue);
|
||||
// if (dep != null && !string.IsNullOrEmpty(dep.DepartLeader))
|
||||
// {
|
||||
// var userTo = from x in Funs.DB.Sys_User
|
||||
// where x.UserId == dep.DepartLeader
|
||||
// && x.Email != null && x.Email != ""
|
||||
// select x;
|
||||
// if (userTo != null)
|
||||
// {
|
||||
// mailTo = userTo.Select(x => x.Email).ToArray();
|
||||
// }
|
||||
|
||||
// var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(drpFO_No.SelectedValue);
|
||||
// if (fo != null)
|
||||
// {
|
||||
// var userCC = from x in Funs.DB.Sys_User
|
||||
// where (x.UserId == fo.Contract_Admin || x.UserId == fo.Main_Coordinator)
|
||||
// && x.Email != null && x.Email != ""
|
||||
// select x;
|
||||
// mailCC = userCC.Select(x => x.Email).Distinct().ToArray();
|
||||
// }
|
||||
|
||||
// if (mailTo.Length > 0)
|
||||
// {
|
||||
// NameValueCollection myPram = new NameValueCollection();
|
||||
// myPram.Add("ContractNo", fo.FO_NO);
|
||||
// myPram.Add("Contractor", drpContractor.SelectedText);
|
||||
// myPram.Add("Date", punishment.PunishDate != null ? punishment.PunishDate.Value.ToString("yyyy-MM-dd") : "");
|
||||
// myPram.Add("Time", punishment.PunishDate != null ? punishment.PunishDate.Value.ToString("HH:mm") : "");
|
||||
// myPram.Add("Violation Description", punishment.Description);
|
||||
// MailHelper.SendPunishSesMail(pops, myPram, "承包商EHSS违规关联SES号的填写通知", mailTo, mailCC, out resultMessage);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Add Contractor Safety Punishment!");
|
||||
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
||||
}
|
||||
|
||||
#region 承包商EHSS违规关联SES号的填写通知
|
||||
var vses = (from x in Funs.DB.EMC_Punishment
|
||||
where (x.RelatedSesMailIsSend == null || x.RelatedSesMailIsSend == false)
|
||||
&& x.BYC_RU != null && x.BYC_RU.ToUpper() != "NA" && x.Flag == "1"
|
||||
&& x.PunishmentId== punishment.PunishmentId
|
||||
select x).ToList();
|
||||
if (vses.Count() > 0)
|
||||
{
|
||||
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||||
if (pops == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var ses in vses)
|
||||
{
|
||||
string[] mailTo = null;
|
||||
string[] mailCC = null;
|
||||
string resultMessage = "";
|
||||
|
||||
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("承包商EHSS违规关联SES号的填写通知"));
|
||||
if (emailTemplate.Count() > 0)
|
||||
{
|
||||
var dep = BLL.DepartService.GetDepartById(ses.BYC_RU);
|
||||
if (dep != null && !string.IsNullOrEmpty(dep.DepartLeader))
|
||||
{
|
||||
var userTo = from x in Funs.DB.Sys_User
|
||||
where x.UserId == dep.DepartLeader
|
||||
&& x.Email != null && x.Email != ""
|
||||
select x;
|
||||
if (userTo != null)
|
||||
{
|
||||
mailTo = userTo.Select(x => x.Email).ToArray();
|
||||
}
|
||||
|
||||
string contractor = string.Empty;
|
||||
var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(ses.FO_NO);
|
||||
if (fo != null)
|
||||
{
|
||||
var userCC = from x in Funs.DB.Sys_User
|
||||
where (x.UserId == fo.Contract_Admin || x.UserId == fo.Main_Coordinator)
|
||||
&& x.Email != null && x.Email != ""
|
||||
select x;
|
||||
mailCC = userCC.Select(x => x.Email).Distinct().ToArray();
|
||||
|
||||
var con = Funs.DB.View_Contractor_DropDownValue.FirstOrDefault(x => x.ContractorId == fo.Contractor);
|
||||
if (con != null)
|
||||
{
|
||||
contractor = con.Contractor;
|
||||
}
|
||||
}
|
||||
|
||||
if (mailTo.Length > 0)
|
||||
{
|
||||
NameValueCollection myPram = new NameValueCollection();
|
||||
myPram.Add("ContractNo", fo.FO_NO);
|
||||
myPram.Add("Contractor", contractor);
|
||||
myPram.Add("Date", ses.PunishDate != null ? ses.PunishDate.Value.ToString("yyyy-MM-dd") : "");
|
||||
myPram.Add("Time", ses.PunishDate != null ? ses.PunishDate.Value.ToString("HH:mm") : "");
|
||||
myPram.Add("Violation Description", ses.Description);
|
||||
bool result = MailHelper.SendPunishSesMail(pops, myPram, "承包商EHSS违规关联SES号的填写通知", mailTo, mailCC, out resultMessage);
|
||||
|
||||
if (result)
|
||||
{
|
||||
ses.RelatedSesMailIsSend = true;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
ShowNotify("Save successfully!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user