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.
103
Program.cs
103
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,10 +128,9 @@ internal class Program
|
||||
}
|
||||
|
||||
return (true, "OK");
|
||||
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
|
||||
private static async Task<(bool status, string msg)> CheckFurnace250()
|
||||
{
|
||||
int cntEmptyPOID = 0;
|
||||
@@ -134,31 +142,43 @@ internal class Program
|
||||
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))
|
||||
@@ -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>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<BaseOutputPath></BaseOutputPath>
|
||||
<PublishAot>False</PublishAot>
|
||||
<PublishTrimmed>False</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@@ -18,24 +21,19 @@
|
||||
|
||||
|
||||
<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="System.Data.SqlClient" Version="4.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oracle.ManagedDataAccess">
|
||||
<HintPath>Oracle.ManagedDataAccess.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="config.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Oracle.ManagedDataAccess.dll">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -3,3 +3,4 @@ app_token_izhstal=A6i4cMWOMSikvsR
|
||||
proxy_url=http://10.14.0.14:3128
|
||||
proxy_username=KhasanovAM
|
||||
proxy_password=Prokatka49!
|
||||
check_now=no
|
||||
Reference in New Issue
Block a user