diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/Domain/EventFactory.cs b/Server/Enlight.Tts/Enlight.Tts.Core/Domain/EventFactory.cs index cd5ceee211e56191cf764c0bb1a51d9e70da0294..064ff1888246ed27169cf1707a01fe061e5d30cb 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/Domain/EventFactory.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Core/Domain/EventFactory.cs @@ -8,7 +8,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Printer with name {p.Name} added.", + Message = $"Å tampaÄ pod nazivom {p.Name} dodat.", PrinterId = p.Id, UserId = "Admin" }; @@ -20,7 +20,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Printer with name {p.Name} updated.", + Message = $"Å tampaÄ pod nazivom {p.Name} izmenjen.", PrinterId = p.Id, UserId = "Admin" }; @@ -32,7 +32,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Printer with name {p.Name} deleted.", + Message = $"Å tampaÄ pod nazivom {p.Name} obrisan.", PrinterId = p.Id, UserId = "Admin" }; @@ -44,7 +44,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Template with name {t.TemplateName} added.", + Message = $"Å ablon pod nazivom {t.TemplateName} dodat.", UserId = "Admin" }; } @@ -55,7 +55,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Template with name {t.TemplateName} updated.", + Message = $"Å ablon pod nazivom {t.TemplateName} izmenjen.", UserId = "Admin" }; } @@ -66,7 +66,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Template with name {t.TemplateName} deleted.", + Message = $"Å ablon pod nazivom {t.TemplateName} obrisan.", UserId = "Admin" }; } @@ -78,7 +78,7 @@ public static class EventFactory { EventType = (int)EventType.Error, TimeStamp = DateTime.Now, - Message = $"Printer with Name {qrCode} not valid.", + Message = $"Å tampaÄ pod nazivom {qrCode} nije validan.", UserId = userId }; @@ -86,7 +86,7 @@ public static class EventFactory { EventType = (int)EventType.Validation, TimeStamp = DateTime.Now, - Message = $"Printer with Name {qrCode} valid.", + Message = $"Å tampaÄ pod nazivom {qrCode} validan.", UserId = userId, PrinterId = printer.Id!.Value }; @@ -98,7 +98,7 @@ public static class EventFactory { EventType = (int)EventType.Validation, TimeStamp = DateTime.Now, - Message = $"Order checked with Code: {qrCode}. Order Id: {orderId}, Product Id: {productId}, BinId: {binId}", + Message = $"Nalog Äekiran sa kodom: {qrCode}. Id naloga: {orderId}, Id proizvoda: {productId}, Id Bina: {binId}", UserId = userId }; } @@ -109,7 +109,7 @@ public static class EventFactory { EventType = (int)EventType.Error, TimeStamp = DateTime.Now, - Message = $"Order with Code: {qrCode} not found.", + Message = $"Nalog sa kodom: {qrCode} nije pronaÄ‘en.", UserId = userId }; } @@ -125,7 +125,7 @@ public static class EventFactory EventType = (int)EventType.Print, TimeStamp = DateTime.Now, UserId = userId, - Message = $"Message {message} sent to printer {printerName}" + Message = $"Poruka {message} poslana Å¡tampaÄu {printerName}" }; } @@ -140,7 +140,7 @@ public static class EventFactory EventType = (int)EventType.Counter, TimeStamp = DateTime.Now, UserId = userId, - Message = $"Counter changed for Order Id: {binCounter.OrderId}, Product Id: {binCounter.ProductId}, BinId: {binCounter.BinId}. Current counter {counter}" + Message = $"BrojaÄ promenjen za Nalog : {binCounter.OrderId}, Proizvod Id: {binCounter.ProductId}, Bin Id: {binCounter.BinId}. Trenutni brojaÄ: {counter}" }; } @@ -155,7 +155,7 @@ public static class EventFactory EventType = (int)EventType.Counter, TimeStamp = DateTime.Now, UserId = userId, - Message = $"Bin Counter {binCounter.Counter} sent to ERP and status {status} received." + Message = $"BrojaÄ naloga {binCounter.OrderId} sa brojem {binCounter.Counter} poslat ERP-u sa statusom: {status}." }; } @@ -165,7 +165,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Generic product with Code: {response.ProductId} added.", + Message = $"Deklaracija za proizvod: {response.ProductName} dodata.", UserId = "Admin" }; } @@ -176,7 +176,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Generic product with Code: {update.ProductId} updated.", + Message = $"Deklaracija proizvoda : {update.ProductName} izmenjena.", UserId = "Admin" }; } @@ -187,7 +187,7 @@ public static class EventFactory { EventType = (int)EventType.Configuration, TimeStamp = DateTime.Now, - Message = $"Generic product with Code: {deleted.ProductId} deleted.", + Message = $"Deklaracija proizvoda : {deleted.ProductId} obrisana.", UserId = "Admin" }; } @@ -199,7 +199,7 @@ public static class EventFactory { EventType = (int)EventType.Print, TimeStamp = DateTime.Now, - Message = $"Printed transport box for {productName}. Lot {lot}, BinId {binId}, BoxId {requestBoxId}.", + Message = $"Postavljena poruka za transportnu kutiju za {productName}. Lot {lot}, Bin Id {binId}, Box Id {requestBoxId}.", UserId = requestUserId, PrinterId = printerId, OrderId = orderId, diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/DriverUserCase.cs b/Server/Enlight.Tts/Enlight.Tts.Core/DriverUserCase.cs index 44cf1a4d67afffe4dd0a5645a83bfca69a10cd15..7592dc7fc3d4e6c24c8f572af76f769b39039af6 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/DriverUserCase.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Core/DriverUserCase.cs @@ -174,6 +174,6 @@ public class DriverUserCase(IGenericProductUseCase genericProductUseCase) : IDri tb.ProductName, tb.NetoWeight, tb.BrutoWeight, - tb.LotNumber); + tb.LotNumber, tb.BoxBarCode); } } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/IoC/Config.cs b/Server/Enlight.Tts/Enlight.Tts.Core/IoC/Config.cs index e004b46dd3a89d7042091f1a380fca93f710c238..d0cb9b5eaa13845a1f6fe41d0f5da50dc6c1af20 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/IoC/Config.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Core/IoC/Config.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Configuration; +using System.Runtime.Serialization; +using Microsoft.Extensions.Configuration; namespace Enlight.Tts.Core.IoC; @@ -29,4 +30,9 @@ public class Config { return Configuration["AppSettings:" + key]; } + + public int GetSatoPrinterDPI() + { + return int.Parse(Configuration["SatoDPI"] ?? throw new InvalidDataContractException()); + } } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/PrinterUseCase.cs b/Server/Enlight.Tts/Enlight.Tts.Core/PrinterUseCase.cs index 9693ab42f95a2807b56557b7af51f5103c0a2fc1..cf099d2ff092e8f633db54dfdce81881208185b1 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/PrinterUseCase.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Core/PrinterUseCase.cs @@ -124,6 +124,7 @@ public class PrinterUseCase( if (driver is HitachiDriver d) { d.Connect(); + d.CallMessage(); d.Disconnect(); } @@ -132,6 +133,7 @@ public class PrinterUseCase( } catch (Exception e) { + throw new UnreachableException(e.Message); } diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/Util/PdfToImageConverter.cs b/Server/Enlight.Tts/Enlight.Tts.Core/Util/PdfToImageConverter.cs index 23fc7a367f90f0329b31a5a33158b92ed2e64829..202356f94395211ce1c9dc521641b3404c8d02c1 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/Util/PdfToImageConverter.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Core/Util/PdfToImageConverter.cs @@ -9,13 +9,15 @@ public class PdfToImageConverter { public PdfToImageConverter() { - var config = new Config(); - PdfRootPath = config.GetDeclarationsPath(); + PrinterConfig = new Config(); + PdfRootPath = PrinterConfig.GetDeclarationsPath(); if (!Directory.Exists(PdfRootPath)) Directory.CreateDirectory(PdfRootPath); } + private Config PrinterConfig { get; set; } + private string PdfRootPath { get; } public string PdfFileName(string productId, string countryId) @@ -36,7 +38,7 @@ public class PdfToImageConverter { for (int pageIndex = 0; pageIndex < document.PageCount; pageIndex++) { - using (var image = RenderPage(document, pageIndex)) + using (var image = RenderPage(document, pageIndex, PrinterConfig.GetSatoPrinterDPI())) { #pragma warning disable CA1416 image.Save(outputDir, ImageFormat.Jpeg); @@ -53,16 +55,12 @@ public class PdfToImageConverter } - private Image RenderPage(PdfDocument document, int pageIndex) + private Image RenderPage(PdfDocument document, int pageIndex, int dpi) { // Adjust the render DPI as needed to control the quality and size of the output image - // const int dpi = 300; - // var size = document.PageSizes[pageIndex]; - // var width = (int)(size.Width * dpi / 72); - // var height = (int)(size.Height * dpi / 72); - const int dpi = 300; - var width = 708; - var height = 685; + var size = document.PageSizes[pageIndex]; + var width = (int)(55 * dpi / 25.4); + var height = (int)(57 * dpi / 25.4); return document.Render(pageIndex, width, height, dpi, dpi, PdfRenderFlags.Annotations); } diff --git a/Server/Enlight.Tts/Enlight.Tts.Core/settings.json b/Server/Enlight.Tts/Enlight.Tts.Core/settings.json index a380d4b6dfe2975ddcc6a09b2753f30aab43774e..64f0318b55931a7ec66c8b6f20ea4dcd6f9f8659 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Core/settings.json +++ b/Server/Enlight.Tts/Enlight.Tts.Core/settings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { "DefaultConnection": "Server=10.0.6.103;Port=5432;Database=tts3;User Id=postgres;Password=ttsPak0m!@#;" - }, - "DeclarationsPath" : "D:/packom/declarations" + "DeclarationsPath" : "D:/packom/declarations", + "SatoDPI" : 600 } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/HitachiTestController.cs b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/HitachiTestController.cs new file mode 100644 index 0000000000000000000000000000000000000000..7abd39c9073fd4775f0a7a7cd822b35f9be0e27a --- /dev/null +++ b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/HitachiTestController.cs @@ -0,0 +1,35 @@ +using Enlight.Tts.Printer; +using Enlight.Tts.Printer.Implementation.IjHitachi; +using Microsoft.AspNetCore.Mvc; + +namespace Enlight.Tts.IntegrationService.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class HitachiTestController : ControllerBase +{ + public HitachiTestController() + { + + } + + [HttpGet("/getMessageCount/")] + public IActionResult GetMsgCount([FromQuery] string ipAddress, [FromQuery] int port) + { + try + { + var hd = new HitachiDriver + ("HitachiDriver", new PrinterConnectionParameters(ipAddress, port, 2)); + hd.Connect(); + var x = hd.GetMessageCount(); + hd.Disconnect(); + return Ok(x); + } + catch (Exception e) + { + return BadRequest(ApiResponseMsg.CreateInstance(e.Message, 33)); + } + } + + +} \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/ScanController.cs b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/ScanController.cs index ccd07dc081eb9f741c1366be3974ff048ca5986b..6bca07a76ede49d442dc32b7922b63c0bdd97010 100644 --- a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/ScanController.cs +++ b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/Controllers/ScanController.cs @@ -152,6 +152,7 @@ public class ScanController( { Lot = order.Lot, ExpDate = order.Exp_date, + ExpDateDays = order.ExpDateDays, ProductId = order.Product_Id, LicenceNumber = order.Licence_number, BinId = order.Bin_Id, diff --git a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/ErpDTOs.cs b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/ErpDTOs.cs index d4c7d68a397e122ab7d30fd94d928325cc3dc52c..1b8d6718532dcbdebd39e8887a97196d72301371 100644 --- a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/ErpDTOs.cs +++ b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/ErpDTOs.cs @@ -11,6 +11,8 @@ public string Bin_Id { get; set; }= string.Empty; public string Exp_date { get; set; }= string.Empty; public string Prod_date { get; set; }= string.Empty; + + public string ExpDateDays { get; set; } public string Lot { get; set; }= string.Empty; public string Licence_number { get; set; }= string.Empty; } diff --git a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/PakomOrderData.cs b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/PakomOrderData.cs index 9fe43cf6d00e26a6e0b4582b1b5bbb451df110ac..4b44227365915edb828c361d8b4451591c8bcaa1 100644 --- a/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/PakomOrderData.cs +++ b/Server/Enlight.Tts/Enlight.Tts.IntegrationService/ExternalServices/PakomOrderData.cs @@ -9,4 +9,5 @@ public class PakomOrderData public string ProdDate { get; set; }= String.Empty; public string Lot { get; set; }= String.Empty; public string LicenceNumber { get; set; }= String.Empty; + public string ExpDateDays { get; set; } } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Printer.Contracts/IVideoJetDriver.cs b/Server/Enlight.Tts/Enlight.Tts.Printer.Contracts/IVideoJetDriver.cs index 098fdf4f0c546e90f531e0d36a3dd045cbe64ff2..60246eadfac55245cf33e4f491d63d845996da6e 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Printer.Contracts/IVideoJetDriver.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Printer.Contracts/IVideoJetDriver.cs @@ -11,7 +11,7 @@ public interface IVideoJetDriver : IPrinterDriver string productName, decimal netoWeight, decimal brutoWeight, - string lotNumber); + string lotNumber, string barCode); ICollection<string> GetJobList(); ICollection<string> GetJobFields(string jobName); @@ -21,6 +21,6 @@ public interface IVideoJetDriver : IPrinterDriver string productName, decimal netoWeight, decimal brutoWeight, - string lotNumber); + string lotNumber, string barCode); string Execute(string command); } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Enlight.Tts.Printer.Implementation.csproj b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Enlight.Tts.Printer.Implementation.csproj index 287c962aaa66e34ecf4fb8972103f68030e1b55b..d57d36995023aae759611e3438aefe913ea12d13 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Enlight.Tts.Printer.Implementation.csproj +++ b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Enlight.Tts.Printer.Implementation.csproj @@ -8,16 +8,16 @@ <ItemGroup> <Reference Include="HitachiIJP"> - <HintPath>IjHitachi\Hitachi IJ Printer\HitachiIJP.dll</HintPath> + <HintPath>..\..\lib\HitachiIJP.dll</HintPath> </Reference> <Reference Include="MemLogger"> - <HintPath>IjHitachi\Hitachi IJ Printer\MemLogger.dll</HintPath> + <HintPath>..\..\lib\MemLogger.dll</HintPath> </Reference> <Reference Include="ModbusTcp"> - <HintPath>IjHitachi\Hitachi IJ Printer\ModbusTcp.dll</HintPath> + <HintPath>..\..\lib\ModbusTcp.dll</HintPath> </Reference> <Reference Include="SATOPrinterAPI"> - <HintPath>..\..\..\..\..\..\Program Files (x86)\SATO\SATO Printer API\Assembly\x64\SATOPrinterAPI.dll</HintPath> + <HintPath>..\..\lib\SATOPrinterAPI.dll</HintPath> </Reference> </ItemGroup> diff --git a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/IjHitachi/IjHitachiDriver.cs b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/IjHitachi/IjHitachiDriver.cs index d44ae3dd150cfdbbe46c1e2f2e895bd8c29d7002..20355f5a7445e0efaddf01721039919a006c2e36 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/IjHitachi/IjHitachiDriver.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/IjHitachi/IjHitachiDriver.cs @@ -5,7 +5,7 @@ using HIES.IJP.RX; namespace Enlight.Tts.Printer.Implementation.IjHitachi; -public class HitachiDriver : IHitachiDriver +public class HitachiDriver : IHitachiDriver, IDisposable { private readonly IJP _inkPrinter = new(); private readonly PrinterConnectionParameters _configuration; @@ -61,8 +61,8 @@ public class HitachiDriver : IHitachiDriver ActiveMessage.Items[0].Text = blisterPrint; //Exp. dd.mm.yyyy. AAAAAABBBCCC - if (ActiveMessage.CountConditions[0] != null) - ActiveMessage.CountConditions[0].Value = counter.ToString("D4"); + // if (ActiveMessage.CountConditions[0] != null) + // ActiveMessage.CountConditions[0].Value = counter.ToString("D4"); _inkPrinter.SetMessage(ActiveMessage); return blisterPrint; @@ -78,7 +78,9 @@ public class HitachiDriver : IHitachiDriver ActiveMessage.Items[0].Text = omotnicaPrint[0]; //PROD. DATE dd.mm.yyyy. ActiveMessage.Items[1].Text = omotnicaPrint[1]; //EXP.DATE dd.mm.yyyy. ActiveMessage.Items[2].Text = omotnicaPrint[2]; //LOT NO.: XXXXXX/BBB-CCC - ActiveMessage.Items[3].Text = omotnicaPrint[3]; //ABCDEFGH... + + if(omotnicaPrint[3] != "-" && !string.IsNullOrEmpty(omotnicaPrint[3])) + ActiveMessage.Items[3].Text = omotnicaPrint[3]; //ABCDEFGH... if (ActiveMessage.CountConditions[0] != null) ActiveMessage.CountConditions[0].Value = counter.ToString("D4"); @@ -101,7 +103,9 @@ public class HitachiDriver : IHitachiDriver ActiveMessage.Items[0].Text = shelfPrint[0]; //PROD. DATE dd.mm.yyyy. ActiveMessage.Items[1].Text = shelfPrint[1]; //EXP.DATE dd.mm.yyyy. ActiveMessage.Items[2].Text = shelfPrint[2]; //LOT NO.: XXXXXX/BBB-CCC - ActiveMessage.Items[3].Text = shelfPrint[3]; //ABCDEFGH... + + if(shelfPrint[3] != "-" && !string.IsNullOrEmpty(shelfPrint[3])) + ActiveMessage.Items[3].Text = shelfPrint[3]; //ABCDEFGH... ActiveMessage.Items[4].Text = shelfPrint[4]; // ActiveMessage.Items[5].Text = shelfPrint[5]; // @@ -176,10 +180,23 @@ public class HitachiDriver : IHitachiDriver _inkPrinter.Retry = (ushort)_configuration.Retry; _inkPrinter.Connect(); + var status = (IJPStatus)_inkPrinter.GetStatus(); + if (status.CommunicationConnection.ToString().Equals("Offline")) + { + _inkPrinter.SetComPort(IJPOnlineStatus.Online); + } + + } public void Disconnect() { _inkPrinter.Disconnect(); } + + public void Dispose() + { + _inkPrinter.Disconnect(); + _inkPrinter.Dispose(); + } } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Sato/SatoDriver.cs b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Sato/SatoDriver.cs index b62e56c8f04983158308627341374a77f929e3f0..74c18373cf33ce8ee565dd2448ed4badc1dc35e0 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Sato/SatoDriver.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/Sato/SatoDriver.cs @@ -3,7 +3,7 @@ using SATOPrinterAPI; namespace Enlight.Tts.Printer.Implementation.Sato; -public class SatoDriver : ISatoDriver +public class SatoDriver : ISatoDriver, IDisposable { private readonly SATOPrinterAPI.Printer _printer; public PrinterConnectionParameters Conf { get; } @@ -16,8 +16,8 @@ public class SatoDriver : ISatoDriver _printer = new SATOPrinterAPI.Printer(); _printer.PermanentConnect = false; _printer.Interface = SATOPrinterAPI.Printer.InterfaceType.TCPIP; - _printer.TCPIPAddress = "10.0.4.171"; - _printer.TCPIPPort = "9100"; + _printer.TCPIPAddress = conf.IpAddress; + _printer.TCPIPPort = conf.Port.ToString(); } public string Name { get; set; } @@ -37,7 +37,7 @@ public class SatoDriver : ISatoDriver if (ps.IsError || ps.IsOnline == false || _printer.IsBusy) throw new InvalidOperationException("Wrong communication with printer"); - var pattern2 = "\u001bA\u001bH0100\u001bV0001$$$\u001bQ###\u001bZ"; + var pattern2 = "\u001bA\u001bH0116\u001bV0017$$$\u001bQ###\u001bZ"; pattern2 = pattern2.Replace("###", quantity.ToString()); string graphicCommands = Utils.ConvertGraphicToSBPL(file); @@ -45,4 +45,9 @@ public class SatoDriver : ISatoDriver _printer.Send(Utils.StringToByteArray(pattern2)); } + + public void Dispose() + { + _printer.Disconnect(); + } } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/VideoJet/VideoJetDriver.cs b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/VideoJet/VideoJetDriver.cs index 4ceb59a0b03947b35dea09078bd6ef19965c4a97..76b50fa9800f7e345e44eaa927629eaf6aa58db1 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/VideoJet/VideoJetDriver.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Printer.Implementation/VideoJet/VideoJetDriver.cs @@ -1,4 +1,5 @@ using System.Net.Sockets; +using System.Runtime.InteropServices.ComTypes; using System.Text; using Enlight.Tts.Printer.Contracts; @@ -26,11 +27,11 @@ public class VideoJetDriver(string name, PrinterConnectionParameters pars) : IVi string productName, decimal netoWeight, decimal brutoWeight, - string lotNumber) + string lotNumber, string barCode) { var fields = GetJobFields(jobName); var command = CreateSetJobCommand(jobName, fields, expDate, prodDate, quantity, productName, netoWeight, - brutoWeight, lotNumber); + brutoWeight, lotNumber, barCode); // select job command var selectCommand = "SEL|" + jobName + "|"; @@ -98,7 +99,7 @@ public class VideoJetDriver(string name, PrinterConnectionParameters pars) : IVi string productName, decimal netoWeight, decimal brutoWeight, - string lotNumber) + string lotNumber, string barCode) { var sb = new StringBuilder(); sb.Append($"SLA|{jobName}|"); @@ -128,6 +129,9 @@ public class VideoJetDriver(string name, PrinterConnectionParameters pars) : IVi case "Lot": sb.Append($"{f}={lotNumber}|"); break; + case "BarCode": + sb.Append($"{f}={barCode}|"); + break; default: break; } diff --git a/Server/Enlight.Tts/Enlight.Tts.Tests/Enlight.Tts.Tests.csproj b/Server/Enlight.Tts/Enlight.Tts.Tests/Enlight.Tts.Tests.csproj index 47112fbe9032768fb9f8faea67c2020b1355367f..8541f5f59ac61bdaf67bc9502f83e402b87966a4 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Tests/Enlight.Tts.Tests.csproj +++ b/Server/Enlight.Tts/Enlight.Tts.Tests/Enlight.Tts.Tests.csproj @@ -31,7 +31,7 @@ <ItemGroup> <Reference Include="SATOPrinterAPI"> - <HintPath>..\..\..\..\..\..\Program Files (x86)\SATO\SATO Printer API\Assembly\x64\SATOPrinterAPI.dll</HintPath> + <HintPath>..\..\lib\SATOPrinterAPI.dll</HintPath> </Reference> </ItemGroup> diff --git a/Server/Enlight.Tts/Enlight.Tts.Tests/HitachiTest.cs b/Server/Enlight.Tts/Enlight.Tts.Tests/HitachiTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..82e66e4d37cd547023206aa3a5ced3d8c9f1e098 --- /dev/null +++ b/Server/Enlight.Tts/Enlight.Tts.Tests/HitachiTest.cs @@ -0,0 +1,19 @@ +using Enlight.Tts.Printer; +using Enlight.Tts.Printer.Implementation.IjHitachi; + +namespace Enlight.Tts.Tests; + +public class HitachiTest +{ + [Fact] + public void Hitachi_Connect() + { + var hd = new HitachiDriver + ("HitachiDriver", new PrinterConnectionParameters("192.168.1.27", 502, 2)); + hd.Connect(); + var x = hd.GetMessageCount(); + Assert.NotNull(x); + hd.Disconnect(); + + } +} \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Tests/SatoPrinterTests.cs b/Server/Enlight.Tts/Enlight.Tts.Tests/SatoPrinterTests.cs index 1c24ce23d63a9ac05911a54966ee190a718c06bb..73a9ab505d745bda41928f9167b549c1e3cbd426 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Tests/SatoPrinterTests.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Tests/SatoPrinterTests.cs @@ -1,12 +1,16 @@ using System.Drawing; using System.Drawing.Imaging; +using System.Net.Sockets; using System.Text; +using Enlight.Tts.Core; +using Enlight.Tts.Core.Util; using PdfiumViewer; namespace Enlight.Tts.Tests; using SATOPrinterAPI; + public class SatoPrinterTests { [Fact] @@ -23,7 +27,7 @@ public class SatoPrinterTests Assert.True(printer.GetPrinterStatus().IsOnline); Assert.False(printer.GetPrinterStatus().IsError); var ps = printer.GetPrinterStatus(); - + var pattern2 = "\u001bA\u001bH0100\u001bV0100$$$\u001bQ1\u001bZ"; string graphicCommands = Utils.ConvertGraphicToSBPL(@"D:/Enlight_Sato.jpg"); @@ -37,10 +41,10 @@ public class SatoPrinterTests public void Sato_printer_FromPDF_Test() { var pdfPath = @"D:\packom\ALB sticker Ananas 60x58 v2.pdf"; - + var outputDir = @"D:\packom"; ConvertPdfToImages(pdfPath, "ananas", outputDir); - + var printer = new Printer(); printer.PermanentConnect = false; printer.Interface = Printer.InterfaceType.TCPIP; @@ -52,7 +56,7 @@ public class SatoPrinterTests Assert.True(printer.GetPrinterStatus().IsOnline); Assert.False(printer.GetPrinterStatus().IsError); var ps = printer.GetPrinterStatus(); - + var pattern2 = "\u001bA\u001bH0100\u001bV001$$$\u001bQ1\u001bZ"; string graphicCommands = Utils.ConvertGraphicToSBPL(@"D:\packom\ananas.jpg"); @@ -60,7 +64,6 @@ public class SatoPrinterTests printer.Send(Utils.StringToByteArray(pattern2)); //printer.TestPrint(true); printer.Disconnect(); - } [Fact] @@ -100,5 +103,33 @@ public class SatoPrinterTests return document.Render(pageIndex, width, height, dpi, dpi, PdfRenderFlags.Annotations); } - + + [Fact] + public async void Sato_TcpIp_Test() + { + var tcpIpClient = new TcpClient(); + await tcpIpClient.ConnectAsync("192.168.1.221", 9100); + var stream = tcpIpClient.GetStream(); + + string command = "Tvoj SATO print command"; // Prilagodi komandu + byte[] data = Encoding.ASCII.GetBytes(command); + + await stream.WriteAsync(data, 0, data.Length); + + tcpIpClient.Close(); + stream.Close(); + } + + [Theory] + [InlineData(55, 57,111)] + public void PdfRenderImage_Test(int width, int height, int testOrderId) + { + var pdfConverter = new PdfToImageConverter(); + var sourceDir = @"D:\TestData\ALB Ananas 60x58 v2.pdf"; + var destDir = @"D:\TestData\SatoImages\Sato_" + testOrderId + ".jpg"; + + pdfConverter.ConvertPdfToImages(sourceDir, destDir); + } + + } \ No newline at end of file diff --git a/Server/Enlight.Tts/Enlight.Tts.Tests/VideoJetTests.cs b/Server/Enlight.Tts/Enlight.Tts.Tests/VideoJetTests.cs index 0b39b5e5541ae6c1e2d91e568759c2a95963ee6c..ad4cbc116d893f7bcd946ee3b2cb87463904b382 100644 --- a/Server/Enlight.Tts/Enlight.Tts.Tests/VideoJetTests.cs +++ b/Server/Enlight.Tts/Enlight.Tts.Tests/VideoJetTests.cs @@ -27,6 +27,6 @@ public class VideoJetTests "Malina Test", 110.22m, 133.33m, - "LOT1234"); + "LOT1234", "1111"); } } \ No newline at end of file diff --git a/Server/lib/HitachiIJP.dll b/Server/lib/HitachiIJP.dll new file mode 100644 index 0000000000000000000000000000000000000000..20700d7969c04aab162c192dcb3655c0b06ec4a8 Binary files /dev/null and b/Server/lib/HitachiIJP.dll differ diff --git a/Server/lib/MemLogger.dll b/Server/lib/MemLogger.dll new file mode 100644 index 0000000000000000000000000000000000000000..881734e687b837caca781099d4fffa76e93f0e29 Binary files /dev/null and b/Server/lib/MemLogger.dll differ diff --git a/Server/lib/ModbusTcp.dll b/Server/lib/ModbusTcp.dll new file mode 100644 index 0000000000000000000000000000000000000000..01abea3751c8f4b3efd0de1851bce25b8a437a03 Binary files /dev/null and b/Server/lib/ModbusTcp.dll differ diff --git a/Server/lib/SATOPrinterAPI.dll b/Server/lib/SATOPrinterAPI.dll new file mode 100644 index 0000000000000000000000000000000000000000..b367a836196dfd9f876b2e10eef512c796417fe8 Binary files /dev/null and b/Server/lib/SATOPrinterAPI.dll differ