public IList <FindAlarmTextResult> Execute(FindAlarmTextParams parameters) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[schemaName]; string connectionString = settings.ConnectionString; IAlarmDao dao = new AlarmDao(connectionString); IList <FindAlarmTextResult> result = null; result = dao.FindAlarmText(parameters); return(result); }
Exception IExceptionHandler.HandleException(Exception exception, Guid handlingInstanceId) { DataAccessException dbExcep = exception as DataAccessException; if (dbExcep != null) { AlarmException alarmException; string errorCode = dbExcep.ErrorCode; 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 IList <IDbDataParameter> TranslateParameters(FindAlarmTextParams parameters) { IList <IDbDataParameter> parameterList = new List <IDbDataParameter>(); IDbDataParameter dbParameter; dbParameter = new OracleParameter(); dbParameter.ParameterName = "ALMID"; dbParameter.DbType = DbTypeConvertor.ConvertToDbType(typeof(string)); dbParameter.Direction = ParameterDirection.Input; dbParameter.Value = parameters.AlarmId; parameterList.Add(dbParameter); dbParameter = new OracleParameter(); dbParameter.ParameterName = "NLANGCOD"; dbParameter.DbType = DbTypeConvertor.ConvertToDbType(typeof(string)); dbParameter.Direction = ParameterDirection.Input; dbParameter.Value = parameters.LanguageCode; parameterList.Add(dbParameter); return(parameterList); }
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; } } }
public IList <FindAlarmTextResult> FindAlarmText(FindAlarmTextParams parameters) { using (TransactionScope scope = new TransactionScope()) { IList <FindAlarmTextResult> result = null; using (IDbConnection connection = new DbConnection(ConnectionString)) { connection.Open(); using (IDbCommand command = connection.CreateCommand()) { command.CommandText = StatementCache.Instance.GetCachedStatement("Imi.SupplyChain.Transportation.Alarm.DataAccess.Queries.FindAlarmText.sql"); ((OracleCommand)command).BindByName = true; foreach (IDbDataParameter parameter in FindAlarmTextTranslator.TranslateParameters(parameters)) { command.Parameters.Add(parameter); } LogDbCommand(command); command.Prepare(); using (IDataReader reader = command.ExecuteReader()) { result = FindAlarmTextTranslator.TranslateResultSet(reader); } } } scope.Complete(); return(result); } }