фикс настройки уведов о просрочке
This commit is contained in:
parent
de22b30321
commit
59f90aaa5c
37
Program.cs
37
Program.cs
@ -92,8 +92,8 @@ class Program
|
||||
|
||||
private static async Task MonitorReportStatus(long reportId, CancellationToken token)
|
||||
{
|
||||
// Ждем 15 секунд перед первой проверкой
|
||||
await Task.Delay(15000, token);
|
||||
// Ждем 1 час перед первой проверкой
|
||||
await Task.Delay(TimeSpan.FromHours(1), token);
|
||||
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
@ -104,9 +104,9 @@ class Program
|
||||
await connection.OpenAsync();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = @"
|
||||
SELECT Status
|
||||
FROM Reports
|
||||
WHERE Id = @id";
|
||||
SELECT Status
|
||||
FROM Reports
|
||||
WHERE Id = @id";
|
||||
command.Parameters.AddWithValue("@id", reportId);
|
||||
|
||||
var status = (string?)await command.ExecuteScalarAsync();
|
||||
@ -117,12 +117,23 @@ class Program
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var adminId in admins)
|
||||
var getAdminsCommand = connection.CreateCommand();
|
||||
getAdminsCommand.CommandText = "SELECT ChatId, NotifyOnPendingReports FROM Admins";
|
||||
using (var reader = await getAdminsCommand.ExecuteReaderAsync())
|
||||
{
|
||||
await _botClient.SendMessage(
|
||||
chatId: adminId,
|
||||
text: $"⚠️ Заявка #{reportId} остается в статусе 'Ожидает'."
|
||||
);
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
long adminId = reader.GetInt64(0);
|
||||
bool notifyOnPendingReports = reader.GetInt32(1) == 1;
|
||||
|
||||
if (notifyOnPendingReports)
|
||||
{
|
||||
await _botClient.SendMessage(
|
||||
chatId: adminId,
|
||||
text: $"⚠️ Заявка #{reportId} остается в статусе 'Ожидает'."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,12 +142,13 @@ class Program
|
||||
Log.Error($"Ошибка при мониторинге статуса заявки #{reportId}: {ex.Message}");
|
||||
}
|
||||
|
||||
// Ждем 15 секунд перед следующей проверкой
|
||||
await Task.Delay(15000, token);
|
||||
// Ждем 1 час перед следующей проверкой
|
||||
await Task.Delay(TimeSpan.FromHours(1), token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static async Task DeletePreviousMessage(ITelegramBotClient botClient, long chatId, int messageId)
|
||||
{
|
||||
try
|
||||
@ -1370,6 +1382,7 @@ class Program
|
||||
|
||||
|
||||
|
||||
|
||||
private static async Task NotifyAdminsAboutWorkAssignment(long reportId, long changerId)
|
||||
{
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user