update
This commit is contained in:
40
Program.cs
40
Program.cs
@@ -3,12 +3,14 @@ using System.Net;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
|
private static DateTime lastDate = DateTime.MinValue;
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
string? gotifyUrl = null;
|
string? gotifyUrl = null;
|
||||||
string? appToken_furnace250_l2 = null;
|
string? appToken_izhstal = null;
|
||||||
string? proxyUrl = null;
|
string? proxyUrl = null;
|
||||||
string? proxyUsername = null;
|
string? proxyUsername = null;
|
||||||
string? proxyPassword = null;
|
string? proxyPassword = null;
|
||||||
@@ -18,8 +20,8 @@ internal class Program
|
|||||||
{
|
{
|
||||||
if (line.StartsWith("gotify_url="))
|
if (line.StartsWith("gotify_url="))
|
||||||
gotifyUrl = line.Substring("gotify_url=".Length);
|
gotifyUrl = line.Substring("gotify_url=".Length);
|
||||||
else if (line.StartsWith("app_token_furnace250_l2="))
|
else if (line.StartsWith("app_token_izhstal="))
|
||||||
appToken_furnace250_l2 = line.Substring("app_token_furnace250_l2=".Length);
|
appToken_izhstal = line.Substring("app_token_izhstal=".Length);
|
||||||
else if (line.StartsWith("proxy_url="))
|
else if (line.StartsWith("proxy_url="))
|
||||||
proxyUrl = line.Substring("proxy_url=".Length);
|
proxyUrl = line.Substring("proxy_url=".Length);
|
||||||
else if (line.StartsWith("proxy_username="))
|
else if (line.StartsWith("proxy_username="))
|
||||||
@@ -28,19 +30,29 @@ internal class Program
|
|||||||
proxyPassword = line.Substring("proxy_password=".Length);
|
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");
|
Console.WriteLine("Ошибка: не все параметры указаны в config.txt");
|
||||||
Log("Ошибка: не все параметры указаны в config.txt");
|
Log("Ошибка: не все параметры указаны в config.txt");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
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)
|
private static async void CheckStatusAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword)
|
||||||
{
|
{
|
||||||
var result = CheckFurnace250Async().Result;
|
var result = CheckFurnace250Async().Result;
|
||||||
@@ -54,7 +66,17 @@ internal class Program
|
|||||||
};
|
};
|
||||||
await SendNotify(url, token, notification, proxyUrl, proxyUsername, proxyPassword);
|
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))
|
if (cntEmptyPOID > 15 && DateTime.Now - lastDT > new TimeSpan(0, 5, 0))
|
||||||
{
|
{
|
||||||
return (false, "Проблема с привязкой заготовок в ПШП.");
|
return (false, $"Проблема с привязкой ID заготовок в ПШП. Не привязанных - {cntEmptyPOID}, время последней привязанной - {lastDT}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (true, "OK");
|
return (true, "OK");
|
||||||
@@ -132,7 +154,7 @@ internal class Program
|
|||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{DateTime.Now} - Отправлено сообщение.");
|
Console.WriteLine($"{DateTime.Now} - Отправлено сообщение.");
|
||||||
Log($"{DateTime.Now} - Отправлено сообщение.");
|
Log($"Отправлено сообщение.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
gotify_url=https://gtf.mysrvhateapple.duckdns.org/message
|
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_url=http://10.14.0.14:3128
|
||||||
proxy_username=KhasanovAM
|
proxy_username=KhasanovAM
|
||||||
proxy_password=Prokatka49!
|
proxy_password=Prokatka49!
|
||||||
Reference in New Issue
Block a user