mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 20:40:55 +00:00
Более менее сделал страничку с принтером
This commit is contained in:
1 parent
286beabf89
commit
9a486a57b4
9 files changed
+103
-32
No files matched your search
@@ -36,9 +36,8 @@ namespace CartriX.Api.Controllers.Network
|
||||
/// Сделать ПИНГ к указанному хосту или IP Адресу
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(bool), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(bool), StatusCodes.Status404NotFound)]
|
||||
[HttpGet(nameof(Ping))]
|
||||
public async Task<ActionResult> Ping([FromQuery] string IpAddressOrHostname) => (await NetworkHelper.PingHostAsync(IpAddressOrHostname)) ? StatusCode(200, true) : StatusCode(404, false);
|
||||
public async Task<ActionResult> Ping([FromQuery] string IpAddressOrHostname) => StatusCode(200, await NetworkHelper.PingHostAsync(IpAddressOrHostname));
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -71,8 +71,9 @@ namespace CartriX.Api.Controllers.Printer
|
||||
/// Поменять статус принтера
|
||||
/// </summary>
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[HttpPut(nameof(ChangeStatus))]
|
||||
public async Task<ActionResult> ChangeStatus([FromQuery] int PrinterId, [FromQuery] int StatusId)
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[HttpPatch(nameof(ChangeStatus))]
|
||||
public async Task<ActionResult> ChangeStatus([FromQuery] int PrinterId, [FromBody] int StatusId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
Model = printer.Model.ToItem(),
|
||||
StatusId = printer.StatusId,
|
||||
StatusName = printer.Status.Name,
|
||||
ConnetctionTypeId = printer.PrinterConnetctionTypeId,
|
||||
ConnetctionTypeName = printer.PrinterConnetctionType.Name,
|
||||
InstalledCartridgeId = printer.InstalledCartridge.Id,
|
||||
LocationName = printer.Location.Name,
|
||||
|
||||
@@ -69,7 +69,11 @@ namespace CartriX.Api.Controllers.Cartridge
|
||||
var printer = await _context.Printers.FindAsync(PrinterId);
|
||||
if (printer is not null)
|
||||
{
|
||||
if (await _context.PrinterStatuses.FindAsync(StatusId) is not null) printer.StatusId = StatusId;
|
||||
if (await _context.PrinterStatuses.FindAsync(StatusId) is not null)
|
||||
{
|
||||
printer.StatusId = StatusId;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
else throw new NullReferenceException($"Нету статуса под идентификатором {StatusId}");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace CartriX.Api.Service
|
||||
await AnsiConsole.Status()
|
||||
.StartAsync("[bold cyan]Получение списка принтеров...[/]", async ctx =>
|
||||
{
|
||||
List<Entities.Printer> printersList = await dbContext.Printers.Where(p => p.PrinterConnetctionTypeId == 1).AsTracking().ToListAsync();
|
||||
List<Entities.Printer> printersList = await dbContext.Printers.Where(p => p.PrinterConnetctionTypeId == 1).Where(p => p.StatusId != 3).AsTracking().ToListAsync();
|
||||
|
||||
ctx.Status($"[green]✓[/] Получен список ({printersList.Count} устройств)");
|
||||
await Task.Delay(500);
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user