using System.Printing; using System.Drawing.Printing; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using CVRLIB.Printing; using CVRLIB_NF.Printing; using static VSERVERWS.Global.Globals; namespace VSERVERWS.Controllers { [Route("api/Printer/[action]")] [ApiController] public class PrinterController : ControllerBase { [HttpGet("{id}")] public IActionResult PrinterStatus(string id) { //testing: //https://localhost:7210/api/Printer/PrinterStatus/Canon%20MF260_10.10.20.147 //https://localhost:7210/api/Printer/PrinterStatus/Brother%20MFC-L8900CDW_10.10.20.111 var CVPC = new CVRPrinterCollection(new[] { (CVRPRINTER)CVP_MF264dw, (CVRPRINTER)CVP_MFC_L8900CDW }); var PSR = new PrinterStatusResponse(); foreach (CVRPRINTER CVP in CVPC) { if (CVP.PrinterName.ToLower() == id.ToLower()) { PSR.RawStatus = CVP.LastRawStatus; PSR.STATUS = CVP.LastStatus.ToString(); PSR.PRINTER_NAME = CVP.PrinterName; break; } } return new JsonResult(PSR); } } }