using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PushPlatform.Common.Util;
using PushPlatform.Data.Bll;
using PushPlatform.Data.Criteria;
using PushPlatform.Common.Enumerate;
using System.Data.SqlClient;

namespace PushPlatform.Data.Blls
{
    public class DbHelpBll
    {
        #region 根据sql语句，数据库连接查询数据
        public static DataTable FetchSql(string sqlStr, string dbConnectId)
        {
            DataTable table = new DataTable();
            var dbModel = new BllSelectItemDetail().Get(dbConnectId);
            if (dbModel == null)
            {
                return table;
            }
            if (dbModel.Select_Type == (int)SelectType.Mysql连接)
            {
                MySqlParameter[] msp = {
                };

                MySQLHelper mysqlHelper = new MySQLHelper(dbModel.Value);
                return mysqlHelper.ExecuteDataTable(sqlStr, msp);
            }
            else
            {
                SQLServerDbHelper sqlHelper = new SQLServerDbHelper(dbModel.Value);
                SqlParameter[] sqlParms = {
                                  };
                return sqlHelper.ExecuteDataTable(sqlStr, sqlParms);
            }
        }
        #endregion
    }
}
