Files
work/LC_Error/Program.cs
T
astankovmi bf51924adb
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 13s
add projects
2026-03-18 15:37:59 +03:00

71 lines
1.7 KiB
C#

using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
namespace LC_Error
{
internal class Program
{
static HttpClient httpClient = new HttpClient();
static int _type;
static int _status;
static string _name;
static string _ip;
static async Task Main(string[] args)
{
CheckType(args[0]);
CheckStatus(args[1]);
_name = args[2];
_ip = args[3];
var e = new Error()
{
Id = 0,
TypeDev = (typeDev)_type,
MsgId = 0,
Status = (statusDev)_status,
Name = _name,
Ip = _ip,
DataError = DateTime.Now,
};
JsonContent content = JsonContent.Create(e);
// отправляем запрос
var response = await httpClient.PostAsync("http://172.24.6.242/api/error", content);
}
static void CheckType(string type)
{
switch (type)
{
case "Camera":
_type = 1;
break;
case "Server":
_type = 2;
break;
case "Workstation":
_type = 3;
break;
case "Rack server":
_type = 4;
break;
default:
_type = 0;
break;
}
}
static void CheckStatus(string status)
{
if (status.Contains("не"))
_status = 0;
else
_status = 1;
}
}
}