using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace DtWebApi { public class DataAccess { public static bool ExecuteNonQuery(StringCollection sql, string connectionString, out string errorMessage) { errorMessage = ""; string api = ""; string type = "POST"; string controlStr = "SQLCommon"; string actionStr = "ExecuteNonQuery1"; Dictionary dic = new Dictionary(); dic.Add("sql", JsonConvert.SerializeObject(sql)); return new CallWebApi().InvokeWebapiBool(controlStr, actionStr, api, type, dic); } public static bool ExecuteNonQuery(string sql, string connectionString, out string errorMessage) { errorMessage = ""; string api = ""; string type = "POST"; string controlStr = "SQLCommon"; string actionStr = "ExecuteNonQuery"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); return new CallWebApi().InvokeWebapiBool(controlStr, actionStr, api, type, dic); } public static bool ExecuteOutNum(string sql, string connectionString, out int count, out string errorMessage) { errorMessage = ""; string api = ""; string type = "POST"; string controlStr = "SQLCommon"; string actionStr = "ExecuteOutNum"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); count = new CallWebApi().InvokeWebapiInt(controlStr, actionStr, api, type, dic); return true; } public static bool ExecuteDataset(string sql, string connectionString, out DataSet ds, out string errorMessage) { errorMessage = ""; string api = ""; string type = "GET"; string controlStr = "SQLCommon"; string actionStr = "ExecuteDataset"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); ds = new CallWebApi().InvokeWebapiDataSet(controlStr, actionStr, api, type, dic); return true; } public static bool ExecuteDataTable(string sql, string connectionString, out DataTable dt, out string errorMessage) { errorMessage = ""; string api = ""; string type = "GET"; string controlStr = "SQLCommon"; string actionStr = "ExecuteDataTable"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); dt = new CallWebApi().InvokeWebapiDataTable(controlStr, actionStr, api, type, dic); return true; } public static bool ExecuteDataReader(string sql, string connectionString, out SqlDataReader dr, out string errorMessage) { errorMessage = ""; string api = ""; string type = "GET"; string controlStr = "SQLCommon"; string actionStr = "ExecuteDataReader"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); dr = new CallWebApi().InvokeWebapiSqlDataReader(controlStr, actionStr, api, type, dic); return true; } public static bool ExecuteSql(string sql, string connectionString, out string errorMessage) { errorMessage = ""; string api = ""; string type = "GET"; string controlStr = "SQLCommon"; string actionStr = "ExecuteSql"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); new CallWebApi().InvokeWebapiString(controlStr, actionStr, api, type, dic); return true; } public static bool ExecuteSql(string sql, string connectionString, out DataTable dt, out string errorMessage) { errorMessage = ""; string api = ""; string type = "GET"; string controlStr = "SQLCommon"; string actionStr = "ExecuteSqlDataTable"; Dictionary dic = new Dictionary(); dic.Add("sql", sql); dt = new CallWebApi().InvokeWebapiDataTable(controlStr, actionStr, api, type, dic); return true; } } }