Example #1
0
        public async Task <string> ExecSqlAsync(List <ParamSql> lst)
        {
            string result;

            try
            {
                using (this.conn = new OracleConnection(this._connectionString))
                {
                    bool flag = this.conn.State != ConnectionState.Open;
                    if (flag)
                    {
                        await this.conn.OpenAsync();
                    }
                    OracleTransaction oracleTransaction = this.conn.BeginTransaction();
                    try
                    {
                        this.cmd             = new OracleCommand();
                        this.cmd.CommandType = CommandType.Text;
                        this.cmd.Connection  = this.conn;
                        this.cmd.Transaction = oracleTransaction;
                        foreach (ParamSql paramSql in lst)
                        {
                            this.cmd.CommandText = paramSql.Sql;
                            foreach (SqlHelperParameter sqlHelperParameter in paramSql.Params)
                            {
                                this.cmd.Parameters.Add(this.GetParameter(sqlHelperParameter));
                            }
                            await this.cmd.ExecuteNonQueryAsync();

                            this.cmd.Parameters.Clear();
                        }
                        await oracleTransaction.CommitAsync();

                        result = string.Empty;
                    }
                    catch (Exception ex)
                    {
                        await oracleTransaction.RollbackAsync();

                        result = ex.Message;
                    }
                    finally
                    {
                        await oracleTransaction.DisposeAsync();

                        await this.cmd.DisposeAsync();

                        await this.conn.CloseAsync();
                    }
                }
            }
            catch (Exception ex2)
            {
                result = ex2.Message;
            }
            return(result);
        }
Example #2
0
        public async Task <string> ExecSqlAsync(ArrayList sqlList)
        {
            string result;

            using (this.conn = new OracleConnection(this._connectionString))
            {
                bool flag = this.conn.State != ConnectionState.Open;
                if (flag)
                {
                    await this.conn.OpenAsync();
                }
                OracleTransaction oracleTransaction = this.conn.BeginTransaction();
                try
                {
                    this.cmd             = new OracleCommand();
                    this.cmd.CommandType = CommandType.Text;
                    this.cmd.Connection  = this.conn;
                    foreach (object obj in sqlList)
                    {
                        string commandText = (string)obj;
                        this.cmd.CommandText = commandText;
                        await this.cmd.ExecuteNonQueryAsync();
                    }
                    await oracleTransaction.CommitAsync();

                    result = string.Empty;
                }
                catch (Exception ex)
                {
                    await oracleTransaction.RollbackAsync();

                    result = ex.Message;
                }
                finally
                {
                    await oracleTransaction.DisposeAsync();

                    await this.cmd.DisposeAsync();

                    await this.conn.CloseAsync();
                }
            }
            return(result);
        }