diff --git a/FodyWeavers.xml b/FodyWeavers.xml
new file mode 100644
index 0000000..5029e70
--- /dev/null
+++ b/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/Oracle.ManagedDataAccess.dll b/Oracle.ManagedDataAccess.dll
deleted file mode 100644
index 59db591..0000000
Binary files a/Oracle.ManagedDataAccess.dll and /dev/null differ
diff --git a/Program.cs b/Program.cs
index 4632f02..2aa0382 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,13 +1,15 @@
-using Oracle.ManagedDataAccess.Client;
+using Microsoft.Data.SqlClient;
+using Oracle.ManagedDataAccess.Client;
using SendNotify;
using System.Net;
+using System.Net.Http.Json;
using System.Text;
-using System.Data.SqlClient;
+
internal class Program
{
private static DateTime lastDate = DateTime.MinValue;
- [Obsolete]
+
private static void Main(string[] args)
{
while (true)
@@ -17,6 +19,8 @@ internal class Program
string? proxyUrl = null;
string? proxyUsername = null;
string? proxyPassword = null;
+ string? checkNow = null;
+
var config = File.ReadAllLines("config.txt");
foreach (var line in config)
@@ -31,26 +35,45 @@ internal class Program
proxyUsername = line.Substring("proxy_username=".Length);
else if (line.StartsWith("proxy_password="))
proxyPassword = line.Substring("proxy_password=".Length);
+ else if (line.StartsWith("check_now="))
+ checkNow = line.Substring("check_now=".Length);
}
- if (gotifyUrl == null || appToken_izhstal == null || proxyUrl == null || proxyUsername == null || proxyPassword == null)
+ if (gotifyUrl == null || appToken_izhstal == null || proxyUrl == null || proxyUsername == null || proxyPassword == null || checkNow == null)
{
Console.WriteLine("Ошибка: не все параметры указаны в config.txt");
Log.Logger("Ошибка: не все параметры указаны в config.txt");
}
else
- NotifyPollingAsync(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword);
+ {
+ NotifyPollingAsync(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword, checkNow);
+ }
Thread.Sleep(60000);
}
}
- [Obsolete]
- private static async void NotifyPollingAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword)
+ private static async void NotifyPollingAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword, string checkNow)
{
- #region check furnace 250
+ #region test msg to check
DateTime now = DateTime.Now;
+ if ((now.Hour == 8 && now.Date != lastDate.Date) || checkNow.ToLower() == "yes")
+ {
+ var notification = new
+ {
+ title = "Test notify",
+ message = "IS OK",
+ priority = 3
+ };
+ await SendNotify(url, token, notification, proxyUrl, proxyUsername, proxyPassword);
+
+ if (checkNow.ToLower() != "yes")
+ lastDate = now;
+ }
+ #endregion
+
+ #region check furnace 250
var result = CheckFurnace250().Result;
if (!result.status)
{
@@ -64,20 +87,6 @@ internal class Program
}
#endregion
- #region test msg to check
- if (now.Hour == 8 && now.Date != lastDate.Date)
- {
- var notification = new
- {
- title = "Test notify",
- message = "IS OK",
- priority = 3
- };
- await SendNotify(url, token, notification, proxyUrl, proxyUsername, proxyPassword);
- lastDate = now;
- }
- #endregion
-
#region check billets 250
result = CheckRoughToFinishedBilletCount().Result;
if (!result.status)
@@ -109,9 +118,9 @@ internal class Program
}
}
}
- catch
+ catch (Exception ex)
{
- return (false, "Ошибка подключения к БД Oracle ст.250!");
+ return (false, ex.Message);
}
if (cntBillets > 15)
{
@@ -119,46 +128,57 @@ internal class Program
}
return (true, "OK");
-
}
- [Obsolete]
+
private static async Task<(bool status, string msg)> CheckFurnace250()
{
int cntEmptyPOID = 0;
DateTime lastDT = DateTime.Now;
const string sqlConn = @"Password=WonderUser;User ID=WonderUser;Initial Catalog=Furnace_l2;Data Source=10.14.18.38\IZHSTALSQLSRVER;TrustServerCertificate=true;Encrypt=true;";
-
+
try
{
using (var conn = new SqlConnection(sqlConn))
{
await conn.OpenAsync();
- string sqlQuery = @"SELECT COUNT(PO_ID) cnt_empty_poid, (SELECT top(1)
- CHARGING_TIME
- FROM [Furnace_l2].[dbo].[HIST_PIECES]
- where [IS_DISCHARGED] ='N' and
- datediff(day,CHARGING_TIME, Getdate()) < 1 AND
- RTRIM(LTRIM(PO_ID)) != ''
- order by CHARGING_TIME desc) last_dt
- FROM [Furnace_l2].[dbo].[HIST_PIECES]
- where [IS_DISCHARGED] ='N' and
- datediff(day,CHARGING_TIME, Getdate()) < 1 AND
- RTRIM(LTRIM(PO_ID)) = '';";
+ string sqlQuery = @"SELECT
+ COUNT(PO_ID) cnt_empty_poid,
+ (
+ SELECT
+ top(1) CHARGING_TIME
+ FROM
+ [Furnace_l2].[dbo].[HIST_PIECES]
+ WHERE
+ [IS_DISCHARGED] = 'N'
+ AND datediff(DAY, CHARGING_TIME, Getdate()) < 1
+ AND RTRIM(LTRIM(PO_ID)) != ''
+ ORDER BY
+ CHARGING_TIME DESC
+ ) last_dt
+ FROM
+ [Furnace_l2].[dbo].[HIST_PIECES]
+ WHERE
+ [IS_DISCHARGED] = 'N'
+ AND datediff(DAY, CHARGING_TIME, Getdate()) < 1
+ AND RTRIM(LTRIM(PO_ID)) = '';";
using (var command = new SqlCommand(sqlQuery, conn))
using (var dbReader = await command.ExecuteReaderAsync())
{
while (await dbReader.ReadAsync())
{
- cntEmptyPOID = Convert.ToInt32(dbReader.GetValue(0));
- lastDT = Convert.ToDateTime(dbReader.GetValue(1));
+ if (dbReader.GetValue(0) != DBNull.Value && dbReader.GetValue(1) != DBNull.Value)
+ {
+ cntEmptyPOID = Convert.ToInt32(dbReader.GetValue(0));
+ lastDT = Convert.ToDateTime(dbReader.GetValue(1));
+ }
}
}
}
}
- catch
+ catch (Exception ex)
{
- return (false, "Ошибка подключения к БД sql server печи ПШП!");
+ return (false, ex.Message);
}
if (cntEmptyPOID > 15 && DateTime.Now - lastDT > new TimeSpan(0, 5, 0))
@@ -218,4 +238,5 @@ internal class Program
}
}
}
-}
\ No newline at end of file
+}
+
\ No newline at end of file
diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json
new file mode 100644
index 0000000..8c0a3c8
--- /dev/null
+++ b/Properties/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "profiles": {
+ "SendNotify": {
+ "commandName": "Project"
+ },
+ "WSL": {
+ "commandName": "WSL2",
+ "distributionName": ""
+ }
+ }
+}
\ No newline at end of file
diff --git a/SendNotify.csproj b/SendNotify.csproj
index 9a52065..e922250 100644
--- a/SendNotify.csproj
+++ b/SendNotify.csproj
@@ -6,6 +6,9 @@
enable
enable
AnyCPU
+
+ False
+ False
@@ -18,24 +21,19 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
-
-
-
-
-
- Oracle.ManagedDataAccess.dll
- True
-
+
Always
-
- Never
-
diff --git a/config.txt b/config.txt
index a6323e7..a2496b7 100644
--- a/config.txt
+++ b/config.txt
@@ -2,4 +2,5 @@ gotify_url=https://gtf.mysrvhateapple.duckdns.org/message
app_token_izhstal=A6i4cMWOMSikvsR
proxy_url=http://10.14.0.14:3128
proxy_username=KhasanovAM
-proxy_password=Prokatka49!
\ No newline at end of file
+proxy_password=Prokatka49!
+check_now=no
\ No newline at end of file