using BLL.Common; using BLL; using System; using System.Collections.Specialized; using System.Linq; using FineUIPro.Web.SES; namespace FineUIPro.Web.ContractorQuality { public partial class NoPassEdit : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void btnSure_Click(object sender, EventArgs e) { string id = Request.Params["punishmentId"]; var pun = BLL.PunishmentService.GetPunishmentById(id); if (pun != null) { pun.IsPass = false; pun.AuditMan = this.CurrUser.UserId; pun.AuditResult = this.txtContents.Text.Trim(); pun.States = "7";//拒绝,流程结束 BLL.PunishmentService.UpdatePunishment(pun); var audit = BLL.PunishmentAuditService.GetAuditByAuditMan(id, this.CurrUser.UserId); if (audit != null) { //audit.AuditMan = this.CurrUser.UserId; audit.AuditDate = DateTime.Now; audit.IsPass = false; audit.AuditResult = this.txtContents.Text.Trim(); BLL.PunishmentAuditService.UpdatePunishmentAudit(audit); #region 主协调员拒绝邮件 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("填写完成后拒绝通知")); if (emailTemplate.Count() > 0) { string departLeader = string.Empty; var u = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector); if (u != null) { if (!string.IsNullOrEmpty(u.DepartId)) { var depart = BLL.DepartService.GetDepartById(u.DepartId); if (depart != null) { departLeader = depart.DepartLeader; } } } if (!string.IsNullOrEmpty(departLeader)) { var userTo = from x in Funs.DB.View_EMail_UserTo where x.PunishmentId == id && x.AuditDate != null || x.ChineseName.Contains("王志高") || x.UserId.Contains(pun.Violation_Inspector) || x.UserId.Contains(departLeader) && x.Email != null && x.Email != "" select x; if (userTo != null) { mailTo = userTo.Select(x => x.Email).Distinct().ToArray(); } } else { var userTo = from x in Funs.DB.View_EMail_UserTo where x.PunishmentId == id && x.AuditDate != null || x.ChineseName.Contains("王志高") || x.UserId.Contains(pun.Violation_Inspector) && x.Email != null && x.Email != "" select x; if (userTo != null) { mailTo = userTo.Select(x => x.Email).Distinct().ToArray(); } } if (mailTo.Length > 0) { NameValueCollection myPram = new NameValueCollection(); myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : ""); myPram.Add("位置", pun.Location); myPram.Add("质量事件描述", pun.Description); myPram.Add("拒绝原因", pun.AuditResult); MailHelper.SendPunishSesMail(pops, myPram, "填写完成后拒绝通知", mailTo, mailCC, out resultMessage); } } #endregion } else { var ssrAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(id, "SSR"); if (ssrAudit != null) { ssrAudit.AuditMan = this.CurrUser.UserId; ssrAudit.AuditDate = DateTime.Now; ssrAudit.IsPass = false; ssrAudit.AuditResult = this.txtContents.Text.Trim(); BLL.PunishmentAuditService.UpdatePunishmentAudit(ssrAudit); #region SSR拒绝邮件 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("SSR管理员填写完成后拒绝通知")); if (emailTemplate.Count() > 0) { if (pun.SeType == "1" && pun.IsFrame == true)//框架合同 { //发送给:王志高、发起人、发起人部门经理 string departLeader = string.Empty; var u = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector); if (u != null) { if (!string.IsNullOrEmpty(u.DepartId)) { var depart = BLL.DepartService.GetDepartById(u.DepartId); if (depart != null) { departLeader = depart.DepartLeader; } } } if (!string.IsNullOrEmpty(departLeader)) { var userTo = from x in Funs.DB.Sys_User where x.ChineseName.Contains("王志高") || x.UserId.Contains(pun.Violation_Inspector) || x.UserId.Contains(departLeader) && x.Email != null && x.Email != "" select x; if (userTo != null) { mailTo = userTo.Select(x => x.Email).ToArray(); } } else { var userTo = from x in Funs.DB.Sys_User where x.ChineseName.Contains("王志高") || x.UserId.Contains(pun.Violation_Inspector) && x.Email != null && x.Email != "" select x; if (userTo != null) { mailTo = userTo.Select(x => x.Email).ToArray(); } } } else//非框架合同 { //发送对象:发起人,抄送:王志高 var userTo = from x in Funs.DB.Sys_User where x.UserId.Contains(pun.Violation_Inspector) && x.Email != null && x.Email != "" select x; if (userTo != null) { mailTo = userTo.Select(x => x.Email).ToArray(); } var userCC = from x in Funs.DB.Sys_User where x.ChineseName.Contains("王志高") && x.Email != null && x.Email != "" select x; if (userCC != null) { mailCC = userCC.Select(x => x.Email).ToArray(); } } if (mailTo.Length > 0) { NameValueCollection myPram = new NameValueCollection(); myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : ""); myPram.Add("位置", pun.Location); myPram.Add("质量事件描述", pun.Description); myPram.Add("拒绝原因", pun.AuditResult); MailHelper.SendPunishSesMail(pops, myPram, "SSR管理员填写完成后拒绝通知", mailTo, mailCC, out resultMessage); } } #endregion } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } } }