еще попытка сортировки
This commit is contained in:
parent
c106e1cac3
commit
e808cae59c
52
Program.cs
52
Program.cs
@ -562,9 +562,9 @@ class Program
|
|||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
var command = connection.CreateCommand();
|
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())
|
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 description = reader.GetString(1).Substring(0, Math.Min(20, reader.GetString(1).Length));
|
||||||
string status = reader.GetString(2);
|
string status = reader.GetString(2);
|
||||||
string priority = reader.GetString(3);
|
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[]
|
buttons.Add(new[]
|
||||||
{
|
{
|
||||||
InlineKeyboardButton.WithCallbackData(
|
InlineKeyboardButton.WithCallbackData(
|
||||||
$"{priorityMarker} #{id} - {statusEmoji} {status} - {description}...",
|
$"{priorityMarker} #{report.Id} - {statusEmoji} {report.Status} - {report.Description}...",
|
||||||
$"report_{id}")
|
$"report_{report.Id}")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Добавляем кнопки навигации
|
// Добавляем кнопки навигации
|
||||||
buttons.Add(new[]
|
buttons.Add(new[]
|
||||||
@ -611,6 +622,7 @@ class Program
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static async Task ViewArchivedReports(ITelegramBotClient botClient, long chatId)
|
private static async Task ViewArchivedReports(ITelegramBotClient botClient, long chatId)
|
||||||
{
|
{
|
||||||
string connectionString = "Data Source=bot.db";
|
string connectionString = "Data Source=bot.db";
|
||||||
@ -621,9 +633,9 @@ class Program
|
|||||||
{
|
{
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
var command = connection.CreateCommand();
|
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())
|
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 description = reader.GetString(1).Substring(0, Math.Min(20, reader.GetString(1).Length));
|
||||||
string status = reader.GetString(2);
|
string status = reader.GetString(2);
|
||||||
string priority = reader.GetString(3);
|
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[]
|
buttons.Add(new[]
|
||||||
{
|
{
|
||||||
InlineKeyboardButton.WithCallbackData(
|
InlineKeyboardButton.WithCallbackData(
|
||||||
$"{priorityMarker} #{id} - {statusEmoji} {status} - {description}...",
|
$"{priorityMarker} #{report.Id} - {statusEmoji} {report.Status} - {report.Description}...",
|
||||||
$"report_{id}")
|
$"report_{report.Id}")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Добавляем кнопки навигации
|
// Добавляем кнопки навигации
|
||||||
buttons.Add(new[]
|
buttons.Add(new[]
|
||||||
@ -669,6 +692,7 @@ class Program
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static async Task ShowReportDetails(ITelegramBotClient botClient, long chatId, long reportId, int messageId)
|
private static async Task ShowReportDetails(ITelegramBotClient botClient, long chatId, long reportId, int messageId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user