/// <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); }
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> /// <typeparam name="T"></typeparam> /// <param name="host"></param> /// <param name="url"></param> /// <param name="param"></param> /// <param name="sysCode"></param> /// <param name="requestDesc"></param> /// <param name="exception"></param> /// <param name="businessExceptionParam"></param> /// <param name="requestType"></param> /// <param name="execCount"></param> private static void CommonDoRequestWithRetry <T>(string host, string url, T param, string sysCode, string requestDesc, ExceptionInfoEntity exception, BusinessExceptionMgrParam businessExceptionParam, RequestType requestType, int execCount = 0) { execCount = execCount + 1; bool execResult = false; ResponseUpdater _responseUpdater = null; try { switch (requestType) { case RequestType.PredictiveTask: // 质量预测发起 _responseUpdater = new PredictiveTask_ResUpdater(execResult, exception); break; case RequestType.Other: case RequestType.QualityTaskToLIMS: _responseUpdater = new ResponseUpdater(execResult, exception); break; case RequestType.PushProcessCardInfoToWCS: _responseUpdater = new PushProcessCardInfoToWCS_ResUpdater(execResult, exception); break; } _responseUpdater.DoResponse <T>(host, url, param, execCount); execResult = _responseUpdater._ResponseUpdaterRet.execResult; exception = _responseUpdater._ResponseUpdaterRet.exception; } catch (Exception ex) { WipLogHelper.GetExceptionInfoForError(ex, ref exception); exception.exceptionMsg += ",执行次数:" + execCount.ToString(); execResult = false; } finally { if (!execResult) { CommonDoRequestWithRetryByFailure <T>(host, url, param, sysCode, requestDesc, exception, businessExceptionParam, requestType, execCount); } } }
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(), ""); }