using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data;

namespace Aitex.Core.RT.DBCore
{
    public static class DB
    {
        public static IDataBaseManager Manager { get; set; }

        public static string GetSqlByNameType(string name, Type type)
        {
            return Manager.GetSqlByNameType(name, type);
        }

        public static void InsertSql(string sql)
        {
            Manager?.InsertSql(sql);
        }

        public static int ExecuteNonQuery(string sql, bool isChangeDB = true)
        {
            return Manager.ExecuteNonQuery(sql, isChangeDB);
        }

        public static int ExecuteNonQuery(string sql, string[] columnsName, params object[] args)
        {
            return Manager.ExecuteNonQuery(sql, columnsName, args);
        }

        public static DbDataReader ExecuteReader(string sql)
        {
            return Manager?.ExecuteReader(sql);
        }

        public static object ExecuteScalar(string sql, bool isChangeDB = true)
        {
            return Manager?.ExecuteScalar(sql);
        }

        public static DataSet ExecuteDataSet(string sql)
        {
            return Manager?.ExecuteDataSet(sql);
        }

        public static DataTable ExecuteDataTable(string sql)
        {
            return Manager?.ExecuteDataTable(sql);
        }

        public static bool ExcuteTransAction(List<string> sqlList)
        {
            return Manager.ExcuteTransAction(sqlList);
        }

        public static void CreateTable(string tableName, Dictionary<string, Type> columns, string primaryKey, Type primaryKeyType)
        {
            Manager.CreateTable(tableName, columns, primaryKey, primaryKeyType);
        }

        public static void CreateTableIndex(string table, string index, string sql)
        {
            Manager?.CreateTableIndex(table, index, sql);
        }

        public static string GetLocalDictionary()
        {
            return Manager?.GetLocalDictionary();
        }
    }
}
