Обновление SQL-запроса и добавление новых полей
Изменён SQL-запрос в классе `Program` для извлечения дополнительных полей: `Priority`, `Room`, `ReporterName` и `DateCreated`. Обновлён код для обработки новых данных и форматирования сообщения. Добавлен новый метод `UpdateReportStatus` для обновления статуса отчета.
This commit is contained in:
parent
f7c4567e18
commit
e093fa6a7e
20
Program.cs
20
Program.cs
@ -548,15 +548,19 @@ class Program
|
|||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
var command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
command.CommandText = "SELECT Description, Status FROM Reports WHERE Id = @id";
|
command.CommandText = "SELECT Priority, Room, Description, ReporterName, Status, DateCreated FROM Reports WHERE Id = @id";
|
||||||
command.Parameters.AddWithValue("@id", reportId);
|
command.Parameters.AddWithValue("@id", reportId);
|
||||||
|
|
||||||
using (var reader = await command.ExecuteReaderAsync())
|
using (var reader = await command.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
if (await reader.ReadAsync())
|
if (await reader.ReadAsync())
|
||||||
{
|
{
|
||||||
string description = reader.GetString(0);
|
string priority = reader.GetString(0);
|
||||||
string status = reader.GetString(1);
|
string room = reader.GetString(1);
|
||||||
|
string description = reader.GetString(2);
|
||||||
|
string reporterName = reader.GetString(3);
|
||||||
|
string status = reader.GetString(4);
|
||||||
|
string dateCreated = reader.GetDateTime(5).ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
var statusButtons = new InlineKeyboardMarkup(new[]
|
var statusButtons = new InlineKeyboardMarkup(new[]
|
||||||
{
|
{
|
||||||
@ -580,7 +584,13 @@ class Program
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
string newText = $"Заявка #{reportId}\n\nОписание: {description}\nСтатус: {status}";
|
string newText = $"Заявка #{reportId}\n\n" +
|
||||||
|
$"Приоритет: {priority}\n" +
|
||||||
|
$"Кабинет: {room}\n" +
|
||||||
|
$"Описание: {description}\n" +
|
||||||
|
$"ФИО: {reporterName}\n" +
|
||||||
|
$"Статус: {status}\n" +
|
||||||
|
$"Дата создания: {dateCreated}";
|
||||||
|
|
||||||
await botClient.SendMessage(
|
await botClient.SendMessage(
|
||||||
chatId: chatId,
|
chatId: chatId,
|
||||||
@ -601,6 +611,8 @@ class Program
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static async Task UpdateReportStatus(long reportId, string newStatus)
|
private static async Task UpdateReportStatus(long reportId, string newStatus)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user