update
This commit is contained in:
3
FodyWeavers.xml
Normal file
3
FodyWeavers.xml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||||
|
<Costura />
|
||||||
|
</Weavers>
|
||||||
Binary file not shown.
99
Program.cs
99
Program.cs
@@ -1,13 +1,15 @@
|
|||||||
using Oracle.ManagedDataAccess.Client;
|
using Microsoft.Data.SqlClient;
|
||||||
|
using Oracle.ManagedDataAccess.Client;
|
||||||
using SendNotify;
|
using SendNotify;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Data.SqlClient;
|
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
private static DateTime lastDate = DateTime.MinValue;
|
private static DateTime lastDate = DateTime.MinValue;
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@@ -17,6 +19,8 @@ internal class Program
|
|||||||
string? proxyUrl = null;
|
string? proxyUrl = null;
|
||||||
string? proxyUsername = null;
|
string? proxyUsername = null;
|
||||||
string? proxyPassword = null;
|
string? proxyPassword = null;
|
||||||
|
string? checkNow = null;
|
||||||
|
|
||||||
var config = File.ReadAllLines("config.txt");
|
var config = File.ReadAllLines("config.txt");
|
||||||
|
|
||||||
foreach (var line in config)
|
foreach (var line in config)
|
||||||
@@ -31,26 +35,45 @@ internal class Program
|
|||||||
proxyUsername = line.Substring("proxy_username=".Length);
|
proxyUsername = line.Substring("proxy_username=".Length);
|
||||||
else if (line.StartsWith("proxy_password="))
|
else if (line.StartsWith("proxy_password="))
|
||||||
proxyPassword = line.Substring("proxy_password=".Length);
|
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");
|
Console.WriteLine("Ошибка: не все параметры указаны в config.txt");
|
||||||
Log.Logger("Ошибка: не все параметры указаны в config.txt");
|
Log.Logger("Ошибка: не все параметры указаны в config.txt");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
NotifyPollingAsync(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword);
|
{
|
||||||
|
NotifyPollingAsync(gotifyUrl, appToken_izhstal, proxyUrl, proxyUsername, proxyPassword, checkNow);
|
||||||
|
}
|
||||||
|
|
||||||
Thread.Sleep(60000);
|
Thread.Sleep(60000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
private static async void NotifyPollingAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword, string checkNow)
|
||||||
private static async void NotifyPollingAsync(string url, string token, string proxyUrl, string proxyUsername, string proxyPassword)
|
|
||||||
{
|
{
|
||||||
#region check furnace 250
|
#region test msg to check
|
||||||
DateTime now = DateTime.Now;
|
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;
|
var result = CheckFurnace250().Result;
|
||||||
if (!result.status)
|
if (!result.status)
|
||||||
{
|
{
|
||||||
@@ -64,20 +87,6 @@ internal class Program
|
|||||||
}
|
}
|
||||||
#endregion
|
#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
|
#region check billets 250
|
||||||
result = CheckRoughToFinishedBilletCount().Result;
|
result = CheckRoughToFinishedBilletCount().Result;
|
||||||
if (!result.status)
|
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)
|
if (cntBillets > 15)
|
||||||
{
|
{
|
||||||
@@ -119,10 +128,9 @@ internal class Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (true, "OK");
|
return (true, "OK");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
private static async Task<(bool status, string msg)> CheckFurnace250()
|
private static async Task<(bool status, string msg)> CheckFurnace250()
|
||||||
{
|
{
|
||||||
int cntEmptyPOID = 0;
|
int cntEmptyPOID = 0;
|
||||||
@@ -134,21 +142,32 @@ internal class Program
|
|||||||
using (var conn = new SqlConnection(sqlConn))
|
using (var conn = new SqlConnection(sqlConn))
|
||||||
{
|
{
|
||||||
await conn.OpenAsync();
|
await conn.OpenAsync();
|
||||||
string sqlQuery = @"SELECT COUNT(PO_ID) cnt_empty_poid, (SELECT top(1)
|
string sqlQuery = @"SELECT
|
||||||
CHARGING_TIME
|
COUNT(PO_ID) cnt_empty_poid,
|
||||||
FROM [Furnace_l2].[dbo].[HIST_PIECES]
|
(
|
||||||
where [IS_DISCHARGED] ='N' and
|
SELECT
|
||||||
datediff(day,CHARGING_TIME, Getdate()) < 1 AND
|
top(1) CHARGING_TIME
|
||||||
RTRIM(LTRIM(PO_ID)) != ''
|
FROM
|
||||||
order by CHARGING_TIME desc) last_dt
|
[Furnace_l2].[dbo].[HIST_PIECES]
|
||||||
FROM [Furnace_l2].[dbo].[HIST_PIECES]
|
WHERE
|
||||||
where [IS_DISCHARGED] ='N' and
|
[IS_DISCHARGED] = 'N'
|
||||||
datediff(day,CHARGING_TIME, Getdate()) < 1 AND
|
AND datediff(DAY, CHARGING_TIME, Getdate()) < 1
|
||||||
RTRIM(LTRIM(PO_ID)) = '';";
|
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 command = new SqlCommand(sqlQuery, conn))
|
||||||
using (var dbReader = await command.ExecuteReaderAsync())
|
using (var dbReader = await command.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
while (await dbReader.ReadAsync())
|
while (await dbReader.ReadAsync())
|
||||||
|
{
|
||||||
|
if (dbReader.GetValue(0) != DBNull.Value && dbReader.GetValue(1) != DBNull.Value)
|
||||||
{
|
{
|
||||||
cntEmptyPOID = Convert.ToInt32(dbReader.GetValue(0));
|
cntEmptyPOID = Convert.ToInt32(dbReader.GetValue(0));
|
||||||
lastDT = Convert.ToDateTime(dbReader.GetValue(1));
|
lastDT = Convert.ToDateTime(dbReader.GetValue(1));
|
||||||
@@ -156,9 +175,10 @@ internal class Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return (false, "Ошибка подключения к БД sql server печи ПШП!");
|
return (false, ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cntEmptyPOID > 15 && DateTime.Now - lastDT > new TimeSpan(0, 5, 0))
|
if (cntEmptyPOID > 15 && DateTime.Now - lastDT > new TimeSpan(0, 5, 0))
|
||||||
@@ -219,3 +239,4 @@ internal class Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
11
Properties/launchSettings.json
Normal file
11
Properties/launchSettings.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"SendNotify": {
|
||||||
|
"commandName": "Project"
|
||||||
|
},
|
||||||
|
"WSL": {
|
||||||
|
"commandName": "WSL2",
|
||||||
|
"distributionName": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Platforms>AnyCPU</Platforms>
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
<BaseOutputPath></BaseOutputPath>
|
||||||
|
<PublishAot>False</PublishAot>
|
||||||
|
<PublishTrimmed>False</PublishTrimmed>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
@@ -18,24 +21,19 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Costura.Fody" Version="6.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.8.0" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Oracle.ManagedDataAccess">
|
|
||||||
<HintPath>Oracle.ManagedDataAccess.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="config.txt">
|
<None Update="config.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="Oracle.ManagedDataAccess.dll">
|
|
||||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ 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!
|
||||||
|
check_now=no
|
||||||
Reference in New Issue
Block a user