private void PostMail(MailBaseData _MailBaseData, string recipientsAddressRange, string MailSubject, string Describe, string File_Path) { MailSubject = MailSubject + " (" + WIPCommon.ForamtCurDateTime() + ")";//任务名称 Describe += "<br/><br/>"; Describe += "消息来自主机:" + WIPCommon.GetHostName() + "<br/>"; Describe += "主机发生时间:" + WIPCommon.ForamtCurDateTime() + "<br/>"; IDictionary <string, object> logDict = new Dictionary <string, object>(); logDict.Add("recipientsAddressRange", recipientsAddressRange); logDict.Add("MailSubject", MailSubject); logDict.Add("Describe", Describe); logDict.Add("File_Path", File_Path); ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <IDictionary <string, object> >(namespaceName, "MailSending", logDict, "", ""); try { if (File_Path == null) { File_Path = ""; } SMTPHelper.MailSending(_MailBaseData, _recipientsAddressRange, MailSubject, Describe.ToString(), ""); } catch (Exception ex) { WipLogHelper.GetExceptionInfoForError(ex, ref exception); WipLogHelper.WriteExceptionInfo(exception); } }
/// <summary> /// 获取需要打印的数据列表 /// </summary> /// <param name="tempName">模板名称</param> /// <returns></returns> public List <PrintInfoModel> GetNeedPrintList() { ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <string>(namespaceName, "GetNeedPrintList", "", "", "", ExceptionSource.WIPReceive, ExceptionLevel.BusinessError, WipSource.PrintService); List <PrintInfoModel> printList = null; try { string printTypeStr = string.Join(",", GetPrintTypeList()); DataSet ds = dal.GetNeedPrintList(printTypeStr); printList = DataTableToListForNeedPrint(ds.Tables[0]); } catch (Exception ex) { WipLogHelper.GetExceptionInfoForError(ex, ref exception); //判断ex的内容,如果是数据库超时,则过滤,直接光写文本日志 if (ex.Message.Contains("信号灯超时时间已到") || ex.Message.Contains("未找到或无法访问服务器") || ex.Message.Contains("超时时间已到")) { Log4netHelper.WriteErrorLogByLog4Net(typeof(PrintConfigBLL), ex.Message, ex); } else { WipLogHelper.WriteExceptionInfo(exception); } } return(printList); }
public void MailSending(string MailSubject, string Describe, string File_Path) { #region 数据获取 try { _recipientsAddressRange = MailRuleBLL.GetInstance().GetMailPersonListRetStr(_categoryId); List <MailBaseData> mailBaseDataList = WIPDataAccess.CreateDAL <ICommonDAL>("CommonDAL").GetMailBaseData(); if (mailBaseDataList == null || mailBaseDataList.Count == 0) { throw new Exception("没有找到邮箱基础数据"); } if (mailBaseDataList.Count > 1) { throw new Exception(string.Format("配置的邮箱基础数据大于1条,请检查数据!查到的条数是{0}条", mailBaseDataList.Count.ToString())); } _MailBaseData = mailBaseDataList[0]; } catch (Exception ex) { IDictionary <string, object> logDict = new Dictionary <string, object>(); logDict.Add("MailSubject", MailSubject); logDict.Add("Describe", Describe); ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <IDictionary <string, object> >(namespaceName, "MailSending", logDict, "", ""); WipLogHelper.GetExceptionInfoForError(ex, ref exception); WipLogHelper.WriteExceptionInfo(exception); } #endregion if (string.IsNullOrEmpty(_recipientsAddressRange) || _MailBaseData == null) // 如果基础数据没有获取到,就不发邮件 { return; } this.PostMail(_MailBaseData, _recipientsAddressRange, MailSubject, Describe.ToString(), ""); }