|
@@ -28,14 +28,16 @@ namespace HyperCube
|
|
|
return _instance;
|
|
|
}
|
|
|
|
|
|
- public bool IsConnect()
|
|
|
+ public async Task<bool> IsConnect()
|
|
|
{
|
|
|
+
|
|
|
string connstring = $"Server={Server}; database={DatabaseName}; UID={UserName}; password={Password}";
|
|
|
if (Connection != null)
|
|
|
{
|
|
|
+ Console.WriteLine($"IsConnect {Connection.State}");
|
|
|
//try
|
|
|
//{
|
|
|
- SQLSelectComplex("select COUNT(*) from accounts", false);
|
|
|
+ await SQLSelectComplex("select COUNT(*) from accounts", false);
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
@@ -62,12 +64,12 @@ namespace HyperCube
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public long SQLInsert(string sql)
|
|
|
+ public async Task<long> SQLInsert(string sql)
|
|
|
{
|
|
|
Console.WriteLine($"SQLInsert {sql}");
|
|
|
long lastID = 0;
|
|
|
|
|
|
- bool connected = IsConnect();
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -78,15 +80,17 @@ namespace HyperCube
|
|
|
else
|
|
|
Console.WriteLine("Not connected to DB.");
|
|
|
|
|
|
+ await Task.WhenAll();
|
|
|
return lastID;
|
|
|
}
|
|
|
|
|
|
public async Task<Dictionary<string, AccountModel>> SQLSelectASPUsers()
|
|
|
{
|
|
|
+ Console.WriteLine($"SQLSelectASPUsers");
|
|
|
string sql = "select * from aspnetusers";
|
|
|
Dictionary<string, AccountModel> accs = new();
|
|
|
|
|
|
- bool connected = IsConnect();
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -120,13 +124,14 @@ namespace HyperCube
|
|
|
|
|
|
public async Task<Dictionary<int, SmartContract>> SQLSelectContracts(int blockchainId)
|
|
|
{
|
|
|
+ Console.WriteLine($"SQLSelectContracts");
|
|
|
var bc = Blockchain.Find(blockchainId);
|
|
|
if (bc != null)
|
|
|
{
|
|
|
string sql = "select * from smart_contracts where blockchain_id =" + blockchainId;
|
|
|
Dictionary<int, SmartContract> contracts = new();
|
|
|
|
|
|
- bool connected = IsConnect();
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -171,10 +176,11 @@ namespace HyperCube
|
|
|
|
|
|
public async Task<Dictionary<int, ArticleModel>> SQLSelectArticles(string sql)
|
|
|
{
|
|
|
+ Console.WriteLine($"SQLSelectArticles");
|
|
|
Dictionary<int, ArticleModel> articleModels = new();
|
|
|
Models.ArticleModel articleModel;
|
|
|
|
|
|
- bool connected = IsConnect();
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -214,7 +220,7 @@ namespace HyperCube
|
|
|
if (check)
|
|
|
{
|
|
|
Console.WriteLine($"SQLSelectComplex check");
|
|
|
- connected = IsConnect();
|
|
|
+ connected = await IsConnect();
|
|
|
}
|
|
|
if (connected)
|
|
|
{
|
|
@@ -270,9 +276,10 @@ namespace HyperCube
|
|
|
|
|
|
public async Task<ArticleModel> SQLSelectArticle(string sql)
|
|
|
{
|
|
|
+ Console.WriteLine($"SQLSelectArticle");
|
|
|
ArticleModel articleModel = new();
|
|
|
|
|
|
- bool connected = IsConnect();
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -304,7 +311,8 @@ namespace HyperCube
|
|
|
|
|
|
public async Task<string> SQLSelectUUID(string sql)
|
|
|
{
|
|
|
- bool connected = IsConnect();
|
|
|
+ Console.WriteLine($"SQLSelectUUID");
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|
|
@@ -316,7 +324,8 @@ namespace HyperCube
|
|
|
|
|
|
public async Task<int> SQLSelectCount(string sql)
|
|
|
{
|
|
|
- bool connected = IsConnect();
|
|
|
+ Console.WriteLine($"SQLSelectCount");
|
|
|
+ bool connected = await IsConnect();
|
|
|
if (connected)
|
|
|
{
|
|
|
SQLcom = new(sql, Connection);
|