public Exception HandleException(Exception exception, Guid handlingInstanceId) { DataAccessException dbExcep = exception as DataAccessException; if (dbExcep != null) { AlarmException alarmException; string errorCode = dbExcep.ErrorCode; // "ORA2292";// +exception.ErrorCode.ToString(); string msg = dbExcep.Message; string addMsg = string.Empty; string languageCode; if (ApplicationContext.Current != null) { languageCode = ApplicationContext.Current.LanguageCode; } else { languageCode = ApplicationContext.DefaultLanguageCode; } FindAlarmTextAction findAlarmTextAction = new FindAlarmTextAction(); FindAlarmTextParams findAlarmTextParams = new FindAlarmTextParams(); findAlarmTextParams.AlarmId = errorCode; findAlarmTextParams.LanguageCode = languageCode; IList <FindAlarmTextResult> alarmTextList = findAlarmTextAction.Execute(findAlarmTextParams); if (alarmTextList.Count == 1) { msg = alarmTextList[0].AlarmText; if (exception.InnerException != null && exception.InnerException.Message.Length > 0) { addMsg = exception.InnerException.Message; } alarmException = new AlarmException(errorCode, msg, null, addMsg, null); return(alarmException); } return(exception); } return(exception); }
public static void Execute(string errorCode, int?currentPosition, string languageCode) { if (string.IsNullOrEmpty(languageCode)) { if (ApplicationContext.Current != null) { languageCode = ApplicationContext.Current.LanguageCode; } else { languageCode = ApplicationContext.DefaultLanguageCode; } } if (!String.IsNullOrEmpty(errorCode)) { FindAlarmTextAction findAlarmTextAction = new FindAlarmTextAction(); FindAlarmTextParams findAlarmTextParams = new FindAlarmTextParams(); findAlarmTextParams.AlarmId = errorCode; findAlarmTextParams.LanguageCode = languageCode; IList <FindAlarmTextResult> alarmTextList = findAlarmTextAction.Execute(findAlarmTextParams); if (alarmTextList.Count != 1) { AlarmException alarmException = new AlarmException(errorCode, "", currentPosition); throw alarmException; } else { AlarmException alarmException = new AlarmException(errorCode, alarmTextList[0].AlarmText, currentPosition); throw alarmException; } } }