Exemplo n.º 1
0
        public IDataReader ExecuteReader(CommandType commandType, string commandText, bool defaultParameters, string currentUser, bool closeConnection, params object[] commandParameters)
        {
            SaveLog("ExecuteReader - " + commandText);
            DbCommand command = GetCommand();

            PrepareCommand(command, commandType, commandText, defaultParameters, currentUser, commandParameters);

            lock (command.Connection)
            {
                try
                {
                    Open();

                    return(command.ExecuteReader());
                }
                finally
                {
                    if (closeConnection)
                    {
                        Close();
                    }

                    if (defaultParameters)
                    {
                        _executionStatus = GetExecutionResults(command);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void PrepareCommand(DbCommand command, CommandType commandType, string commandText, bool defaultParameters, string currentUser, params object [] commandParameters)
        {
            _executionStatus = new Model.ExecutionStatus(command);

            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (string.IsNullOrEmpty(commandText))
            {
                throw new ArgumentNullException("commandText");
            }

            command.CommandText = commandText;
            command.CommandType = commandType;


            foreach (DbParameter parameter in commandParameters)
            {
                command.Parameters.Add(parameter);
            }


            if (defaultParameters)
            {
                SetDefaultParameters(command, currentUser);
            }
        }
Exemplo n.º 3
0
        public DataSet ExecuteDataSet(CommandType commandType, string commandText, bool defaultParameters, string currentUser, params object[] commandParameters)
        {
            SaveLog("ExecuteDataSet - " + commandText);
            DataSet dataset = new DataSet();

            DbDataAdapter adapter = GetDataAdapter();

            lock (adapter.SelectCommand.Connection)
            {
                PrepareCommand(adapter.SelectCommand, commandType, commandText, defaultParameters, currentUser, commandParameters);

                adapter.Fill(dataset);

                if (defaultParameters)
                {
                    _executionStatus = GetExecutionResults(adapter.SelectCommand);
                }
            }

            return(dataset);
        }