IList <InjectionMessage> IInjectionMessageStorage.ListInjectionMessage(QueryInjectionMessage pQueryInjectionMessage) { List <InjectionMessage> injectionMessageList = null; SqlConnection conn; IDataReader reader; try { Verify.ArgumentNotNull(pQueryInjectionMessage, "pQueryInjectionMessage"); conn = new SqlConnection( ConfigurationManager .ConnectionStrings["DEFAULT"].ToString()); conn.Open(); reader = InjectionMessageSelectWrapper.ExecuteReader( conn, pQueryInjectionMessage); if (reader != null) { injectionMessageList = new List <InjectionMessage>(); while (reader.Read()) { InjectionMessage myInjectionMessage = DAUtil.ReadInjectionMessage( reader); injectionMessageList.Add(myInjectionMessage); } } conn.Close(); } catch (Exception ex) { ExceptionHandler.DealWithException(ex); //switch (ex.GetType().FullName) //{ // case "System.ArgumentNullException": // { // throw new ArgumentNullException(ex.Message); // } // case "System.ArgumentException": // { // throw new ArgumentException(ex.Message); // } // default: // throw new Exception(ex.Message); //} } return(injectionMessageList); }
InjectionMessage IInjectionMessageStorage.ReadInjectionMessage(int pInjectionMessageID) { InjectionMessage myInjectionMessage = null; SqlConnection conn = null; IDataReader reader = null; try { Verify.ArgumentNotNull(pInjectionMessageID); myInjectionMessage = new InjectionMessage(); conn = new SqlConnection( ConfigurationManager .ConnectionStrings["DEFAULT"].ToString()); conn.Open(); reader = InjectionMessageByInjectionMessageIdSelectWrapper.ExecuteReader( conn, pInjectionMessageID); if (!reader.Read()) { throw new Exception("InjectionMessage read failure!"); } myInjectionMessage = DAUtil.ReadInjectionMessage(reader); conn.Close(); } catch (Exception ex) { ExceptionHandler.DealWithException(ex); //switch (ex.GetType().FullName) //{ // case "System.ArgumentNullException": // { // throw new ArgumentNullException(ex.Message); // } // case "System.ArgumentException": // { // throw new ArgumentException(ex.Message); // } // default: // throw new Exception(ex.Message); //} } #region Dispose finally { if (reader != null) { reader.Dispose(); } if (conn != null) { conn.Dispose(); } } #endregion return(myInjectionMessage); }