Пример #1
0
        void Handle_Clicked(object sender, System.EventArgs e)
        {
            IConnection connection = null;

            try
            {
                connection = App.myPrinter.Connection;
                connection.Open();
                if (!CheckPrinterLanguage(connection))
                {
                    //ResetPage();
                    return;
                }
                IZebraPrinter  printer = ZebraPrinterFactory.Current.GetInstance(connection);
                IPrinterStatus status  = printer.CurrentStatus;
                ShowStatus(status);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception:" + ex.Message);
                ShowErrorAlert(ex.Message);
            }
            finally
            {
                if ((connection != null) && (connection.IsConnected))
                {
                    connection.Close();
                }
            }
        }
        private void GetPrinterStatus()
        {
            //CheckPrinter();
            IConnection connection = null;

            try
            {
                connection = myPrinter.Connection;
                connection.Open();
                if (!CheckPrinterLanguage(connection))
                {
                    resetPage();
                    return;
                }
                IZebraPrinter  printer = ZebraPrinterFactory.Current.GetInstance(connection);
                IPrinterStatus status  = printer.CurrentStatus;
                ShowStatus(status);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception:" + e.Message);
                ShowErrorAlert(e.Message);
            }
            finally
            {
                if ((connection != null) && (connection.IsConnected))
                {
                    connection.Close();
                }
                resetPage();
            }
        }
Пример #3
0
        private bool CheckPrinterStatus(IConnection conn)
        {
            IZebraPrinter  printer = ZebraPrinterFactory.Current.GetInstance(PrinterLanguage.ZPL, conn);
            IPrinterStatus status  = printer.CurrentStatus;

            if (!status.IsReadyToPrint)
            {
                Debug.WriteLine("Printer in Error: " + status.ToString());
            }
            return(true);
        }
Пример #4
0
        protected void PrePrintCheckStatus()
        {
            // Check the printer status
            IPrinterStatus status = _prn.CurrentStatus;

            if (!status.IsReadyToPrint)
            {
                Debug.WriteLine("Unable to print. Printer is " + status.Status);
                throw new ZebraExceptions(ZebraExceptions.MsgUnableToPrint + " " + status.Status, ZebraExceptions.ErrUnableToPrint);
            }
        }
Пример #5
0
        private bool CheckPrinterStatus(IConnection connection)
        {
            IZebraPrinter  printer = ZebraPrinterFactory.Current.GetInstance(PrinterLanguage.ZPL, connection);
            IPrinterStatus status  = printer.CurrentStatus;

            if (!status.IsReadyToPrint)
            {
                Log.Information("Printer in Error: " + status);
            }
            return(true);
        }
Пример #6
0
        protected bool PreCheckPrinterStatus(IZebraPrinter printer)
        {
            // Check the printer status
            IPrinterStatus status = printer.CurrentStatus;

            if (!status.IsReadyToPrint)
            {
                ShowErrorAlert("Unable to print. Printer is " + status.Status);
                return(false);
            }
            return(true);
        }
        public bool PreCheckPrinterStatus(IZebraPrinter printer)
        {
            // Check the printer status
            IPrinterStatus status = printer.CurrentStatus;

            if (!status.IsReadyToPrint)
            {
                Application.Current.MainPage.DisplayAlert("Unable to print. Printer is " + status.Status, "test", "test");
                return(false);
            }
            return(true);
        }
        private void ShowStatus(IPrinterStatus status) {
            Device.BeginInvokeOnMainThread(() => {
                if (status.IsReadyToPrint) {

                    printerStatusLbl.Text = "Printer Status: Printer Ready";
                    printerStatusLbl.TextColor = Color.Green;
                    causesLbl.Text = "";
                } else {
                    printerStatusLbl.Text = "Printer Status: Printer Error";
                    printerStatusLbl.TextColor = Color.Red;
                    causesLbl.Text = status.Status;
                }
            });
        }
Пример #9
0
 private void ShowStatus(IPrinterStatus status)
 {
     Device.BeginInvokeOnMainThread(() => {
         if (status.IsReadyToPrint)
         {
             // checkStatus.Text = "Printer Status: Printer Ready";
             //checkStatus.TextColor = Color.Green;
         }
         else
         {
             //checkStatus.Text = "Printer Status: Printer Error";
             // checkStatus.TextColor = Color.Red;
         }
     });
 }
Пример #10
0
        //Check what happens to the printer after print command was sent
        protected void PostPrintCheckStatus()
        {
            // Check the status again to verify print happened successfully
            IPrinterStatus status = _prn.CurrentStatus;

            // Wait while the printer is printing
            while ((status.NumberOfFormatsInReceiveBuffer > 0) && (status.IsReadyToPrint))
            {
                status = _prn.CurrentStatus;
            }
            // verify the print didn't have errors like running out of paper
            if (!status.IsReadyToPrint)
            {
                Debug.WriteLine("Error durring print. Printer is " + status.Status);
                throw new ZebraExceptions(ZebraExceptions.MsgDuringPrint + " " + status.Status, ZebraExceptions.ErrDuringPrint);
            }
        }
