checkpoint

This commit is contained in:
2024-11-16 12:37:56 -06:00
parent 13e79eb490
commit 460dfd608e
10 changed files with 139 additions and 49 deletions

View File

@@ -1,7 +1,9 @@
using Dapper;
using Shogi.Api.Repositories.Dto;
using Shogi.Api.Repositories.Dto.SessionState;
using System.Data;
using System.Data.SqlClient;
using System.Text.Json;
namespace Shogi.Api.Repositories;
@@ -21,4 +23,27 @@ public class QueryRepository(IConfiguration configuration)
return await results.ReadAsync<SessionDto>();
}
public async Task<List<SessionStateDocument>> ReadSessionSnapshots(string sessionId)
{
using var connection = new SqlConnection(this.connectionString);
var command = connection.CreateCommand();
command.CommandText = "session.ReadStatesBySession";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("SessionId", sessionId);
await using var reader = await command.ExecuteReaderAsync();
var documents = new List<SessionStateDocument>(20);
while (await reader.ReadAsync())
{
var json = reader.GetString("Document");
var document = JsonSerializer.Deserialize<SessionStateDocument>(json);
if (document != null)
{
documents.Add(document);
}
}
return documents;
}
}