public IDataReader ExecuteQueryWithSqls(SqlStatements queries) { string Function_Name = "ExecuteQuery"; LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered"); string query; DatabaseSession session = m_sessionFactory.GetDatabaseSession(); bool bLocalSession = false; IDataReader dr = null; if (session != null) { try { if (!session.IsConnectionOpen()) { session.OpenConnection(); bLocalSession = true; } IDbCommand cmd = session.CreateCommand(); if (session.GetDBType() == DBType.Oracle) { query = queries.OracleSql; } else { query = queries.MySqlStr; } LogHelper.Debug(CLASS_NAME, Function_Name, string.Format("Query = {0}", query)); cmd.CommandText = query; dr = cmd.ExecuteReader(); // LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); // return dr; } catch (Exception localException) { LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString()); //todo // throw exception } } /*if (bLocalSession) * { * session.CloseConnection(); * }*/ LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(dr); }
public bool ExecuteEnqueneProcedure(List <SqlParameter> parameters) { string Function_Name = "ExecuteProcedure"; LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered"); bool bLocalSession = false; DatabaseSession session = m_sessionFactory.GetDatabaseSession(); bool boolUpdated = true; try { if (session != null) { if (!session.IsConnectionOpen()) { session.OpenConnection(); bLocalSession = true; } IDbCommand cmd = session.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; string procName; if (session.GetDBType() == DBType.Oracle) { procName = DAOHelper.ORACLE_AUDIT_PROCEDURE_NAME; } else { procName = DAOHelper.MYSQL_AUDIT_PROCEDURE_NAME; } cmd.CommandText = procName; LogHelper.Debug(CLASS_NAME, Function_Name, "SQL Parameters for Enquene procedure are : "); foreach (var item in parameters) { IDbDataParameter parameter = cmd.CreateParameter(); parameter.ParameterName = item.ParameterName; parameter.Direction = item.Direction; parameter.Value = item.Value; LogHelper.Debug(CLASS_NAME, Function_Name, String.Format("{0}\n", item.Value)); cmd.Parameters.Add(parameter); } LogHelper.Debug(CLASS_NAME, Function_Name, String.Format("Command Text: {0}", cmd.CommandText)); cmd.ExecuteNonQuery(); boolUpdated = false; } } catch (Exception localException) { LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString()); } if (bLocalSession) { session.CloseConnection(); } LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited"); return(!boolUpdated); }