public static List<Customers> GetAllCustomers(bool isNew) { //sp_getactivecustomerstomatchnewdeal DBisNULLUtility isNull = new DBisNULLUtility(); MySqlConnection conn = new MySqlConnection(connStr); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader dr = null; cmd.CommandType = System.Data.CommandType.StoredProcedure; List<Customers> tmpList = new List<Customers>(); try { cmd.CommandText = "sp_getactivecustomerstomatchnewdeal"; cmd.Parameters.AddWithValue("@isNewInput", isNew); conn.Open(); cmd.CommandTimeout = 60; // increase timeout to 60, just in case of busy or locking dr = cmd.ExecuteReader(); while (dr.Read()) { Customers tmpModel = new Customers(); tmpModel.CustomerID = (int)dr["CustomerID"]; tmpModel.Email = isNull.isDBNull(dr["Email"],""); tmpModel.FirstName = isNull.isDBNull(dr["FirstName"],""); tmpModel.LastName = isNull.isDBNull(dr["LastName"],""); tmpModel.Catekeywords = isNull.isDBNull(dr["catekeywords"],""); tmpModel.Custkeywords = isNull.isDBNull(dr["custkeywords"],""); tmpModel.KeyWords = (tmpModel.Catekeywords.Trim(',') + "," + tmpModel.Custkeywords.Trim(',')).Trim(','); tmpList.Add(tmpModel); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { conn.Close(); if (dr != null) dr.Dispose(); cmd.Dispose(); } return tmpList; }
// public static List<ScheduledDelivery> GetAllScheduled2Deliver() { DBisNULLUtility isNull = new DBisNULLUtility(); MySqlConnection conn = new MySqlConnection(connStr); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader dr = null; cmd.CommandType = System.Data.CommandType.StoredProcedure; List<ScheduledDelivery> tmpList = new List<ScheduledDelivery>(); try { cmd.CommandText = "sp_getScheduledDelivery"; conn.Open(); cmd.CommandTimeout = 60; // increase timeout to 60, just in case of busy or locking dr = cmd.ExecuteReader(); while (dr.Read()) { ScheduledDelivery tmpModel = new ScheduledDelivery(); tmpModel.scheduleID = (int)dr["scheduleID"]; tmpModel.Email = (string) dr["Email"]; tmpModel.dealsID= (string)dr["dealsID"]; tmpModel.customerID = (int)dr["customerID"]; tmpModel.FirstName= (string)dr["FirstName"]; tmpModel.LastName = (string)dr["LastName"]; tmpModel.Keywords = isNull.isDBNull(dr["keywords"], ""); tmpList.Add(tmpModel); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { conn.Close(); if (dr != null) dr.Dispose(); cmd.Dispose(); } return tmpList; }