Ejemplo n.º 1
0
 public static void ExecuteNonQueryNoTimeout(ITransformationProvider p_provider, string p_sqlStatement)
 {
     var command = p_provider.GetCommand();
     command.CommandType = CommandType.Text;
     // 1-24-13 AMB:  Changed from 600 (10 minutes) to 1800 (30 minutes)
     command.CommandTimeout = 1800;
     command.CommandText = p_sqlStatement;
     Console.WriteLine("Executing: {0}", command.CommandText);
     command.ExecuteNonQuery();
 }
Ejemplo n.º 2
0
        public static void ExecuteNonQueryNoTimeout(ITransformationProvider p_provider, string p_sqlStatement)
        {
            var command = p_provider.GetCommand();

            command.CommandType = CommandType.Text;
            // 1-24-13 AMB:  Changed from 600 (10 minutes) to 1800 (30 minutes)
            command.CommandTimeout = 1800;
            command.CommandText    = p_sqlStatement;
            Console.WriteLine("Executing: {0}", command.CommandText);
            command.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Run Script
        /// </summary>
        /// <param name="p_provider">Database provider</param>
        /// <param name="p_scriptType">Script Type</param>
        /// <param name="p_scriptName">Name of Script</param>
        /// <param name="p_fileName">FileName of Script</param>
        /// <param name="p_schemaName">Schema Name - Default as dbo</param>
        /// <returns></returns>
        private static void RunScript(ITransformationProvider p_provider, ScriptType p_scriptType, string p_scriptName, Type typeHoldingScript, string p_fileName = null, string p_schemaName = "dbo")
        {
            if (string.IsNullOrEmpty(p_fileName))
            {
                p_fileName = string.Format("{0}.sql", p_scriptName);
            }

            // Drop proc/views/trigger if already exists
            p_provider.ExecuteNonQuery(string.Format(GetDropStatement(p_scriptType), p_scriptName, p_schemaName));


            // Load Script
            var    assembly         = typeHoldingScript.Assembly;
            string resourceFullName = string.Format("{0}.Scripts.{1}.{2}.sql", assembly.GetName().Name, p_scriptType, p_fileName);

            Console.WriteLine("Resource file name = " + resourceFullName);


            Console.WriteLine(resourceFullName);
            var stream = assembly.GetManifestResourceStream(resourceFullName);

            if (stream == null)
            {
                throw new InvalidOperationException(string.Format("Cannot load resource: {0}", resourceFullName));
            }
            var textStreamReader = new StreamReader(stream);

            // Execute procedure
            // Execute procedure
            // 4-26-13 AMB:  Changing this so we can set the timeout value
            //p_provider.ExecuteNonQuery(textStreamReader.ReadToEnd());
            var command = p_provider.GetCommand();

            command.CommandType    = CommandType.Text;
            command.CommandTimeout = 1800;
            command.CommandText    = textStreamReader.ReadToEnd();
            command.ExecuteNonQuery();

            Console.WriteLine(command.CommandText);
        }
Ejemplo n.º 4
0
 public static IDbConnection GetConnection(this ITransformationProvider provider)
 {
     return(provider.GetCommand().Connection);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Run Script
        /// </summary>
        /// <param name="p_provider">Database provider</param>
        /// <param name="p_scriptType">Script Type</param>
        /// <param name="p_scriptName">Name of Script</param>
        /// <param name="p_fileName">FileName of Script</param>
        /// <param name="p_schemaName">Schema Name - Default as dbo</param>
        /// <returns></returns>
        private static void RunScript(ITransformationProvider p_provider, ScriptType p_scriptType, string p_scriptName, Type typeHoldingScript,string p_fileName = null, string p_schemaName = "dbo")
        {
            if (string.IsNullOrEmpty(p_fileName))
                p_fileName = string.Format("{0}.sql", p_scriptName);

            // Drop proc/views/trigger if already exists
            p_provider.ExecuteNonQuery(string.Format(GetDropStatement(p_scriptType), p_scriptName, p_schemaName));

            // Load Script
            var assembly = typeHoldingScript.Assembly;
            string resourceFullName = string.Format("{0}.Scripts.{1}.{2}.sql", assembly.GetName().Name, p_scriptType, p_fileName);
            Console.WriteLine("Resource file name = " + resourceFullName);

            Console.WriteLine(resourceFullName);
            var stream = assembly.GetManifestResourceStream(resourceFullName);
            if (stream == null)
                throw new InvalidOperationException(string.Format("Cannot load resource: {0}", resourceFullName));
            var textStreamReader = new StreamReader(stream);

            // Execute procedure
            // Execute procedure
            // 4-26-13 AMB:  Changing this so we can set the timeout value
            //p_provider.ExecuteNonQuery(textStreamReader.ReadToEnd());
            var command = p_provider.GetCommand();
            command.CommandType = CommandType.Text;
            command.CommandTimeout = 1800;
            command.CommandText = textStreamReader.ReadToEnd();
            command.ExecuteNonQuery();

            Console.WriteLine(command.CommandText);
        }