еще попытка сортировки
This commit is contained in:
parent
c106e1cac3
commit
e808cae59c
52
Program.cs
52
Program.cs
@ -562,9 +562,9 @@ class Program
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = "SELECT Id, Description, Status, Priority FROM Reports WHERE Status != 'закрыта' ORDER BY CASE Priority WHEN 'высокий' THEN 1 WHEN 'средний' THEN 2 ELSE 3 END";
|
||||
command.CommandText = "SELECT Id, Description, Status, Priority FROM Reports WHERE Status != 'закрыта'";
|
||||
|
||||
var buttons = new List<InlineKeyboardButton[]>();
|
||||
var reports = new List<(long Id, string Description, string Status, string Priority)>();
|
||||
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
@ -574,17 +574,28 @@ class Program
|
||||
string description = reader.GetString(1).Substring(0, Math.Min(20, reader.GetString(1).Length));
|
||||
string status = reader.GetString(2);
|
||||
string priority = reader.GetString(3);
|
||||
string statusEmoji = GetStatusEmoji(status);
|
||||
string priorityMarker = priority.ToLower() == "высокий" ? "⚠️" : "";
|
||||
|
||||
reports.Add((id, description, status, priority));
|
||||
}
|
||||
}
|
||||
|
||||
// Сортируем заявки по приоритету
|
||||
reports.Sort((x, y) => string.Compare(y.Priority, x.Priority, StringComparison.Ordinal));
|
||||
|
||||
var buttons = new List<InlineKeyboardButton[]>();
|
||||
|
||||
foreach (var report in reports)
|
||||
{
|
||||
string statusEmoji = GetStatusEmoji(report.Status);
|
||||
string priorityMarker = report.Priority.ToLower() == "высокий" ? "⚠️" : "";
|
||||
|
||||
buttons.Add(new[]
|
||||
{
|
||||
InlineKeyboardButton.WithCallbackData(
|
||||
$"{priorityMarker} #{id} - {statusEmoji} {status} - {description}...",
|
||||
$"report_{id}")
|
||||
$"{priorityMarker} #{report.Id} - {statusEmoji} {report.Status} - {report.Description}...",
|
||||
$"report_{report.Id}")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем кнопки навигации
|
||||
buttons.Add(new[]
|
||||
@ -611,6 +622,7 @@ class Program
|
||||
|
||||
|
||||
|
||||
|
||||
private static async Task ViewArchivedReports(ITelegramBotClient botClient, long chatId)
|
||||
{
|
||||
string connectionString = "Data Source=bot.db";
|
||||
@ -621,9 +633,9 @@ class Program
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = "SELECT Id, Description, Status, Priority FROM Reports WHERE Status = 'закрыта' ORDER BY CASE Priority WHEN 'высокий' THEN 1 WHEN 'средний' THEN 2 ELSE 3 END";
|
||||
command.CommandText = "SELECT Id, Description, Status, Priority FROM Reports WHERE Status = 'закрыта'";
|
||||
|
||||
var buttons = new List<InlineKeyboardButton[]>();
|
||||
var reports = new List<(long Id, string Description, string Status, string Priority)>();
|
||||
|
||||
using (var reader = await command.ExecuteReaderAsync())
|
||||
{
|
||||
@ -633,17 +645,28 @@ class Program
|
||||
string description = reader.GetString(1).Substring(0, Math.Min(20, reader.GetString(1).Length));
|
||||
string status = reader.GetString(2);
|
||||
string priority = reader.GetString(3);
|
||||
string statusEmoji = GetStatusEmoji(status);
|
||||
string priorityMarker = priority.ToLower() == "высокий" ? "⚠️" : "";
|
||||
|
||||
reports.Add((id, description, status, priority));
|
||||
}
|
||||
}
|
||||
|
||||
// Сортируем заявки по приоритету
|
||||
reports.Sort((x, y) => string.Compare(y.Priority, x.Priority, StringComparison.Ordinal));
|
||||
|
||||
var buttons = new List<InlineKeyboardButton[]>();
|
||||
|
||||
foreach (var report in reports)
|
||||
{
|
||||
string statusEmoji = GetStatusEmoji(report.Status);
|
||||
string priorityMarker = report.Priority.ToLower() == "высокий" ? "⚠️" : "";
|
||||
|
||||
buttons.Add(new[]
|
||||
{
|
||||
InlineKeyboardButton.WithCallbackData(
|
||||
$"{priorityMarker} #{id} - {statusEmoji} {status} - {description}...",
|
||||
$"report_{id}")
|
||||
$"{priorityMarker} #{report.Id} - {statusEmoji} {report.Status} - {report.Description}...",
|
||||
$"report_{report.Id}")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем кнопки навигации
|
||||
buttons.Add(new[]
|
||||
@ -669,6 +692,7 @@ class Program
|
||||
|
||||
|
||||
|
||||
|
||||
private static async Task ShowReportDetails(ITelegramBotClient botClient, long chatId, long reportId, int messageId)
|
||||
{
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user