фикс просрочки уведомлений
This commit is contained in:
parent
8eba4a48bd
commit
c71c6f1fd3
18
Program.cs
18
Program.cs
@ -92,6 +92,9 @@ class Program
|
|||||||
|
|
||||||
private static async Task MonitorReportStatus(long reportId, CancellationToken token)
|
private static async Task MonitorReportStatus(long reportId, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
// Ждем 15 секунд перед первой проверкой
|
||||||
|
await Task.Delay(15000, token);
|
||||||
|
|
||||||
while (!token.IsCancellationRequested)
|
while (!token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -101,9 +104,9 @@ class Program
|
|||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
var command = connection.CreateCommand();
|
var command = connection.CreateCommand();
|
||||||
command.CommandText = @"
|
command.CommandText = @"
|
||||||
SELECT Status
|
SELECT Status
|
||||||
FROM Reports
|
FROM Reports
|
||||||
WHERE Id = @id";
|
WHERE Id = @id";
|
||||||
command.Parameters.AddWithValue("@id", reportId);
|
command.Parameters.AddWithValue("@id", reportId);
|
||||||
|
|
||||||
var status = (string?)await command.ExecuteScalarAsync();
|
var status = (string?)await command.ExecuteScalarAsync();
|
||||||
@ -133,6 +136,7 @@ class Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static async Task DeletePreviousMessage(ITelegramBotClient botClient, long chatId, int messageId)
|
private static async Task DeletePreviousMessage(ITelegramBotClient botClient, long chatId, int messageId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1451,6 +1455,13 @@ class Program
|
|||||||
{
|
{
|
||||||
await NotifyAdminsAboutWorkAssignment(reportId, changerId);
|
await NotifyAdminsAboutWorkAssignment(reportId, changerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Перезапускаем мониторинг, если статус изменился обратно на "ожидает"
|
||||||
|
if (newStatus == "ожидает")
|
||||||
|
{
|
||||||
|
var cts = new CancellationTokenSource();
|
||||||
|
_ = Task.Run(() => MonitorReportStatus(reportId, cts.Token));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -1462,6 +1473,7 @@ class Program
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static async Task SaveReportToDatabase(long chatId, Report report)
|
private static async Task SaveReportToDatabase(long chatId, Report report)
|
||||||
{
|
{
|
||||||
string connectionString = "Data Source=bot.db"; // Используем SQLite
|
string connectionString = "Data Source=bot.db"; // Используем SQLite
|
||||||
|
Loading…
x
Reference in New Issue
Block a user