useraccounts refactor

This commit is contained in:
nugroho 2025-05-20 15:57:24 +07:00
parent f8144dd254
commit c6c2dea10c

View File

@ -139,12 +139,13 @@ internal static class Commons
Console.Write(" Caching User Accounts... "); Console.Write(" Caching User Accounts... ");
await using SqlConnection FConn = new(CS); await using SqlConnection FConn = new(CS);
await FConn.OpenAsync().ConfigureAwait(false); await FConn.OpenAsync().ConfigureAwait(false);
using SqlCommand FComm = new("SELECT * FROM users",FConn); using SqlCommand FComm = new("SELECT * FROM useraccounts",FConn);
await using (SqlDataReader URead = await FComm.ExecuteReaderAsync(CTS.Token).ConfigureAwait(false)) await using (SqlDataReader URead = await FComm.ExecuteReaderAsync(CTS.Token).ConfigureAwait(false))
{ {
while(await URead.ReadAsync(CTS.Token).ConfigureAwait(false)) UserAccounts.Clear();
while (await URead.ReadAsync(CTS.Token).ConfigureAwait(false))
{ {
_ = UserAccounts.TryAdd((string)URead["uname"], new User((string)URead["uname"],(string)URead["name"],(string)URead["pass"],(byte)URead["level"],(bool)URead["active"])); _ = UserAccounts.TryAdd((string)URead["uname"], new User((string)URead["uname"], (string)URead["agentid"], (string)URead["pass"], (byte)URead["level"], (bool)URead["active"]));
} }
} }
Console.WriteLine("Done."); Console.WriteLine("Done.");