фикс настройки уведов о просрочке

This commit is contained in:
107 2025-03-20 12:11:21 +07:00
parent de22b30321
commit 59f90aaa5c

View File

@ -92,8 +92,8 @@ class Program
private static async Task MonitorReportStatus(long reportId, CancellationToken token) private static async Task MonitorReportStatus(long reportId, CancellationToken token)
{ {
// Ждем 15 секунд перед первой проверкой // Ждем 1 час перед первой проверкой
await Task.Delay(15000, token); await Task.Delay(TimeSpan.FromHours(1), token);
while (!token.IsCancellationRequested) while (!token.IsCancellationRequested)
{ {
@ -117,7 +117,16 @@ class Program
return; return;
} }
foreach (var adminId in admins) var getAdminsCommand = connection.CreateCommand();
getAdminsCommand.CommandText = "SELECT ChatId, NotifyOnPendingReports FROM Admins";
using (var reader = await getAdminsCommand.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
{
long adminId = reader.GetInt64(0);
bool notifyOnPendingReports = reader.GetInt32(1) == 1;
if (notifyOnPendingReports)
{ {
await _botClient.SendMessage( await _botClient.SendMessage(
chatId: adminId, chatId: adminId,
@ -126,17 +135,20 @@ class Program
} }
} }
} }
}
}
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Ошибка при мониторинге статуса заявки #{reportId}: {ex.Message}"); Log.Error($"Ошибка при мониторинге статуса заявки #{reportId}: {ex.Message}");
} }
// Ждем 15 секунд перед следующей проверкой // Ждем 1 час перед следующей проверкой
await Task.Delay(15000, token); await Task.Delay(TimeSpan.FromHours(1), token);
} }
} }
private static async Task DeletePreviousMessage(ITelegramBotClient botClient, long chatId, int messageId) private static async Task DeletePreviousMessage(ITelegramBotClient botClient, long chatId, int messageId)
{ {
try try
@ -1370,6 +1382,7 @@ class Program
private static async Task NotifyAdminsAboutWorkAssignment(long reportId, long changerId) private static async Task NotifyAdminsAboutWorkAssignment(long reportId, long changerId)
{ {
try try