1684 lines
82 KiB
C#
1684 lines
82 KiB
C#
namespace FineUIPro.Web
|
||
{
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Collections.Specialized;
|
||
using System.Configuration;
|
||
using System.Globalization;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Web;
|
||
using BLL;
|
||
using BLL.Common;
|
||
using FineUIPro.Web.common;
|
||
using Model;
|
||
using NPOI.SS.Formula.Functions;
|
||
|
||
public class Global : System.Web.HttpApplication
|
||
{
|
||
/// <summary>
|
||
/// 自动启用插件标志文件路径
|
||
/// </summary>
|
||
private static string applicationActiveFlagFilePhysicalPath = String.Empty;
|
||
|
||
protected void Application_Start(object sender, EventArgs e)
|
||
{
|
||
|
||
Application["OnlineUserCount"] = 0;
|
||
try
|
||
{
|
||
Funs.RootPath = Server.MapPath("~/");
|
||
// 日志文件所在目录
|
||
ErrLogInfo.DefaultErrLogFullPath = Server.MapPath("~/ErrLog.txt");
|
||
Funs.ClientId = ConfigurationManager.AppSettings["clientId"];
|
||
Funs.ClientSecret = ConfigurationManager.AppSettings["clientSecret"];
|
||
Funs.Redirect_url = ConfigurationManager.AppSettings["redirect_url"];
|
||
|
||
Funs.SystemName = ConfigurationManager.AppSettings["SystemName"];
|
||
Funs.ConnString = ConfigurationManager.ConnectionStrings["FCLDBConnectionString"].ConnectionString;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog(ex);
|
||
AppDomain.Unload(AppDomain.CurrentDomain);
|
||
}
|
||
|
||
|
||
//每月(2,5,8,10)邮件自动发送给SSR提交人员和主协调人及合同员,用户代表等评价
|
||
if ((DateTime.Now.Day == 2 || DateTime.Now.Day == 5 || DateTime.Now.Day == 8 || DateTime.Now.Day == 10))
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_Elapsed);
|
||
//60分钟执行一次
|
||
aTimer.Interval = 1000 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
|
||
}
|
||
//自动填写评价
|
||
if (DateTime.Now.Day == 12)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_AutoFill);
|
||
//30分钟执行一次
|
||
aTimer.Interval = 1800000;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
|
||
}
|
||
|
||
// 过期提示
|
||
//var foList = from x in Funs.DB.FC_SESRelatedData
|
||
// where x.Expire_Date != null
|
||
// && x.Expire_Date.Value.AddMonths(-6).Date <= DateTime.Now.Date
|
||
// && x.Expire_Date.Value.AddMonths(-5).Date >= DateTime.Now.Date
|
||
// select x;
|
||
if (DateTime.Now.Hour == 10)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_AutoSend);
|
||
//60分钟执行一次
|
||
aTimer.Interval = 1000 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
|
||
}
|
||
|
||
// 框架承包商评估表的填写邮件通知
|
||
if (DateTime.Now.Hour == 15)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_FC_AutoSend);
|
||
//4小时执行一次
|
||
aTimer.Interval = 1000 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
}
|
||
|
||
// 更新FC_SESRelatedData表中FC_Status状态
|
||
if (DateTime.Now.Hour == 15)
|
||
{
|
||
System.Timers.Timer fcTimer = new System.Timers.Timer();
|
||
fcTimer.Elapsed += new System.Timers.ElapsedEventHandler(FC_AutoStatus);
|
||
//120分钟执行一次
|
||
fcTimer.Interval = 1000 * 60 * 60;
|
||
fcTimer.Enabled = true;
|
||
fcTimer.Start();
|
||
}
|
||
|
||
// 每天9点自动执行ReturnStatus
|
||
if (DateTime.Now.Hour == 9)
|
||
{
|
||
System.Timers.Timer upTimer = new System.Timers.Timer();
|
||
upTimer.Elapsed += new System.Timers.ElapsedEventHandler(upTimer_AutoReturnStatus);
|
||
//60分钟执行一次
|
||
upTimer.Interval = 1000 * 60 * 60;
|
||
upTimer.Enabled = true;
|
||
upTimer.Start();
|
||
}
|
||
|
||
// 承包商资质提前3个过期提示
|
||
var queListOne = from x in Funs.DB.EMC_Contractor_Qualification
|
||
join y in Funs.DB.FC_SESRelatedData on x.FoId equals y.ID
|
||
where x.LimitEndDate != null && y.FC_Status == "Valid"
|
||
&& x.LimitEndDate.Value.AddMonths(-3).Date <= DateTime.Now.Date
|
||
&& x.LimitEndDate.Value.AddMonths(-3).AddDays(15).Date >= DateTime.Now.Date
|
||
select x;
|
||
if (queListOne.Count() > 0)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(queTimer_AutoSendOne);
|
||
//2小时执行一次
|
||
aTimer.Interval = 1000 * 60 * 60 * 2;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
|
||
}
|
||
|
||
// 承包商资质提前1个过期提示
|
||
var queListTwo = from x in Funs.DB.EMC_Contractor_Qualification
|
||
join y in Funs.DB.FC_SESRelatedData on x.FoId equals y.ID
|
||
where x.LimitEndDate != null && y.FC_Status == "Valid"
|
||
&& x.LimitEndDate.Value.AddMonths(-1).Date <= DateTime.Now.Date
|
||
&& x.LimitEndDate.Value.AddMonths(-1).AddDays(15).Date >= DateTime.Now.Date
|
||
select x;
|
||
if (queListTwo.Count() > 0)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(queTimer_AutoSendTwo);
|
||
//60分钟执行一次
|
||
aTimer.Interval = 1000 * 2 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
|
||
}
|
||
|
||
// 承包商EHSS违规关联SES号的填写通知
|
||
if (DateTime.Now.Hour == 10)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(Safe_RelatedSes_EmailSend);
|
||
//60分钟执行一次
|
||
aTimer.Interval = 1000 * 3 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
}
|
||
|
||
// 承包商质量违规关联SES号的填写通知
|
||
if (DateTime.Now.Hour == 10)
|
||
{
|
||
System.Timers.Timer aTimer = new System.Timers.Timer();
|
||
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(CQuality_RelatedSes_EmailSend);
|
||
//60分钟执行一次
|
||
aTimer.Interval = 1000 * 3 * 60 * 60;
|
||
aTimer.Enabled = true;
|
||
aTimer.Start();
|
||
}
|
||
|
||
// 启动接口
|
||
if (DateTime.Now.Hour == 17)
|
||
{
|
||
System.Timers.Timer fcTimer = new System.Timers.Timer();
|
||
fcTimer.Elapsed += new System.Timers.ElapsedEventHandler(Sync_HR);
|
||
//12小时执行一次
|
||
fcTimer.Interval = 1000 * 60 * 60 * 12;
|
||
fcTimer.Enabled = true;
|
||
fcTimer.Start();
|
||
}
|
||
}
|
||
|
||
private void queTimer_AutoSendOne(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
// 承包商资质提前3个过期提示
|
||
var queList = from x in Funs.DB.EMC_Contractor_Qualification
|
||
join y in Funs.DB.FC_SESRelatedData on x.FoId equals y.ID
|
||
where x.LimitEndDate != null && y.FC_Status == "Valid"
|
||
&& x.LimitEndDate.Value.AddMonths(-3).Date <= DateTime.Now.Date
|
||
&& x.LimitEndDate.Value.AddMonths(-3).AddDays(15).Date >= DateTime.Now.Date
|
||
select x;
|
||
if (queList.Count() > 0)
|
||
{
|
||
foreach (var que in queList)
|
||
{
|
||
var fo = BLL.SESRelatedDataService.GetSESRelatedDataById(que.FoId.ToString());
|
||
var contractor = BLL.ContractorService.GetContractorById(fo.Contractor);
|
||
List<Model.Sys_User> userList = new List<Sys_User>();
|
||
EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||
if (pops == null)
|
||
{
|
||
return;
|
||
}
|
||
string[] mailTo = null;
|
||
string mailSubject = string.Empty;
|
||
string mailBody = string.Empty;
|
||
string mailPriority = string.Empty;
|
||
string[] mailCC = null;
|
||
string resultMessage = "";
|
||
string departId = string.Empty;
|
||
string userName = string.Empty;
|
||
|
||
|
||
// 营业执照
|
||
if (que.QueType == "1")
|
||
{
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
mailTo = contractAdmin.Select(x => x.Email).ToArray();
|
||
userName = contractAdmin.First().UserName;
|
||
departId = contractAdmin.First().DepartId;
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 专业资质
|
||
if (que.QueType == "2")
|
||
{
|
||
var mainCoord = from x in Funs.DB.Sys_User where x.UserId == fo.Main_Coordinator && x.Email != null && x.Email != "" select x;
|
||
if (mainCoord.Count() > 0)
|
||
{
|
||
mailTo = mainCoord.Select(x => x.Email).ToArray();
|
||
userName = mainCoord.First().UserName;
|
||
departId = mainCoord.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 安全资质
|
||
if (que.QueType == "3")
|
||
{
|
||
var cts = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != "" && (y.RoleName == "CTS/S")
|
||
select x;
|
||
if (cts.Count() > 0)
|
||
{
|
||
mailTo = cts.Select(x => x.Email).ToArray();
|
||
userName = cts.First().UserName;
|
||
departId = cts.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader" || y.RoleName == "CTE/D Manager")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 环保资质
|
||
if (que.QueType == "4")
|
||
{
|
||
var cts = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != "" && (y.RoleName == "CTS/Safe")
|
||
select x;
|
||
if (cts.Count() > 0)
|
||
{
|
||
mailTo = cts.Select(x => x.Email).ToArray();
|
||
userName = cts.First().UserName;
|
||
departId = cts.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader" || y.RoleName == "CTE/D Manager")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
//mailCode = userName + "|" + contractor.Contractor + " " + contractor.ContractorCN + "|" + que.QueName + "|" + que.LimitEndDate.Value.ToShortDateString();
|
||
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功"
|
||
&& p.EmailTile.Contains("资质到期提醒一次") && p.EmailTile.Contains(que.QueName)
|
||
&& p.EmailTile.Contains(fo.FO_NO) && mailTo.Contains(p.EmailURL));
|
||
if (email.Count() > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("资质到期提醒"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
myCol.Add("QuaName_En", que.QueName);
|
||
myCol.Add("ContractNo_En", fo.FO_NO);
|
||
myCol.Add("Contractor_En", contractor.Contractor);
|
||
myCol.Add("Expire_En", que.LimitEndDate.Value.ToShortDateString());
|
||
|
||
|
||
myCol.Add("ContractNo", fo.FO_NO);
|
||
myCol.Add("Contractor", (contractor.ContractorCN != null && contractor.ContractorCN!="") ? contractor.ContractorCN : contractor.Contractor);
|
||
myCol.Add("QuaName", que.QueName);
|
||
myCol.Add("Expire", que.LimitEndDate.Value.ToShortDateString());
|
||
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
|
||
string mailName = EmailTemplate.Select(p => p.EmailName).FirstOrDefault();
|
||
NameValueCollection myCol1 = new NameValueCollection();
|
||
myCol1.Add("ContractNo", fo.FO_NO);
|
||
myCol1.Add("QuaName", que.QueName);
|
||
myCol1.Add("Contractor", contractor.Contractor + " " + contractor.ContractorCN);
|
||
mailSubject = TemplateHelper.BulidByFile2(mailName, myCol1);
|
||
|
||
MailHelper.SendNetMail2(pops, pops.EmailYx, mailTo, mailSubject, mailBody, mailPriority, mailCC, "一次", out resultMessage);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private void queTimer_AutoSendTwo(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
// 承包商资质提前1个过期提示
|
||
var queList = from x in Funs.DB.EMC_Contractor_Qualification
|
||
join y in Funs.DB.FC_SESRelatedData on x.FoId equals y.ID
|
||
where x.LimitEndDate != null && y.FC_Status == "Valid"
|
||
&& x.LimitEndDate.Value.AddMonths(-1).Date <= DateTime.Now.Date
|
||
&& x.LimitEndDate.Value.AddMonths(-1).AddDays(15).Date >= DateTime.Now.Date
|
||
select x;
|
||
if (queList.Count() > 0)
|
||
{
|
||
foreach (var que in queList)
|
||
{
|
||
var fo = BLL.SESRelatedDataService.GetSESRelatedDataById(que.FoId.ToString());
|
||
var contractor = BLL.ContractorService.GetContractorById(fo.Contractor);
|
||
List<Model.Sys_User> userList = new List<Sys_User>();
|
||
EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||
if (pops == null)
|
||
{
|
||
return;
|
||
}
|
||
string[] mailTo = null;
|
||
string mailBody = string.Empty;
|
||
|
||
string mailSubject = string.Empty;
|
||
string mailPriority = string.Empty;
|
||
string[] mailCC = null;
|
||
string resultMessage = "";
|
||
string departId = string.Empty;
|
||
string userName = string.Empty;
|
||
|
||
// 营业执照
|
||
if (que.QueType == "1")
|
||
{
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
mailTo = contractAdmin.Select(x => x.Email).ToArray();
|
||
userName = contractAdmin.First().UserName;
|
||
departId = contractAdmin.First().DepartId;
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 专业资质
|
||
if (que.QueType == "2")
|
||
{
|
||
var mainCoord = from x in Funs.DB.Sys_User where x.UserId == fo.Main_Coordinator && x.Email != null && x.Email != "" select x;
|
||
if (mainCoord.Count() > 0)
|
||
{
|
||
mailTo = mainCoord.Select(x => x.Email).ToArray();
|
||
userName = mainCoord.First().UserName;
|
||
departId = mainCoord.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 安全资质
|
||
if (que.QueType == "3")
|
||
{
|
||
var cts = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != "" && (y.RoleName == "CTS/S")
|
||
select x;
|
||
if (cts.Count() > 0)
|
||
{
|
||
mailTo = cts.Select(x => x.Email).ToArray();
|
||
userName = cts.First().UserName;
|
||
departId = cts.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader" || y.RoleName == "CTE/D Manager")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
// 环保资质
|
||
if (que.QueType == "4")
|
||
{
|
||
var cts = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != "" && (y.RoleName == "CTS/Safe")
|
||
select x;
|
||
if (cts.Count() > 0)
|
||
{
|
||
mailTo = cts.Select(x => x.Email).ToArray();
|
||
userName = cts.First().UserName;
|
||
departId = cts.First().DepartId;
|
||
}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
|
||
var depart = BLL.DepartService.GetDepartById(departId);
|
||
if (depart != null)
|
||
{
|
||
var ccd = from x in Funs.DB.Sys_User
|
||
where x.Email != null && x.Email != ""
|
||
&& x.UserId == depart.DepartLeader
|
||
select x;
|
||
if (ccd.Count() > 0)
|
||
{
|
||
userList.Add(ccd.First());
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader" || y.RoleName == "CTE/D Manager")
|
||
select x;
|
||
if (cc.Count() > 0)
|
||
{
|
||
foreach (var c in cc)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCC = userList.Select(x => x.Email).ToArray();
|
||
}
|
||
|
||
//mailCode = userName + "|" + contractor.Contractor + " " + contractor.ContractorCN + "|" + que.QueName + "|" + que.LimitEndDate.Value.ToShortDateString();
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功"
|
||
&& p.EmailTile.Contains("资质到期提醒二次") && p.EmailTile.Contains(que.QueName)
|
||
&& p.EmailTile.Contains(fo.FO_NO) && mailTo.Contains(p.EmailURL));
|
||
if (email.Count() > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("资质到期提醒"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
myCol.Add("QuaName_En", que.QueName);
|
||
myCol.Add("ContractNo_En", fo.FO_NO);
|
||
myCol.Add("Contractor_En", contractor.Contractor);
|
||
myCol.Add("Expire_En", que.LimitEndDate.Value.ToShortDateString());
|
||
|
||
|
||
myCol.Add("ContractNo", fo.FO_NO);
|
||
myCol.Add("Contractor", (contractor.ContractorCN != null && contractor.ContractorCN != "") ? contractor.ContractorCN : contractor.Contractor);
|
||
myCol.Add("QuaName", que.QueName);
|
||
myCol.Add("Expire", que.LimitEndDate.Value.ToShortDateString());
|
||
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
|
||
string mailName = EmailTemplate.Select(p => p.EmailName).FirstOrDefault();
|
||
NameValueCollection myCol1 = new NameValueCollection();
|
||
myCol1.Add("ContractNo", fo.FO_NO);
|
||
myCol1.Add("QuaName", que.QueName);
|
||
myCol1.Add("Contractor", contractor.Contractor + " " + contractor.ContractorCN);
|
||
mailSubject = TemplateHelper.BulidByFile2(mailName, myCol1);
|
||
|
||
MailHelper.SendNetMail2(pops, pops.EmailYx, mailTo, mailSubject, mailBody, mailPriority, mailCC, "二次", out resultMessage);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
private void aTimer_AutoSend(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
// 过期提示,30天范围
|
||
var foList = from x in Funs.DB.FC_SESRelatedData where x.Expire_Date != null
|
||
&& x.Expire_Date.Value.AddMonths(-6).AddDays(-7).Date <= DateTime.Now.Date
|
||
&& x.Expire_Date.Value.AddMonths(-5).AddDays(-7).Date >= DateTime.Now.Date
|
||
select x;
|
||
if (foList.Count() > 0)
|
||
{
|
||
foreach (var fo in foList)
|
||
{
|
||
List<Model.Sys_User> userList = new List<Sys_User>();
|
||
EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||
if (pops == null)
|
||
{
|
||
return;
|
||
}
|
||
string[] mailTo = null;
|
||
string mailBody = string.Empty;
|
||
string mailAttch = string.Empty;
|
||
string mailCode = string.Empty;
|
||
string mailPriority = string.Empty;
|
||
string[] mailCC = null;
|
||
string resultMessage = "";
|
||
string departId = string.Empty;
|
||
|
||
var contractor = BLL.ContractorService.GetContractorById(fo.Contractor);
|
||
var discipline = BLL.DisciplineService.GetDisciplineById(fo.DisciplineId);
|
||
string disc = discipline.Discipline.Replace("\r\n", " ");
|
||
if (!string.IsNullOrEmpty(discipline.DisciplineCN))
|
||
{
|
||
disc = disc + " " + discipline.DisciplineCN;
|
||
}
|
||
|
||
mailCode = fo.FO_NO + "|" + disc + "|" + contractor.Contractor + " " + contractor.ContractorCN;
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
|
||
var buyer = from x in Funs.DB.Sys_User where x.UserName == fo.Buyer && x.Email != null && x.Email != "" select x;
|
||
if (buyer.Count() > 0)
|
||
{
|
||
userList.Add(buyer.First());
|
||
mailCode = mailCode + "|" + buyer.First().UserName;
|
||
}
|
||
else
|
||
{
|
||
mailCode = mailCode + "|" + "";
|
||
}
|
||
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
mailCode = mailCode + "|" + contractAdmin.First().UserName;
|
||
}
|
||
else
|
||
{
|
||
mailCode = mailCode + "|" + "";
|
||
}
|
||
|
||
var mainCoor = from x in Funs.DB.Sys_User where x.UserId == fo.Main_Coordinator && x.Email != null && x.Email != "" select x;
|
||
if (mainCoor.Count() > 0)
|
||
{
|
||
userList.Add(mainCoor.First());
|
||
mailCode = mailCode + "|" + mainCoor.First().UserName;
|
||
|
||
string depId = mainCoor.First().DepartId;
|
||
if (!string.IsNullOrEmpty(depId))
|
||
{
|
||
string dep = BLL.DepartService.GetDepartNameById(depId);
|
||
if (dep.Length >= 3)
|
||
{
|
||
string departName = dep.Substring(0, 3);
|
||
var d = BLL.DepartService.GetDepartByName(departName);
|
||
departId = d.DepartId;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
mailCode = mailCode + "|" + "";
|
||
}
|
||
|
||
var userRepresentative = from x in Funs.DB.Sys_User where x.UserId == fo.User_Representative && x.Email != null && x.Email != "" select x;
|
||
if (userRepresentative.Count() > 0)
|
||
{
|
||
userList.Add(userRepresentative.First());
|
||
mailCode = mailCode + "|" + userRepresentative.First().UserName;
|
||
}
|
||
else
|
||
{
|
||
mailCode = mailCode + "|" + "";
|
||
}
|
||
|
||
var cost = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
join z in Funs.DB.Base_Depart on x.DepartId equals z.DepartId
|
||
where (y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader" || z.DepartCode== "CT/K") && x.Email != null && x.Email != ""
|
||
select x;
|
||
if (cost.Count() > 0)
|
||
{
|
||
foreach (var c in cost)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
mailCode = mailCode + "|" + fo.Expire_Date.Value.ToShortDateString();
|
||
|
||
//把CGP/S采购经理Purchasing Manager 改为fc list该合同的采购员buyer对应的部门leader
|
||
string deparatLeader = string.Empty;
|
||
if (!string.IsNullOrEmpty(fo.BuyerId))
|
||
{
|
||
var bu = from x in Funs.DB.Sys_User where x.UserId == fo.BuyerId select x;
|
||
if (bu != null && !string.IsNullOrEmpty(bu.FirstOrDefault().DepartId))
|
||
{
|
||
var de = from x in Funs.DB.Base_Depart where x.DepartId == bu.FirstOrDefault().DepartId select x;
|
||
if (de != null && !string.IsNullOrEmpty(de.FirstOrDefault().DepartLeader))
|
||
{
|
||
deparatLeader = de.FirstOrDefault().DepartLeader;
|
||
}
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "CTE/D Manager" || x.UserId== deparatLeader || y.RoleName == "CGP Director" || (y.RoleName== "CT Director" && x.DepartId== departId))
|
||
select x;
|
||
|
||
mailTo = userList.Select(x => x.Email).ToArray();
|
||
mailCC = cc.Select(x => x.Email).ToArray();
|
||
|
||
//var nowDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
|
||
//&& p.CreateTime.Value >= nowDate
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功"
|
||
&& p.EmailTile.Contains("到期提醒") && p.EmailTile.Contains(discipline.Discipline.Replace("\r\n", ""))
|
||
&& p.EmailTile.Contains(fo.FO_NO) && mailTo.Contains(p.EmailURL)).ToList();
|
||
if (email.Count > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("ExpiredSoon"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
MailHelper.SendNetMail1(pops, pops.EmailYx, mailTo, "工程维修施工合同-" + fo.FO_NO + ":" + discipline.Discipline.Replace("\r\n", "") + " 到期提醒", mailBody, mailAttch, mailCode, mailPriority, mailCC, null, out resultMessage);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#region 框架合同评估表填写通知
|
||
private void aTimer_FC_AutoSend(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
// 过期提示,30天范围
|
||
var foList = from x in Funs.DB.FC_SESRelatedData
|
||
where x.Expire_Date != null
|
||
&& x.Expire_Date.Value.AddMonths(-6).AddDays(-7) <= DateTime.Now.Date
|
||
&& x.Expire_Date.Value.AddMonths(-5).AddDays(-7) >= DateTime.Now.Date
|
||
select x;
|
||
if (foList.Count() > 0)
|
||
{
|
||
foreach (var fo in foList)
|
||
{
|
||
List<Model.Sys_User> userList = new List<Sys_User>();
|
||
EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||
if (pops == null)
|
||
{
|
||
return;
|
||
}
|
||
string[] mailTo = null;
|
||
string mailBody = string.Empty;
|
||
string mailAttch = string.Empty;
|
||
string mailCode = string.Empty;
|
||
string mailPriority = string.Empty;
|
||
string[] mailCC = null;
|
||
string resultMessage = "";
|
||
string departId = string.Empty;
|
||
|
||
|
||
var discipline = BLL.DisciplineService.GetDisciplineById(fo.DisciplineId);
|
||
//string disc = discipline.Discipline;
|
||
//if (!string.IsNullOrEmpty(discipline.DisciplineCN))
|
||
//{
|
||
// disc = disc + " " + discipline.DisciplineCN;
|
||
//}
|
||
|
||
var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x;
|
||
if (contractAdmin.Count() > 0)
|
||
{
|
||
userList.Add(contractAdmin.First());
|
||
}
|
||
var buyer = from x in Funs.DB.Sys_User where x.UserId == fo.BuyerId && x.Email != null && x.Email != "" select x;
|
||
if (buyer.Count() > 0)
|
||
{
|
||
userList.Add(buyer.First());
|
||
}
|
||
var mainCoor = from x in Funs.DB.Sys_User where x.UserId == fo.Main_Coordinator && x.Email != null && x.Email != "" select x;
|
||
if (mainCoor.Count() > 0)
|
||
{
|
||
userList.Add(mainCoor.First());
|
||
}
|
||
var userRepresentative = from x in Funs.DB.Sys_User where x.UserId == fo.User_Representative && x.Email != null && x.Email != "" select x;
|
||
if (userRepresentative.Count() > 0)
|
||
{
|
||
userList.Add(userRepresentative.First());
|
||
}
|
||
|
||
//var ctk = from x in Funs.DB.Sys_User
|
||
// join z in Funs.DB.Base_Depart on x.DepartId equals z.DepartId
|
||
// where z.DepartCode == "CT/K" && x.Email != null && x.Email != ""
|
||
// select x;
|
||
//if (ctk.Count() > 0)
|
||
//{
|
||
// foreach (var c in ctk)
|
||
// {
|
||
// userList.Add(c);
|
||
// }
|
||
//}
|
||
|
||
var ctss = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where y.RoleName == "CTS/S" && x.Email != null && x.Email != ""
|
||
select x;
|
||
if (ctss.Count() > 0)
|
||
{
|
||
foreach (var c in ctss)
|
||
{
|
||
userList.Add(c);
|
||
}
|
||
}
|
||
|
||
var cc = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
||
where x.Email != null && x.Email != ""
|
||
&& (y.RoleName == "CTE/D Manager" || y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader")
|
||
select x;
|
||
|
||
mailTo = userList.Select(x => x.Email).Distinct().ToArray();
|
||
mailCC = cc.Select(x => x.Email).ToArray();
|
||
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功"
|
||
&& p.EmailTile.Contains("框架合同评估表") && p.EmailTile.Contains(discipline.Discipline.Replace("\r\n", ""))
|
||
&& p.EmailTile.Contains(fo.FO_NO) && mailTo.Contains(p.EmailURL)).ToList();
|
||
if (email.Count > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("框架合同评估"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
MailHelper.SendNetMail1(pops, pops.EmailYx, mailTo, fo.FO_NO + "-" + discipline.Discipline.Replace("\r\n", "") + " 框架合同评估表填写通知", mailBody, mailAttch, mailCode, mailPriority, mailCC, null, out resultMessage);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 每月(2,5,8,10)邮件自动发送给SSR提交人员和主协调人及合同员,用户代表等评价
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void aTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
|
||
if (pops == null)
|
||
{
|
||
return;
|
||
}
|
||
string[] mailTo = null;
|
||
string mailBody = string.Empty;
|
||
string mailAttch = string.Empty;
|
||
string mailCode = string.Empty;
|
||
string mailPriority = string.Empty;
|
||
string[] mailCC = null;
|
||
string resultMessage = "";
|
||
|
||
var emailSendList = Funs.DB.EmailUserView.Where(p => p.EmailType != 2 && p.IsEvaluateType != 1).ToList();
|
||
List<EmailUser> eUserList = new List<EmailUser>();
|
||
List<EmailUser> safetyUserList = new List<EmailUser>();
|
||
foreach (var item in emailSendList)
|
||
{
|
||
EmailUser eUserModel = new EmailUser();
|
||
eUserModel.ConGuid = item.ConGuid.ToString();
|
||
eUserModel.UserId = item.UserId;
|
||
eUserModel.UserName = item.UserName;
|
||
eUserModel.FO_NO = item.FO_NO;
|
||
eUserModel.Email = item.Email;
|
||
eUserModel.UserType = item.UserType;
|
||
eUserModel.dateYear = item.DateYear;
|
||
eUserModel.dateMonth = item.DateMonth;
|
||
eUserModel.emailType = item.EmailType;
|
||
eUserModel.emailName = item.EmailName;
|
||
eUserModel.IsEvaluateType = item.IsEvaluateType;
|
||
eUserModel.IsEvaluateName = item.IsEvaluateName;
|
||
if (item.IsSafetyEvaluate == 0)
|
||
{
|
||
eUserList.Add(eUserModel);
|
||
}
|
||
else
|
||
{
|
||
safetyUserList.Add(eUserModel);
|
||
}
|
||
}
|
||
|
||
var emailSendLeaderList = Funs.DB.EmailUserLeaderView.Where(p => p.EmailType != 2 && p.IsEvaluateType != 1).ToList();
|
||
foreach (var item in emailSendLeaderList)
|
||
{
|
||
EmailUser eUserModel = new EmailUser();
|
||
eUserModel.ConGuid = item.ConGuid.ToString();
|
||
eUserModel.UserId = item.UserId;
|
||
eUserModel.UserName = item.UserName;
|
||
eUserModel.FO_NO = item.FO_NO;
|
||
eUserModel.Email = item.Email;
|
||
eUserModel.UserType = item.UserType;
|
||
eUserModel.dateYear = item.DateYear;
|
||
eUserModel.dateMonth = item.DateMonth;
|
||
eUserModel.emailType = item.EmailType;
|
||
eUserModel.emailName = item.EmailName;
|
||
eUserModel.IsEvaluateType = item.IsEvaluateType;
|
||
eUserModel.IsEvaluateName = item.IsEvaluateName;
|
||
if (item.IsSafetyEvaluate == 0)
|
||
{
|
||
eUserList.Add(eUserModel);
|
||
}
|
||
else
|
||
{
|
||
safetyUserList.Add(eUserModel);
|
||
}
|
||
}
|
||
|
||
if (eUserList != null && eUserList.Count > 0)
|
||
{
|
||
mailTo = eUserList.Select(p => p.Email).Distinct().ToArray();
|
||
var nowDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功" && p.EmailTile.Contains("承包商绩效评估") && !p.EmailTile.Contains("特殊作业安全监护") && p.CreateTime.Value >= nowDate && mailTo.Contains(p.EmailURL)).ToList();
|
||
if (email.Count > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
|
||
// 要对其发送邮件的用户
|
||
var mailToUser = from x in Funs.DB.Sys_User where mailTo.Contains(x.Email) select x;
|
||
// 获取发送邮件的用户的部门集合
|
||
var depart = mailToUser.Select(p => p.DepartId).Distinct().ToArray();
|
||
// 获取部门信息
|
||
var depList = from x in Funs.DB.Base_Depart where depart.Contains(x.DepartId) && x.DepartLeader != null && x.DepartLeader != "" select x;
|
||
if (depList.Count() > 0)
|
||
{
|
||
var leaderList = depList.Select(p => p.DepartLeader).Distinct().ToArray();
|
||
var mailToLeader = from x in Funs.DB.Sys_User where leaderList.Contains(x.UserId) select x;
|
||
if (DateTime.Now.Day == 8)
|
||
{
|
||
// 部门经理
|
||
var mailCCLs = new List<string>();
|
||
mailCCLs = mailToLeader.Select(p => p.Email).Distinct().ToList();
|
||
mailCCLs.Add("wei.hu@basf-ypc.com.cn");
|
||
mailCCLs.Add("lei.zhong@basf-ypc.com.cn");
|
||
if (mailCCLs.Count > 0)
|
||
{
|
||
mailCC = mailCCLs.Where(p => !string.IsNullOrEmpty(p)).ToArray();
|
||
}
|
||
|
||
}
|
||
|
||
// 总监
|
||
var departCode = depList.Select(p => p.DepartCode.Substring(0, 3)).Distinct().ToArray();
|
||
var mailToDirector = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Base_Depart on x.DepartId equals y.DepartId
|
||
where departCode.Contains(y.DepartCode) && x.RoleId == Const.Role_DirectorId select x;
|
||
if (DateTime.Now.Day == 11 && mailToDirector.Count() > 0)
|
||
{
|
||
var mailccLs = new List<string>();
|
||
// 部门经理
|
||
var leader = mailToLeader.Select(p => p.Email).Distinct().ToList();
|
||
var director = mailToDirector.Select(p => p.Email).Distinct().ToList();
|
||
if (leader.Count > 0) mailccLs.AddRange(leader);
|
||
if (director.Count > 0) mailccLs.AddRange(director);
|
||
// 部门经理和总监都要抄送
|
||
mailCC = mailccLs.Where(p => !string.IsNullOrEmpty(p)).ToArray();
|
||
}
|
||
|
||
}
|
||
|
||
//邮件发送
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("Evaluation") && !x.EmailName.Contains("Safety"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
MailHelper.SendNetMail(pops, pops.EmailYx, mailTo, "[提醒]承包商绩效评估", mailBody, mailAttch, mailCode, mailPriority, mailCC, eUserList, out resultMessage);
|
||
}
|
||
}
|
||
|
||
if (safetyUserList != null && safetyUserList.Count > 0)
|
||
{
|
||
mailTo = safetyUserList.Select(p => p.Email).Distinct().ToArray();
|
||
var nowDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
|
||
var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功" && p.EmailTile.Contains("承包商绩效评估") && p.EmailTile.Contains("特殊作业安全监护") && p.CreateTime.Value >= nowDate && mailTo.Contains(p.EmailURL)).ToList();
|
||
if (email.Count > 0)
|
||
{
|
||
var emailurl = email.Select(p => p.EmailURL).ToList();
|
||
mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray();
|
||
}
|
||
if (mailTo == null || mailTo.Length == 0) return;
|
||
|
||
// 要对其发送邮件的用户
|
||
var mailToUser = from x in Funs.DB.Sys_User where mailTo.Contains(x.Email) select x;
|
||
// 获取发送邮件的用户的部门集合
|
||
var depart = mailToUser.Select(p => p.DepartId).Distinct().ToArray();
|
||
// 获取部门信息
|
||
var depList = from x in Funs.DB.Base_Depart where depart.Contains(x.DepartId) && x.DepartLeader != null && x.DepartLeader != "" select x;
|
||
if (depList.Count() > 0)
|
||
{
|
||
var leaderList = depList.Select(p => p.DepartLeader).Distinct().ToArray();
|
||
var mailToLeader = from x in Funs.DB.Sys_User where leaderList.Contains(x.UserId) select x;
|
||
if (DateTime.Now.Day == 8)
|
||
{
|
||
// 部门经理
|
||
var mailCCLs = new List<string>();
|
||
mailCCLs = mailToLeader.Select(p => p.Email).Distinct().ToList();
|
||
mailCCLs.Add("wei.hu@basf-ypc.com.cn");
|
||
mailCCLs.Add("lei.zhong@basf-ypc.com.cn");
|
||
if (mailCCLs.Count > 0)
|
||
{
|
||
mailCC = mailCCLs.Where(p => !string.IsNullOrEmpty(p)).ToArray();
|
||
}
|
||
}
|
||
|
||
// 总监
|
||
var departCode = depList.Select(p => p.DepartCode.Substring(0, 3)).Distinct().ToArray();
|
||
var mailToDirector = from x in Funs.DB.Sys_User
|
||
join y in Funs.DB.Base_Depart on x.DepartId equals y.DepartId
|
||
where departCode.Contains(y.DepartCode) && x.RoleId == Const.Role_DirectorId
|
||
select x;
|
||
if (DateTime.Now.Day == 11 && mailToDirector.Count() > 0)
|
||
{
|
||
var mailccLs = new List<string>();
|
||
// 部门经理
|
||
var leader = mailToLeader.Select(p => p.Email).Distinct().ToList();
|
||
var director = mailToDirector.Select(p => p.Email).Distinct().ToList();
|
||
if (leader.Count > 0) mailccLs.AddRange(leader);
|
||
if (director.Count > 0) mailccLs.AddRange(director);
|
||
// 部门经理和总监都要抄送
|
||
mailCC = mailccLs.Where(p => !string.IsNullOrEmpty(p)).ToArray();
|
||
}
|
||
|
||
}
|
||
|
||
//邮件发送
|
||
var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("Evaluation") && x.EmailName.Contains("Safety"));
|
||
if (EmailTemplate.Count() > 0)
|
||
{
|
||
string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault();
|
||
NameValueCollection myCol = new NameValueCollection();
|
||
mailBody = TemplateHelper.BulidByFile2(templetpath, myCol);
|
||
MailHelper.SendNetMail(pops, pops.EmailYx, mailTo, "[提醒]特殊作业安全监护服务-承包商绩效评估", mailBody, mailAttch, mailCode, mailPriority, mailCC, safetyUserList, out resultMessage);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 自动填写评价
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void aTimer_AutoFill(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
var userEmail = Funs.DB.EmailUserView.Where(p => p.IsEvaluateType != 1).ToList();
|
||
if (userEmail != null && userEmail.Count > 0)
|
||
{
|
||
foreach (var itemUser in userEmail)
|
||
{
|
||
FC_Score fsModel = new FC_Score();
|
||
var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(itemUser.FO_NO);
|
||
string fotype = string.Empty;
|
||
if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "")
|
||
{
|
||
var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId);
|
||
if (t != null)
|
||
{
|
||
fotype = t.FOType;
|
||
}
|
||
}
|
||
var tar_homelyModel = Funs.DB.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemUser.FO_NO);
|
||
var homelyModel = Funs.DB.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemUser.FO_NO);
|
||
fsModel.Contract_No = itemUser.FO_NO;
|
||
fsModel.Score1 = 0;
|
||
fsModel.Score2 = 0;
|
||
fsModel.Score3 = 0;
|
||
fsModel.Score4 = 0;
|
||
fsModel.Score5 = 0;
|
||
fsModel.Score6 = 0;
|
||
fsModel.UserId = itemUser.UserId;
|
||
fsModel.UserName = itemUser.UserName;
|
||
fsModel.DateIn = DateTime.Now;
|
||
fsModel.Role = "User";
|
||
fsModel.Remark = "Auto";
|
||
|
||
if (homelyModel != null && homelyModel.Honesty != null)
|
||
{
|
||
fsModel.Honesty = homelyModel.Honesty;
|
||
}
|
||
|
||
if (fotype.Trim() == "FC")
|
||
{
|
||
if (homelyModel != null && homelyModel.Timely != null)
|
||
{
|
||
fsModel.Timely = homelyModel.Timely;
|
||
}
|
||
}
|
||
else if (fotype.Trim() == "TAR")
|
||
{
|
||
if (tar_homelyModel != null && tar_homelyModel.Timely != null)
|
||
{
|
||
fsModel.Timely = tar_homelyModel.Timely;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
fsModel.Timely = Convert.ToDecimal(5.0);
|
||
}
|
||
|
||
Funs.DB.FC_Score.InsertOnSubmit(fsModel);
|
||
//评价日志信息
|
||
var setList = new List<Sys_User>();
|
||
var pjSESReport = new List<FC_SESReportView>();
|
||
pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == itemUser.FO_NO && p.Requisitioner == itemUser.UserName).ToList();
|
||
if (pjSESReport.Count > 0)
|
||
{
|
||
var scoreJournalList = new List<Score_JournalEvaluation>();
|
||
foreach (var item in pjSESReport)
|
||
{
|
||
Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation();
|
||
scoreJournal.SES_No = item.SES_No;
|
||
scoreJournal.Contract_No = item.FO_NO;
|
||
scoreJournal.Role = "User";
|
||
scoreJournal.Remark = "Auto";
|
||
scoreJournal.Evaluate_UserId = itemUser.UserId;
|
||
scoreJournal.Evaluate_UserName = itemUser.UserName;
|
||
scoreJournal.Evaluate_Time = DateTime.Now;
|
||
scoreJournalList.Add(scoreJournal);
|
||
}
|
||
Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList);
|
||
}
|
||
}
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
//部门
|
||
var depEmail = Funs.DB.EmailUserLeaderView.Where(p => p.IsEvaluateType != 1).ToList();
|
||
if (depEmail != null && depEmail.Count > 0)
|
||
{
|
||
foreach (var itemDep in depEmail.Select(p => new { p.FO_NO, p.UserName, p.UserId }).Distinct().ToList())
|
||
{
|
||
FC_Score fsModel = new FC_Score();
|
||
var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(itemDep.FO_NO);
|
||
string fotype = string.Empty;
|
||
if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "")
|
||
{
|
||
var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId);
|
||
if (t != null)
|
||
{
|
||
fotype = t.FOType;
|
||
}
|
||
}
|
||
var tar_homelyModel = Funs.DB.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemDep.FO_NO);
|
||
var homelyModel = Funs.DB.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemDep.FO_NO);
|
||
|
||
fsModel.Contract_No = itemDep.FO_NO;
|
||
|
||
fsModel.Score1 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 5) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.Score2 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 6) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.Score3 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 2) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.Score4 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 3) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.Score5 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 7) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.Score6 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 4) > 0 ? 0 : (decimal)-0.01;
|
||
fsModel.UserId = itemDep.UserId;
|
||
fsModel.UserName = itemDep.UserName;
|
||
fsModel.DateIn = DateTime.Now;
|
||
fsModel.Role = "Dep";
|
||
fsModel.Remark = "Auto";
|
||
|
||
if (homelyModel != null && homelyModel.Honesty != null)
|
||
{
|
||
fsModel.Honesty = homelyModel.Honesty;
|
||
}
|
||
|
||
if (fotype.Trim() == "FC")
|
||
{
|
||
if (homelyModel != null && homelyModel.Timely != null)
|
||
{
|
||
fsModel.Timely = homelyModel.Timely;
|
||
}
|
||
}
|
||
else if (fotype.Trim() == "TAR")
|
||
{
|
||
if (tar_homelyModel != null && tar_homelyModel.Timely != null)
|
||
{
|
||
fsModel.Timely = tar_homelyModel.Timely;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
fsModel.Timely = Convert.ToDecimal(5.0);
|
||
}
|
||
|
||
Funs.DB.FC_Score.InsertOnSubmit(fsModel);
|
||
//评价日志信息
|
||
var pjSESReport = new List<FC_SESReportView>();
|
||
var setList = Funs.DB.Sys_User.Where(p => new string[] { Const.Role_CTSSId, Const.Role_CTSCId, Const.Role_CTMTId }.Contains(p.RoleId) && p.UserId == itemDep.UserId).ToList();
|
||
if (setList.Count > 0)
|
||
{
|
||
pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == itemDep.FO_NO && p.Requisitioner != "").ToList();
|
||
}
|
||
else
|
||
{
|
||
pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == itemDep.FO_NO && (p.MainCoordinatorUser == itemDep.UserName || p.ContractAdminUser == itemDep.UserName || p.UserRepresentativeUser == itemDep.UserName)).ToList();
|
||
}
|
||
if (pjSESReport.Count > 0)
|
||
{
|
||
var scoreJournalList = new List<Score_JournalEvaluation>();
|
||
foreach (var item in pjSESReport)
|
||
{
|
||
Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation();
|
||
scoreJournal.SES_No = item.SES_No;
|
||
scoreJournal.Contract_No = item.FO_NO;
|
||
scoreJournal.Role = "Dep";
|
||
scoreJournal.Remark = "Auto";
|
||
scoreJournal.Evaluate_UserId = itemDep.UserId;
|
||
scoreJournal.Evaluate_UserName = itemDep.UserName;
|
||
scoreJournal.Evaluate_Time = DateTime.Now;
|
||
scoreJournalList.Add(scoreJournal);
|
||
}
|
||
Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList);
|
||
}
|
||
}
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
private void FC_AutoStatus(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
var date = (from x in Funs.DB.FC_SESRelatedData where x.FC_Status != "Closed" select x).ToList();
|
||
foreach (var d in date)
|
||
{
|
||
string lastPayment = string.Empty;
|
||
string status = d.FC_Status;
|
||
if (!string.IsNullOrEmpty(d.FO_NO))
|
||
{
|
||
//var cpt = from x in Funs.DB.CPTList where select x;
|
||
//if (cpt.Count() > 0)
|
||
//{
|
||
// lastPayment = cpt.FirstOrDefault().Last_Payment;
|
||
//}
|
||
lastPayment = Funs.DB.CPTList.FirstOrDefault(x => x.Contract_No == d.FO_NO)?.Last_Payment;
|
||
|
||
}
|
||
|
||
if (d.Validate_Date.HasValue)
|
||
{
|
||
if (d.Validate_Date.Value < DateTime.Now)
|
||
{
|
||
status = "Ready";
|
||
}
|
||
}
|
||
|
||
if (d.Expire_Date.HasValue)
|
||
{
|
||
if (d.Expire_Date.Value >= DateTime.Now)
|
||
{
|
||
if (d.Expire_Date.Value.AddMonths(-6) <= DateTime.Now)
|
||
{
|
||
status = "Expired Soon";
|
||
}
|
||
else
|
||
{
|
||
status = "Valid";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
status = "Expired";
|
||
if (lastPayment == "Y")
|
||
{
|
||
status = "Closed";
|
||
}
|
||
}
|
||
}
|
||
|
||
string strSql = "UPDATE dbo.FC_SESRelatedData SET FC_Status=@status WHERE ID=@id";
|
||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||
listStr.Add(new SqlParameter("@status", status));
|
||
listStr.Add(new SqlParameter("@id", d.ID));
|
||
SqlParameter[] parameter = listStr.ToArray();
|
||
try
|
||
{
|
||
BLL.SQLHelper.ExecutSql(strSql, parameter);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ErrLogInfo.WriteLog($"执行当前sql:{strSql}错误:{ex.Message},当前ID={d.ID},当前status={status}");
|
||
//记录日志到数据中。
|
||
}
|
||
}
|
||
}
|
||
|
||
private void upTimer_AutoReturnStatus(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
string strSql = @"UPDATE dbo.SSR SET ReturnStatus=(CASE WHEN ssr.ReturnDate IS NOT NULL OR
|
||
((SELECT COUNT(*) FROM dbo.FC_SESReport s
|
||
WHERE s.SES_No=ssr.SES_No
|
||
AND (s.Accepted='X' OR s.Deleted='X')
|
||
AND s.Engineer_confirmed_o IS NOT NULL))>0
|
||
THEN 'Y' ELSE 'N' END)";
|
||
BLL.SQLHelper.ExecutSql(strSql);
|
||
}
|
||
|
||
#region 承包商EHSS违规关联SES号的填写通知(5天后如还没录入再发邮件提醒)
|
||
private void Safe_RelatedSes_EmailSend(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
var vses = (from x in Funs.DB.EMC_Punishment
|
||
where (x.RelatedSesMailIsSend2 == null || x.RelatedSesMailIsSend2 == false)
|
||
&& x.BYC_RU != null && x.BYC_RU.ToUpper() != "NA" && x.Flag == "1"
|
||
&& (x.ViolationRelatedSes == null || x.ViolationRelatedSes == "")
|
||
&& x.CreateDate.HasValue && x.CreateDate.Value.AddDays(5).Date <= DateTime.Now.Date
|
||
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.RelatedSesMailIsSend2 = true;
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 承包商质量违规关联SES号的填写通知(5天后如还没录入SES再发邮件提醒)
|
||
private void CQuality_RelatedSes_EmailSend(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
var vses = (from x in Funs.DB.EMC_Punishment
|
||
where (x.RelatedSesMailIsSend2 == null || x.RelatedSesMailIsSend2 == false)
|
||
&& x.BYC_RU != null && x.BYC_RU.ToUpper() != "NA" && x.Flag == "2"
|
||
&& (x.ViolationRelatedSes == null || x.ViolationRelatedSes == "")
|
||
&& x.CreateDate.HasValue && x.CreateDate.Value.AddDays(5).Date <= DateTime.Now.Date
|
||
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("承包商质量违规关联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();
|
||
}
|
||
|
||
if (mailTo.Length > 0)
|
||
{
|
||
NameValueCollection myPram = new NameValueCollection();
|
||
myPram.Add("ContractNo", ses.FO_NO);
|
||
myPram.Add("Contractor", ses.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, "承包商质量违规关联SES号的填写通知", mailTo, mailCC, out resultMessage);
|
||
|
||
if (result)
|
||
{
|
||
ses.RelatedSesMailIsSend2 = true;
|
||
Funs.DB.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void Sync_HR(object sender, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
//调用接口
|
||
string baseUrl = "https://fcl-test.basf-ypc.net.cn/api/api/DataSyncUserInfo/GetHrInfoList";
|
||
BLL.Common.HttpHelper.HttpGetRequest(baseUrl);
|
||
}
|
||
|
||
protected void Session_Start(object sender, EventArgs e)
|
||
{
|
||
Session.Timeout = 120;
|
||
|
||
// 这种统计在线人数的做法会有一定的误差
|
||
Application.Lock();
|
||
Application["OnlineUserCount"] = (int)Application["OnlineUserCount"] + 1;
|
||
Application.UnLock();
|
||
|
||
// https访问secure设置为true
|
||
if (Request.IsSecureConnection)
|
||
{
|
||
Response.Cookies["ASP.NET_SessionId"].Secure = true;
|
||
}
|
||
}
|
||
|
||
protected void Application_BeginRequest(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
protected void Application_AuthenticateRequest(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
protected void Application_Error(object sender, EventArgs e)
|
||
{
|
||
StringBuilder errLog = null;
|
||
Exception ex = null;
|
||
try
|
||
{
|
||
// 获取错误类
|
||
ex = Server.GetLastError().InnerException;
|
||
if (ex == null)
|
||
{
|
||
ex = Server.GetLastError().GetBaseException();
|
||
}
|
||
|
||
errLog = new StringBuilder();
|
||
errLog.Append(String.Format(CultureInfo.InvariantCulture, "出错文件:{0}\r\n", Request.Url.AbsoluteUri));
|
||
if (Request.UserHostAddress != null)
|
||
{
|
||
errLog.Append(String.Format(CultureInfo.InvariantCulture, "IP地址:{0}\r\n", Request.UserHostAddress));
|
||
}
|
||
|
||
if (Session != null && Session["CurrUser"] != null)
|
||
{
|
||
errLog.Append(String.Format(CultureInfo.InvariantCulture, "操作人员:{0}\r\n", BLL.Sys_UserService.GetUsersByUserId(((Model.Sys_User)Session["CurrUser"]).UserId).UserName));
|
||
}
|
||
else
|
||
{
|
||
PageBase.ZXRefresh(Request.ApplicationPath + "/LogOff.aspx");
|
||
}
|
||
|
||
if (ex is HttpRequestValidationException)
|
||
{
|
||
PageBase.ZXRefresh(Request.ApplicationPath + "/Wrong.aspx?Message=0");
|
||
}
|
||
else if (ex is FriendlyException)
|
||
{
|
||
PageBase.ZXRefresh(Request.ApplicationPath + "/Wrong.aspx?MessageText=" + ex.Message);
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
try
|
||
{
|
||
PageBase.ZXRefresh(Request.ApplicationPath + "/OperationError.aspx");
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
ErrLogInfo.WriteLog(ex, errLog == null ? null : errLog.ToString());
|
||
Server.ClearError();
|
||
|
||
PageBase.ZXRefresh(Request.ApplicationPath + "/OperationError.aspx");
|
||
}
|
||
|
||
|
||
}
|
||
|
||
protected void Session_End(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
// 回收时调用接口
|
||
protected void Application_End(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|