|
|
|
@ -14,6 +14,9 @@ using Newtonsoft.Json;
|
|
|
|
|
using Mysqlx.Resultset;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System.Transactions;
|
|
|
|
|
using Org.BouncyCastle.Asn1.X509;
|
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
namespace ZKLT.Hadoop
|
|
|
|
|
{
|
|
|
|
@ -1142,5 +1145,57 @@ namespace ZKLT.Hadoop
|
|
|
|
|
return _result.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 执行存储过程
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public T? StoredProcedure<T>(string sourceId,string name, JToken? data)
|
|
|
|
|
{
|
|
|
|
|
var source = GetSource(sourceId);
|
|
|
|
|
using (MySqlConnection _connection = new MySqlConnection(source.GetConnectString()))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_connection.Open();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("数据源连接失败");
|
|
|
|
|
}
|
|
|
|
|
using (MySqlCommand _command = new MySqlCommand(name, _connection))
|
|
|
|
|
{
|
|
|
|
|
_command.CommandType = CommandType.StoredProcedure;
|
|
|
|
|
if (data != null)
|
|
|
|
|
{
|
|
|
|
|
var _datas = data.ToObject<Dictionary<string, object>>()!;
|
|
|
|
|
foreach (var item in _datas)
|
|
|
|
|
{
|
|
|
|
|
_command.Parameters.AddWithValue(item.Key, item.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
using (MySqlDataReader _reader = _command.ExecuteReader())
|
|
|
|
|
{
|
|
|
|
|
var _result = new List<Dictionary<string, object>>();
|
|
|
|
|
while (_reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var row = new Dictionary<string, object>();
|
|
|
|
|
for (int i = 0; i < _reader.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
row[_reader.GetName(i)] = _reader.GetValue(i);
|
|
|
|
|
}
|
|
|
|
|
_result.Add(row);
|
|
|
|
|
}
|
|
|
|
|
_reader.Close();
|
|
|
|
|
_connection.Close();
|
|
|
|
|
return (T)(object)_result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|