This commit is contained in:
2025-04-14 20:47:28 +04:00
parent 90819d9241
commit 5f1b51fd5f
2 changed files with 32 additions and 10 deletions

View File

@@ -3,12 +3,14 @@ using System.Net;
using System.Text;
internal class Program
{
private static DateTime lastDate = DateTime.MinValue;
private static void Main(string[] args)
{
while (true)
{
DateTime now = DateTime.Now;
string? gotifyUrl = null;
string? appToken_furnace250_l2 = null;
string? appToken_izhstal = null;
string? proxyUrl = null;
string? proxyUsername = null;
string? proxyPassword = null;
@@ -18,8 +20,8 @@ internal class Program
{
if (line.StartsWith("gotify_url="))
gotifyUrl = line.Substring("gotify_url=".Length);
else if (line.StartsWith("app_token_furnace250_l2="))
appToken_furnace250_l2 = line.Substring("app_token_furnace250_l2=".Length);
else if (line.StartsWith("app_token_izhstal="))
appToken_izhstal = line.Substring("app_token_izhstal=".Length);
else if (line.StartsWith("proxy_url="))
proxyUrl = line.Substring("proxy_url=".Length);
else if (line.StartsWith("proxy_username="))
@@ -28,19 +30,29 @@ internal class Program
proxyPassword = line.Substring("proxy_password=".Length);
}
if (gotifyUrl == null || appToken_furnace250_l2 == null || proxyUrl == null || proxyUsername == null || proxyPassword == null)
if (gotifyUrl == null || appToken_izhstal == null || proxyUrl == null || proxyUsername == null || proxyPassword == null)
{
Console.WriteLine("Ошибка: не все параметры указаны в config.txt");
Log("Ошибка: не все параметры указаны в config.txt");
}
else
CheckStatusAsync(gotifyUrl, appToken_furnace250_l2, proxyUrl, proxyUsername, proxyPassword);
{
CheckStatusAsync(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword);
Thread.Sleep(10000);
if (now.Hour == 4 && now.Date != lastDate.Date)
{
TestMSG(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword);
lastDate = now;
}
}
Thread.Sleep(60000);
}
}
private static async void CheckStatusAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword)
{
var result = CheckFurnace250Async().Result;
@@ -54,7 +66,17 @@ internal class Program
};
await SendNotify(url, token, notification, proxyUrl, proxyUsername, proxyPassword);
}
Thread.Sleep(10000);
}
private static async void TestMSG(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword)
{
var notification = new
{
title = "Test notify",
message = "IS OK",
priority = 3
};
await SendNotify(url, token, notification, proxyUrl, proxyUsername, proxyPassword);
}
@@ -97,7 +119,7 @@ internal class Program
if (cntEmptyPOID > 15 && DateTime.Now - lastDT > new TimeSpan(0, 5, 0))
{
return (false, "Проблема с привязкой заготовок в ПШП.");
return (false, $"Проблема с привязкой ID заготовок в ПШП. Не привязанных - {cntEmptyPOID}, время последней привязанной - {lastDT}");
}
return (true, "OK");
@@ -132,7 +154,7 @@ internal class Program
if (response.IsSuccessStatusCode)
{
Console.WriteLine($"{DateTime.Now} - Отправлено сообщение.");
Log($"{DateTime.Now} - Отправлено сообщение.");
Log($"Отправлено сообщение.");
}
else
{

View File

@@ -1,5 +1,5 @@
gotify_url=https://gtf.mysrvhateapple.duckdns.org/message
app_token_furnace250_l2=A6i4cMWOMSikvsR
app_token_izhstal=A6i4cMWOMSikvsR
proxy_url=http://10.14.0.14:3128
proxy_username=KhasanovAM
proxy_password=Prokatka49!