Пример #11
0
        public void GetDeviceStatusAction(Communication.Result result, IPrinterStatus printerStatus)
        {
            if (result == Communication.Result.Success)
            {
                this.listViewItemCollection.Add(new ListViewItem("Online", printerStatus.Offline,   new string[] {"Offline", "Online"}, new Color[] {Color.Red, Color.Blue}));
                this.listViewItemCollection.Add(new ListViewItem("Cover",  printerStatus.CoverOpen, new string[] {"Open",    "Closed"}, new Color[] {Color.Red, Color.Blue}));

                if (printerStatus.ReceiptPaperEmpty)
                {
                    this.listViewItemCollection.Add(new ListViewItem("Paper", "Empty",      Color.Red));
                }
                else if (printerStatus.ReceiptPaperNearEmptyInner ||
                         printerStatus.ReceiptPaperNearEmptyOuter)
                {
                    this.listViewItemCollection.Add(new ListViewItem("Paper", "Near Empty", Color.Orange));
                }
                else
                {
                    this.listViewItemCollection.Add(new ListViewItem("Paper", "Ready",      Color.Blue));
                }

                if (Configuration.CashDrawerOpenActiveHigh)
                {
                    this.listViewItemCollection.Add(new ListViewItem("Cash Drawer",   printerStatus.CompulsionSwitch, new string[] {"Open", "Closed"}, new Color[] {Color.Red, Color.Blue}));
                }
                else
                {
                    this.listViewItemCollection.Add(new ListViewItem("Cash Drawer", ! printerStatus.CompulsionSwitch, new string[] {"Open", "Closed"}, new Color[] {Color.Red, Color.Blue}));
                }

                this.listViewItemCollection.Add(new ListViewItem("Head Temperature",      printerStatus.OverTemp,            new string[] {"High",   "Normal"}, new Color[] {Color.Red, Color.Blue}));
                this.listViewItemCollection.Add(new ListViewItem("Non Recoverable Error", printerStatus.UnrecoverableError,  new string[] {"Occurs", "Ready"},  new Color[] {Color.Red, Color.Blue}));
                this.listViewItemCollection.Add(new ListViewItem("Paper Cutter",          printerStatus.CutterError,         new string[] {"Error",  "Ready"},  new Color[] {Color.Red, Color.Blue}));
                this.listViewItemCollection.Add(new ListViewItem("Head Thermistor",       printerStatus.HeadThermistorError, new string[] {"Error",  "Normal"}, new Color[] {Color.Red, Color.Blue}));
                this.listViewItemCollection.Add(new ListViewItem("Voltage",               printerStatus.VoltageError,        new string[] {"Error",  "Normal"}, new Color[] {Color.Red, Color.Blue}));
            }
            else
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    DisplayAlert(result.ToString(), null, "OK");
                });
            }

            this.contentPageComponent.UserInteractionEnabled = true;
        }
Пример #12
0
        protected bool PostPrintCheckStatus(IZebraPrinter printer)
        {
            // Check the status again to verify print happened successfully
            IPrinterStatus status = printer.CurrentStatus;

            // Wait while the printer is printing
            while ((status.NumberOfFormatsInReceiveBuffer > 0) && (status.IsReadyToPrint))
            {
                status = printer.CurrentStatus;
            }
            // verify the print didn't have errors like running out of paper
            if (!status.IsReadyToPrint)
            {
                ShowErrorAlert("Error durring print. Printer is " + status.Status);
                return(false);
            }
            return(true);
        }
Пример #13
0
        public static void GetDeviceStatus(string portName, string portSettings, int timeout, Action <Result, IPrinterStatus> action)
        {
            Task task = new Task(() =>
            {
                Result result = Result.UnknownError;

                IPort port = null;

                IPrinterStatus printerStatus = null;

                try
                {
                    result = Result.GetPortError;

                    port = Port.GetPort(portName, portSettings, timeout);

                    result = Result.GetParsedStatusError;

                    printerStatus = port.GetParsedStatus();

                    result = Result.Success;
                }
                catch (Exception exception)
                {
                    DebugExt.WriteLine(exception.Message);
                }
                finally
                {
                    if (port != null)
                    {
                        Port.ReleasePort(port);

                        port = null;
                    }
                }

                Device.BeginInvokeOnMainThread(() => {
                    action(result, printerStatus);
                });
            });

            task.Start();
        }