@using CartriX.Shared.DTOs.Printer
Результат запроса принтера
Имя хоста
@if (processingQueryToPrinter)
{
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.hostname;
}
else
{
}
IP Адрес
@if (processingQueryToPrinter)
{
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.ipAddress;
}
else
{
}
Модель принтера
@if (processingQueryToPrinter)
{
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.model;
}
else
{
}
Местоположение
@if (processingQueryToPrinter)
{
}
else if (queryPrinterToAdd is not null)
{
@queryPrinterToAdd.location;
}
else
{
}
@code {
private string printerIpOrHostname = "";
private bool processingQueryToPrinter = false;
QueryPrinterToAdd queryPrinterToAdd = null!;
private async Task OnQueryPrinter()
{
if (string.IsNullOrWhiteSpace(printerIpOrHostname))
return;
processingQueryToPrinter = true;
try
{
HttpClient client = new();
var response = await client.GetAsync($"http://localhost:5197/api/Printer/GetSNMP/{printerIpOrHostname}");
if (response.IsSuccessStatusCode)
{
var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
queryPrinterToAdd = result!;
}
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка: {ex.Message}");
}
finally
{
processingQueryToPrinter = false;
}
}
}