Fixed crash on AppVersion after the removal of Version key in the EnviromentVariables dictionary. Added new SqlDatabase functions: ReadDataArrayAsync and ReadDataAsync with query + parameters of the query.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Nullable>enable</Nullable>
|
||||
<AvaloniaVersion>11.0.2</AvaloniaVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -385,6 +385,37 @@ public class SqlDatabase
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read data from the result table and return the first row
|
||||
/// </summary>
|
||||
/// <param name="query">The query</param>
|
||||
/// <param name="parameters">The parameters of the query</param>
|
||||
/// <returns>The result is a string that has all values separated by space character</returns>
|
||||
public async Task<string?> ReadDataAsync(string query, params KeyValuePair<string, object>[] parameters)
|
||||
{
|
||||
if (!_connection.State.HasFlag(ConnectionState.Open))
|
||||
await _connection.OpenAsync();
|
||||
|
||||
var command = new SQLiteCommand(query, _connection);
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
var p = CreateParameter(parameter);
|
||||
if (p is not null)
|
||||
command.Parameters.Add(p);
|
||||
}
|
||||
|
||||
var reader = await command.ExecuteReaderAsync();
|
||||
|
||||
var values = new object[reader.FieldCount];
|
||||
if (reader.Read())
|
||||
{
|
||||
reader.GetValues(values);
|
||||
return string.Join<object>(" ", values);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read data from the result table and return the first row
|
||||
/// </summary>
|
||||
@@ -429,6 +460,32 @@ public class SqlDatabase
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<object[]?> ReadDataArrayAsync(string query, params KeyValuePair<string, object>[] parameters)
|
||||
{
|
||||
if (!_connection.State.HasFlag(ConnectionState.Open))
|
||||
await _connection.OpenAsync();
|
||||
|
||||
var command = new SQLiteCommand(query, _connection);
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
var p = CreateParameter(parameter);
|
||||
if (p is not null)
|
||||
command.Parameters.Add(p);
|
||||
}
|
||||
|
||||
var reader = await command.ExecuteReaderAsync();
|
||||
|
||||
var values = new object[reader.FieldCount];
|
||||
if (reader.Read())
|
||||
{
|
||||
reader.GetValues(values);
|
||||
return values;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read data from the result table and return the first row
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DiscordBotCore.Interfaces.Updater
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace DiscordBotCore.Interfaces.Updater
|
||||
|
||||
public int PatchVersion { get; set; }
|
||||
|
||||
public static readonly AppVersion CurrentAppVersion = new AppVersion(Application.CurrentApplication.ApplicationEnvironmentVariables["Version"]);
|
||||
public static readonly AppVersion CurrentAppVersion = new AppVersion(Assembly.GetEntryAssembly().GetName().Version.ToString());
|
||||
|
||||
private readonly char _Separator = '.';
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{8FAE
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicPlayer", "..\SethPlugins\MusicPlayer\MusicPlayer.csproj", "{F094D29D-6F1A-46BC-8B1F-88F3D98FCA84}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LevelingSystem", "..\SethPlugins\LevelingSystem\LevelingSystem.csproj", "{39EF14F8-7E67-4C14-A4F1-E706CFF61192}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -34,12 +36,17 @@ Global
|
||||
{F094D29D-6F1A-46BC-8B1F-88F3D98FCA84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F094D29D-6F1A-46BC-8B1F-88F3D98FCA84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F094D29D-6F1A-46BC-8B1F-88F3D98FCA84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{39EF14F8-7E67-4C14-A4F1-E706CFF61192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{39EF14F8-7E67-4C14-A4F1-E706CFF61192}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{39EF14F8-7E67-4C14-A4F1-E706CFF61192}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{39EF14F8-7E67-4C14-A4F1-E706CFF61192}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{F094D29D-6F1A-46BC-8B1F-88F3D98FCA84} = {8FAEFF5E-F749-435C-BB7B-D57C0F8B17FC}
|
||||
{39EF14F8-7E67-4C14-A4F1-E706CFF61192} = {8FAEFF5E-F749-435C-BB7B-D57C0F8B17FC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3FB3C5DE-ED21-4D2E-ABDD-3A00EE4A2FFF}
|
||||
|
||||
Reference in New Issue
Block a user