фикс настройки уведов о просрочке
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)
|
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)
|
||||||
{
|
{
|
||||||
@ -104,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();
|
||||||
@ -117,12 +117,23 @@ 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())
|
||||||
{
|
{
|
||||||
await _botClient.SendMessage(
|
while (await reader.ReadAsync())
|
||||||
chatId: adminId,
|
{
|
||||||
text: $"⚠️ Заявка #{reportId} остается в статусе 'Ожидает'."
|
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}");
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user