Exemplo n.º 1
0
        public object ExecScalar(HSQL sql)
        {
            this.LastSQL = sql;
            object obj;

            try
            {
                DbCommand dbCommand = this.PrepareCommand(sql);
                bool      flag      = !this.Connected;
                if (flag)
                {
                    this.OpenConnection();
                }
                obj = dbCommand.ExecuteScalar();
                bool flag2 = !this.InTransaction;
                if (flag2)
                {
                    this.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(obj);
        }
Exemplo n.º 2
0
        public DataSet OpenDataSet(HSQL sql)
        {
            DataSet dataSet = new DataSet();

            this.LastSQL = sql;
            try
            {
                DbCommand dbCommand = this.PrepareCommand(sql);
                bool      flag      = !this.Connected;
                if (flag)
                {
                    this.OpenConnection();
                }
                DbDataAdapter dataAdapter = this.m_dbProviderFactory.CreateDataAdapter();
                dataAdapter.SelectCommand = dbCommand;
                dataAdapter.Fill(dataSet);
                bool flag2 = !this.m_inTransaction;
                if (flag2)
                {
                    this.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dataSet);
        }
Exemplo n.º 3
0
        public int ExecSQL(HSQL sql)
        {
            this.LastSQL = sql;
            int num;

            try
            {
                DbCommand dbCommand = this.PrepareCommand(sql);
                bool      flag      = !this.Connected;
                if (flag)
                {
                    this.OpenConnection();
                }
                num = dbCommand.ExecuteNonQuery();
                bool flag2 = !this.InTransaction;
                if (flag2)
                {
                    this.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(num);
        }
Exemplo n.º 4
0
        public int OpenDataSet(HSQL sql, DataTable dt, DataTable seDt, int startRecord, int maxRecords)
        {
            int       num = 0;
            DbCommand cmd;

            using (DbDataReader dbDataReader = this.OpenReader(sql, out cmd))
            {
                for (int ordinal = 0; ordinal < dbDataReader.FieldCount; ordinal++)
                {
                    bool flag = !dt.Columns.Contains(dbDataReader.GetName(ordinal));
                    if (flag)
                    {
                        dt.Columns.Add(dbDataReader.GetName(ordinal));
                    }
                    bool flag2 = !seDt.Columns.Contains(dbDataReader.GetName(ordinal));
                    if (flag2)
                    {
                        seDt.Columns.Add(dbDataReader.GetName(ordinal));
                    }
                }
                while (dbDataReader.Read())
                {
                    num++;
                    bool flag3 = !(num < startRecord + 1 | num >= startRecord + maxRecords + 1);
                    if (flag3)
                    {
                        DataRow row  = dt.NewRow();
                        DataRow row2 = seDt.NewRow();
                        for (int ordinal2 = 0; ordinal2 < dbDataReader.FieldCount; ordinal2++)
                        {
                            bool flag4 = dt.Columns.Contains(dbDataReader.GetName(ordinal2));
                            if (flag4)
                            {
                                row[dbDataReader.GetName(ordinal2)]  = dbDataReader[ordinal2];
                                row2[dbDataReader.GetName(ordinal2)] = dbDataReader[ordinal2];
                            }
                        }
                        dt.Rows.Add(row);
                        seDt.Rows.Add(row2);
                    }
                }
                bool flag5 = cmd != null;
                if (flag5)
                {
                    cmd.Cancel();
                }
            }
            return(num);
        }
Exemplo n.º 5
0
        protected virtual DbCommand PrepareCommand(HSQL sql)
        {
            DbCommand command = this.m_dbProviderFactory.CreateCommand();

            command.CommandTimeout = 180;
            command.Connection     = this.m_connection;
            bool inTransaction = this.m_inTransaction;

            if (inTransaction)
            {
                command.Transaction = this.m_transaction;
            }
            command.CommandType = CommandType.Text;
            command.CommandText = sql.ToString();
            for (int index = 0; index < sql.Params.Count; index++)
            {
                DbParameter parameter = this.CreateParameter("@" + sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                command.Parameters.Add(parameter);
            }
            return(command);
        }
Exemplo n.º 6
0
        public DbDataReader OpenReader(HSQL sql, out DbCommand cmd)
        {
            this.LastSQL = sql;
            DbDataReader dbDataReader;

            try
            {
                cmd = this.PrepareCommand(sql);
                bool flag = !this.Connected;
                if (flag)
                {
                    this.OpenConnection();
                }
                dbDataReader = ((!this.m_inTransaction) ? cmd.ExecuteReader(CommandBehavior.CloseConnection) : cmd.ExecuteReader());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dbDataReader);
        }
Exemplo n.º 7
0
        public virtual DbDataAdapter OpenAdapter(HSQL sql)
        {
            this.LastSQL = sql;
            DbCommand dbCommand = this.PrepareCommand(sql);
            bool      flag      = !this.Connected;

            if (flag)
            {
                this.OpenConnection();
            }
            DbDataAdapter dataAdapter = this.m_dbProviderFactory.CreateDataAdapter();

            dataAdapter.SelectCommand = dbCommand;
            bool flag2 = !this.m_inTransaction;

            if (flag2)
            {
                this.CloseConnection();
            }
            return(dataAdapter);
        }
Exemplo n.º 8
0
        protected override DbCommand PrepareCommand(HSQL sql)
        {
            DbCommand command = base.DbProviderFactory.CreateCommand();

            ((OracleCommand)command).BindByName = true;
            command.CommandTimeout = 180;
            command.Connection     = this.m_connection;
            bool inTransaction = base.InTransaction;

            if (inTransaction)
            {
                command.Transaction = base.Transaction;
            }
            command.CommandType = CommandType.Text;
            command.CommandText = sql.ToString();
            for (int index = 0; index < sql.Params.Count; index++)
            {
                bool flag = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.Long;
                if (flag)
                {
                    OracleParameter oracleParameter = new OracleParameter(sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                    oracleParameter.OracleDbType = OracleDbType.Long;
                    bool flag2 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                    if (flag2)
                    {
                        oracleParameter.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                    }
                    bool flag3 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                    if (flag3)
                    {
                        oracleParameter.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                    }
                    command.Parameters.Add(oracleParameter);
                }
                else
                {
                    bool flag4 = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.LongRaw;
                    if (flag4)
                    {
                        OracleParameter oracleParameter2 = new OracleParameter(sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                        oracleParameter2.OracleDbType = OracleDbType.LongRaw;
                        bool flag5 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                        if (flag5)
                        {
                            oracleParameter2.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                        }
                        bool flag6 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                        if (flag6)
                        {
                            oracleParameter2.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                        }
                        command.Parameters.Add(oracleParameter2);
                    }
                    else
                    {
                        bool flag7 = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.Text;
                        if (flag7)
                        {
                            OracleParameter oracleParameter3 = new OracleParameter(sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                            oracleParameter3.OracleDbType = OracleDbType.Varchar2;
                            bool flag8 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                            if (flag8)
                            {
                                oracleParameter3.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                            }
                            else
                            {
                                oracleParameter3.Size = 4000;
                            }
                            bool flag9 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                            if (flag9)
                            {
                                oracleParameter3.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                            }
                            command.Parameters.Add(oracleParameter3);
                        }
                        else
                        {
                            bool flag10 = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.NVarChar;
                            if (flag10)
                            {
                                OracleParameter oracleParameter4 = new OracleParameter(sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                                oracleParameter4.OracleDbType = OracleDbType.NVarchar2;
                                bool flag11 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                                if (flag11)
                                {
                                    oracleParameter4.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                                }
                                bool flag12 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                                if (flag12)
                                {
                                    oracleParameter4.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                                }
                                command.Parameters.Add(oracleParameter4);
                            }
                            else
                            {
                                DbParameter parameter = base.CreateParameter(sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                                bool        flag13    = parameter.DbType == DbType.String;
                                if (flag13)
                                {
                                    parameter.DbType = DbType.AnsiString;
                                }
                                else
                                {
                                    switch (sql.ParamByName(sql.Params[index].ToString()).ParamterType)
                                    {
                                    case TimDbType.Null:
                                    {
                                        bool flag14 = sql.ParamByName(sql.Params[index].ToString()).Value is DateTime;
                                        if (flag14)
                                        {
                                            parameter.DbType = DbType.Date;
                                        }
                                        break;
                                    }

                                    case TimDbType.VarChar:
                                        parameter.DbType = DbType.String;
                                        break;

                                    case TimDbType.DateTime:
                                        parameter.DbType = DbType.Date;
                                        break;

                                    case TimDbType.Float:
                                        parameter.DbType = DbType.Double;
                                        break;
                                    }
                                }
                                bool flag15 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                                if (flag15)
                                {
                                    parameter.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                                }
                                bool flag16 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                                if (flag16)
                                {
                                    parameter.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                                }
                                command.Parameters.Add(parameter);
                            }
                        }
                    }
                }
            }
            return(command);
        }
Exemplo n.º 9
0
        protected override DbCommand PrepareCommand(HSQL sql)
        {
            DbCommand command = base.DbProviderFactory.CreateCommand();

            command.CommandTimeout = 180;
            command.Connection     = this.m_connection;
            bool inTransaction = base.InTransaction;

            if (inTransaction)
            {
                command.Transaction = base.Transaction;
            }
            command.CommandType = CommandType.Text;
            command.CommandText = sql.ToString();
            for (int index = 0; index < sql.Params.Count; index++)
            {
                bool flag = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.Text || sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.Long;
                if (flag)
                {
                    SqlParameter sqlParameter = new SqlParameter("@" + sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                    sqlParameter.SqlDbType = SqlDbType.Text;
                    bool flag2 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                    if (flag2)
                    {
                        sqlParameter.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                    }
                    command.Parameters.Add(sqlParameter);
                }
                else
                {
                    bool flag3 = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.LongRaw;
                    if (flag3)
                    {
                        SqlParameter sqlParameter2 = new SqlParameter("@" + sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                        sqlParameter2.SqlDbType = SqlDbType.Image;
                        bool flag4 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                        if (flag4)
                        {
                            sqlParameter2.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                        }
                        command.Parameters.Add(sqlParameter2);
                    }
                    else
                    {
                        bool flag5 = sql.ParamByName(sql.Params[index].ToString()).ParamterType == TimDbType.NVarChar;
                        if (flag5)
                        {
                            SqlParameter sqlParameter3 = new SqlParameter("@" + sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                            sqlParameter3.SqlDbType = SqlDbType.NVarChar;
                            bool flag6 = sql.ParamByName(sql.Params[index].ToString()).Size != 0;
                            if (flag6)
                            {
                                sqlParameter3.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                            }
                            bool flag7 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                            if (flag7)
                            {
                                sqlParameter3.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                            }
                            command.Parameters.Add(sqlParameter3);
                        }
                        else
                        {
                            DbParameter parameter = base.CreateParameter("@" + sql.Params[index].ToString(), sql.ParamByName(sql.Params[index].ToString()).Value);
                            bool        flag8     = parameter.DbType == DbType.String;
                            if (flag8)
                            {
                                parameter.DbType = DbType.AnsiString;
                            }
                            else
                            {
                                switch (sql.ParamByName(sql.Params[index].ToString()).ParamterType)
                                {
                                case TimDbType.VarChar:
                                    parameter.DbType = DbType.String;
                                    break;

                                case TimDbType.DateTime:
                                    parameter.DbType = DbType.DateTime;
                                    break;

                                case TimDbType.Float:
                                    parameter.DbType = DbType.Double;
                                    break;
                                }
                            }
                            bool flag9 = sql.ParamByName(sql.Params[index].ToString()).Size != 0 && sql.ParamByName(sql.Params[index].ToString()).ParamterType != TimDbType.Float;
                            if (flag9)
                            {
                                parameter.Size = sql.ParamByName(sql.Params[index].ToString()).Size;
                            }
                            bool flag10 = !string.IsNullOrEmpty(sql.ParamByName(sql.Params[index].ToString()).SourceColumn);
                            if (flag10)
                            {
                                parameter.SourceColumn = sql.ParamByName(sql.Params[index].ToString()).SourceColumn;
                            }
                            command.Parameters.Add(parameter);
                        }
                    }
                }
            }
            return(command);
        }