/// <summary> /// Executes sql statements from a file on the databse. /// </summary> /// <param name="fileName">The name of the file conatining the statements</param> internal static void ExecuteStatementsOfSqlFile(string fileName) { //Load the insert statements from file string fileContent = File.ReadAllText(fileName); string[] statements = fileContent.Split(';'); //Get the connection string from config string connectionName = ConfigManager.GetInstance().GetValue( HermesScheduleItemPersistenceProvider.DefaultNamespace, "connectionName"); //Run each insert statement using (OracleConnection conn = OracleConnectionHelper.GetPooledConnection(null, connectionName)) { conn.Open(); using (OracleCommand command = new OracleCommand()) { foreach (string statement in statements) { command.CommandText = statement; command.Connection = conn; command.ExecuteNonQuery(); } } } }
/// <summary> /// Creats connection. /// </summary> /// /// <returns></returns> public static IDbConnection CreateConnection() { return(OracleConnectionHelper.GetPooledConnection(DbUserName, DataSource)); }
/// <summary> /// Gets an OracleConnection instance given the connection string using the WcfHelper component. /// </summary> /// <param name="connectionString">The connection string</param> /// <returns>An OracleConnection instance</returns> internal static OracleConnection GetConnection(string connectionString) { Profile profile = WcfHelper.GetProfileFromContext(OperationContext.Current); return(OracleConnectionHelper.GetPooledConnection(profile.UserID, connectionString)); }