private void PrintMUBLabel(PrinterMonitor printerMonitor, LabelInfo labelInfo) { BarcodePrinterUtil barcodeScannerUtils = BarcodePrinterUtil.Instance; // Check status of Barcode printer //MessageBox.Show(EnumDeviceNames.MUBLabelPrinter); EnumDeviceStatus[] mubLabelPrinterStatuses = barcodeScannerUtils.GetDeviceStatus(EnumDeviceNames.MUBLabelPrinter); if (mubLabelPrinterStatuses.Contains(EnumDeviceStatus.Connected)) { printerMonitor.PrintMUBLabel(labelInfo); } else { // Printer disconnect, get list status of the causes disconnected string causeOfPrintMUBFailure = string.Empty; foreach (var item in mubLabelPrinterStatuses) { causeOfPrintMUBFailure = causeOfPrintMUBFailure + CommonUtil.GetDeviceStatusText(item) + "; "; } labelInfo.PrintStatus = EnumPrintStatus.Failed; labelInfo.Message = causeOfPrintMUBFailure; RaisePrintMUBLabelsFailedEvent(new Trinity.Common.PrintMUBAndTTLabelsEventArgs(labelInfo)); } }
internal void Start(LabelInfo labelInfo) { try { Lib.LayerWeb.SetLoading(false); System.Threading.Thread.Sleep(200); PrinterMonitor printerMonitor = PrinterMonitor.Instance; printerMonitor.OnPrintMUBLabelSucceeded += OnPrintMUBLabelsSucceeded; printerMonitor.OnPrintTTLabelSucceeded += OnPrintTTLabelsSucceeded;//RaisePrintMUBAndTTLabelsSucceededEvent; printerMonitor.OnMonitorException += OnPrintMUBAndTTLabelsException; Session session = Session.Instance; if (session.IsAuthenticated) { List <Task> tasks = new List <Task>(); tasks.Add(Task.Run(() => { PrintMUBLabel(printerMonitor, labelInfo); })); //System.Threading.Thread.Sleep(1000); tasks.Add(Task.Run(() => { PrintTTLabel(printerMonitor, labelInfo); })); Task.WaitAll(tasks.ToArray()); _jsCallCs.OnPrintingAndLabellingCompleted(); } } catch (Exception ex) { RaisePrintMUBAndTTLabelsExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.UnknownError, ErrorMessage = ex.Message })); } }
internal void StartPrintTT(LabelInfo labelInfo) { try { _web.SetLoading(false); this._web.LoadPageHtml("MUBAndTTLabel.html"); //this._web.RunScript("$('.status-text').css('color','#000').text('Please wait');"); //System.Threading.Thread.Sleep(1000); PrinterMonitor printerMonitor = PrinterMonitor.Instance; printerMonitor.OnPrintTTLabelSucceeded += OnPrintTTLabelsSucceeded; printerMonitor.OnMonitorException += OnPrintMUBAndTTLabelsException; BarcodePrinterUtil barcodeScannerUtils = BarcodePrinterUtil.Instance; Session session = Session.Instance; if (session.IsAuthenticated) { #region Print TTLabel // Check status of Barcode printer string ttLabelPrinterName = ConfigurationManager.AppSettings["TTLabelPrinterName"]; var ttLabelPrinterStatus = barcodeScannerUtils.GetDeviceStatus(ttLabelPrinterName); if (ttLabelPrinterStatus.Contains(EnumDeviceStatus.Connected)) { printerMonitor.PrintTTLabel(labelInfo); } else { // Printer disconnect, get list status of the causes disconnected string causeOfPrintFailure = ""; foreach (var item in ttLabelPrinterStatus) { causeOfPrintFailure = causeOfPrintFailure + CommonUtil.GetDeviceStatusText(item) + "; "; } RaisePrintTTLabelsFailedEvent(new PrintMUBAndTTLabelsEventArgs("TTLabel Printer have problem: " + causeOfPrintFailure)); return; } #endregion } } catch (Exception ex) { RaisePrintMUBAndTTLabelsExceptionEvent(new ExceptionArgs(new FailedInfo() { ErrorCode = (int)EnumErrorCodes.UnknownError, ErrorMessage = new ErrorInfo().GetErrorMessage(EnumErrorCodes.UnknownError) })); } }
/// <summary> /// Configures runtime services for the application /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { var printerStatus = new PrinterStatus(); var actorSystem = ActorSystem.Create("Printer"); var monitor = actorSystem.ActorOf(PrinterMonitor.Props(printerStatus), "printer-monitor"); var printer = actorSystem.ActorOf(PrinterDevice.Props(monitor), "printer"); services.AddSingleton(printerStatus); services.AddSingleton <IPrinterService>(new PrinterService(printer)); services.AddServerSideBlazor().AddHubOptions(options => { // Allow uploads up to 30MB options.MaximumReceiveMessageSize = 1024 * 1024 * 30; }); services.AddRazorPages(); services.AddFileReaderService(options => { options.InitializeOnFirstCall = true; }); }