Exemple #1
0
        private async Task WriteToOPOSLineDisplay(string oposText1, string oposText2)
        {
            if (oposText1 != null || oposText2 != null)
            {
                try
                {
                    using (var lineDisplay = new OPOSLineDisplay(CacheBusinessLogic.CustomerDisplayName))
                    {
                        lineDisplay.Clear();
                        lineDisplay.DisplayTextAt(0, 0, oposText1);
                        await Task.Delay(50);

                        lineDisplay.DisplayTextAt(1, 0, oposText2);
                    }
                }
                catch (LineDisplayException ex)
                {
                    Log.Warn(ex);
                    if (DisplayCustomerDisplayMessage)
                    {
                        DisplayCustomerDisplayMessage = false;
                        ShowNotification(ApplicationConstants.NoCustomerDisplayFound, null, null, ApplicationConstants.ButtonWarningColor);
                    }
                }
                catch (Exception ex)
                {
                    Log.Info(Message, ex);
                    if (DisplayCustomerDisplayMessage)
                    {
                        DisplayCustomerDisplayMessage = false;
                        ShowNotification(ApplicationConstants.SomethingBadHappned, null, null, ApplicationConstants.ButtonWarningColor);
                    }
                }
            }
        }
            /// <summary>
            /// Establishes a connection to the specified line display.
            /// </summary>
            /// <param name="peripheralName">Name of scale device to open.</param>
            /// <param name="characterSet">The character set.</param>
            /// <param name="binaryConversion">If set to <c>true</c> [binary conversion].</param>
            /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param>
            public void Open(string peripheralName, int characterSet, bool binaryConversion, PeripheralConfiguration peripheralConfig)
            {
                this.oposLineDisplayWorker = new WorkerThread <IOPOSLineDisplay>(() =>
                {
                    IOPOSLineDisplay oposLineDisplay = new OPOSLineDisplay();

                    // Open
                    oposLineDisplay.Open(peripheralName);
                    OposHelper.CheckResultCode(this, oposLineDisplay.ResultCode);

                    // Claim
                    oposLineDisplay.ClaimDevice(OposHelper.ClaimTimeOut);
                    OposHelper.CheckResultCode(this, oposLineDisplay.ResultCode);

                    // Enable/Configure
                    oposLineDisplay.DeviceEnabled = true;
                    binaryConversionEnabled       = binaryConversion;

                    if (characterSet != 0)
                    {
                        // If character set is not supported by device, then disable and error out.
                        if (!oposLineDisplay.CharacterSetList.Split(CharacterSetListSeparator).Any(p => p.Equals(characterSet.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)))
                        {
                            oposLineDisplay.ReleaseDevice();
                            oposLineDisplay.Close();

                            throw new PeripheralException(PeripheralException.LineDisplayCharacterSetNotSupported);
                        }

                        oposLineDisplay.CharacterSet = characterSet;
                    }

                    this.numberOfColumns = oposLineDisplay.Columns;

                    return(oposLineDisplay);
                });
            }
Exemple #3
0
        private void btnLineDisplay_Click(object sender, EventArgs e)
        {
            OPOSLineDisplay ld  = new OPOSLineDisplay();
            int             nRC = ld.Open("DefaultPOSLineDisplay");

            if (nRC == (int)OPOS_Constants.OPOS_SUCCESS)
            {
                nRC = ld.ClaimDevice(5000);
                if (nRC == (int)OPOS_Constants.OPOS_SUCCESS)
                {
                    ld.DeviceEnabled = true;

                    ld.DisplayTextAt(0, 0, "WELCOME To W-MALL",
                                     (int)POS.Devices.OPOSLineDisplayConstants.DISP_DT_NORMAL);

                    ld.DisplayTextAt(1, 0, "TOTAL" + "30,000".PadLeft(26 - "TOTAL".Length - 6, ' '),
                                     (int)POS.Devices.OPOSLineDisplayConstants.DISP_DT_NORMAL);

                    ld.DeviceEnabled = false;
                    ld.ReleaseDevice();
                    ld.Close();
                }
            }
        }
Exemple #4
0
        protected Task <bool> VerifyPeripheralsConnected()
        {
            Action printerError     = default(Action);
            Action cashDrawerError  = default(Action);
            Action lineDisplayError = default(Action);

            printerError = new Action(async() =>
            {
                if (CacheBusinessLogic.UseReceiptPrinter && CacheBusinessLogic.UseOposReceiptPrinter)
                {
                    if (OposPrinter == null)
                    {
                        ClaimOposPrinter();
                    }
                    if (OposPrinter != null && OposPrinter.IsAvailable())
                    {
                        cashDrawerError();
                    }
                    else
                    {
                        ShowNotification(ApplicationConstants.NoPrinterFound, cashDrawerError, cashDrawerError, ApplicationConstants.ButtonWarningColor);
                    }
                }
                else
                {
                    ClaimOposPrinter();
                    cashDrawerError();
                }
            });

            cashDrawerError = new Action(async() =>
            {
                if (CacheBusinessLogic.UseCashDrawer && CacheBusinessLogic.UseOposCashDrawer)
                {
                    try
                    {
                        using (var cashDrawer = new OPOSCashDrawer(CacheBusinessLogic.CashDrawerName))
                        {
                        }
                        lineDisplayError();
                    }
                    catch (CashDrawerException ex)
                    {
                        ShowNotification(ApplicationConstants.NoCashDrawerFound, lineDisplayError, lineDisplayError
                                         , ApplicationConstants.ButtonWarningColor);
                    }
                }
                else
                {
                    lineDisplayError();
                }
            });

            lineDisplayError = new Action(async() =>
            {
                if (CacheBusinessLogic.UseCustomerDisplay && CacheBusinessLogic.UseOposCustomerDisplay)
                {
                    try
                    {
                        using (var lineDisplay = new OPOSLineDisplay(CacheBusinessLogic.CustomerDisplayName))
                        {
                        }
                    }
                    catch (LineDisplayException ex)
                    {
                        Log.Warn(ex);
                        DisplayCustomerDisplayMessage = false;
                        ShowNotification(ApplicationConstants.NoCustomerDisplayFound, null, null, ApplicationConstants.ButtonWarningColor);
                    }
                    catch (Exception ex)
                    {
                        Log.Info(Message, ex);
                        DisplayCustomerDisplayMessage = false;
                        ShowNotification(ApplicationConstants.SomethingBadHappned, null, null, ApplicationConstants.ButtonWarningColor);
                    }
                }
            });

            printerError();
            return(Task.FromResult <bool>(true));
        }
Exemple #5
0
 public POSLineDisplay()
 {
     m_device = new OPOSLineDisplay();
 }