Пример #1
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException"></exception>
        public void Load()
        {
            if (this.deviceType == DeviceTypes.None)
            {
                return;
            }

            if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled())
            {
                FiscalPrinter.FiscalPrinter.Instance.Load();
                return;
            }

            if (this.deviceType == DeviceTypes.OPOS)
            {
                NetTracer.Information("Peripheral [CashDrawer] - OPOS device loading: {0}", this.DeviceName ?? "<Undefined>");

                oposPrinter = new OPOSPOSPrinterClass();

                // Open
                oposPrinter.Open(this.DeviceName);
                Peripherals.CheckResultCode(this, oposPrinter.ResultCode);

                // Claim
                oposPrinter.ClaimDevice(Peripherals.ClaimTimeOut);
                Peripherals.CheckResultCode(this, oposPrinter.ResultCode);

                // Enable/Configure
                oposPrinter.DeviceEnabled = true;
                oposPrinter.AsyncMode     = false;
                oposPrinter.CharacterSet  = characterSet;
                oposPrinter.RecLineChars  = 56;
                oposPrinter.SlpLineChars  = 60;

                // Loading a bitmap for the printer
                string logoFile = Path.Combine(ApplicationSettings.GetAppPath(), "RetailPOSLogo.bmp");

                if (File.Exists(logoFile))
                {
                    NetTracer.Information("Peripheral [Printer] - OPOS printer bitmap load");
                    oposPrinter.SetBitmap(1, (int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, logoFile, 500, (int)OPOSPOSPrinterConstants.PTR_BM_CENTER);
                }
            }

            IsActive = true;
        }
Пример #2
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException"></exception>
        /// <exception cref="NotSupportedException"></exception>
        public void Load()
        {
            NotificationCenter = NotificationProxy.GetNotificationCenter();

            if (LSRetailPosis.Settings.HardwareProfiles.LineDisplay.DeviceType != DeviceTypes.OPOS)
            {
                return;
            }

            NetTracer.Information("Peripheral [LineDisplay] - OPOS device loading: {0}", DeviceName ?? "<Undefined>");

            // If character set is not supported by OS, then error out.
            if (!Encoding.GetEncodings().Any(p => p.CodePage == characterSet))
            {
                throw new NotSupportedException(string.Format("Peripheral [LineDisplay] - Character set '{0}' is not supported by Windows OS", characterSet));
            }

            oposLineDisplay = new OPOSLineDisplayClass();

            //Open
            oposLineDisplay.Open(DeviceName);
            Peripherals.CheckResultCode(this, oposLineDisplay.ResultCode);

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

            // Enable/Configure
            oposLineDisplay.DeviceEnabled = true;

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

                throw new NotSupportedException(string.Format("Peripheral [LineDisplay] - Character set '{0}' is not supported by device.", characterSet));
            }

            oposLineDisplay.CharacterSet = characterSet;
            IsActive = true;
        }
Пример #3
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException">Cannot load device</exception>
        public void Load()
        {
            if (Keylock.DeviceType != DeviceTypes.OPOS)
            {
                return;
            }

            NetTracer.Information("Peripheral [Keylock] - OPOS device loading: {0}", DeviceName ?? "<Undefined>");

            oposKeylock = new OPOSKeylockClass();

            //Open
            oposKeylock.Open(DeviceName);
            Peripherals.CheckResultCode(this, oposKeylock.ResultCode);

            //Enable
            oposKeylock.StatusUpdateEvent += new _IOPOSKeylockEvents_StatusUpdateEventEventHandler(posKeylock_StatusUpdateEvent);
            oposKeylock.DeviceEnabled      = true;

            IsActive = true;
        }
Пример #4
0
        /// <summary>
        /// Print a receipt containing the text to the OPOS Printer.
        /// </summary>
        /// <param name="textToPrint"> The text to print on the receipt</param>
        private void OPOSPrinting(string textToPrint)
        {
            Match  barCodeMarkerMatch = Regex.Match(textToPrint, barCodeRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            bool   printBarcode       = false;
            string receiptId          = string.Empty;

            if (barCodeMarkerMatch.Success)
            {
                printBarcode = true;

                // Get the receiptId
                receiptId = barCodeMarkerMatch.Groups[1].ToString();

                // Delete the barcode marker from the printed string
                textToPrint = textToPrint.Remove(barCodeMarkerMatch.Index, barCodeMarkerMatch.Length);
            }

            // replace ESC with Char(27) and add a CRLF to the end
            textToPrint = textToPrint.Replace("ESC", ((char)27).ToString());
            textToPrint = textToPrint.Replace("<L>", "\x1B|1B\x1B|bC");

            if (LSRetailPosis.Settings.HardwareProfiles.Printer.BinaryConversion == true)
            {
                oposPrinter.BinaryConversion = 2;                  // OposBcDecimal
                textToPrint = Peripherals.ConvertToBCD(textToPrint + "\r\n\r\n\r\n", characterSet);
            }

            oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, textToPrint);
            oposPrinter.BinaryConversion = 0;              // OposBcNone

            // Check if we should print the receipt id as a barcode on the receipt
            if (printBarcode == true)
            {
                oposPrinter.PrintBarCode((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, receiptId, (int)OPOSPOSPrinterConstants.PTR_BCS_Code128,
                                         80, 80, (int)OPOSPOSPrinterConstants.PTR_BC_CENTER, (int)OPOSPOSPrinterConstants.PTR_BC_TEXT_BELOW);
                oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, "\r\n\r\n\r\n\r\n");
            }

            oposPrinter.CutPaper(100);
        }
Пример #5
0
        /// <summary>
        /// Begin transaction workflow on the claimed OPOS Pinpad device.
        /// Pinpad device will enable pin entry and request the user to follow debit workflows.
        /// </summary>
        /// <param name="amount"></param>
        /// <param name="accountNumber"></param>
        public void BeginTransaction(decimal amount, string accountNumber)
        {
            if (IsActive)
            {
                NetTracer.Information("Peripheral [PinPad] - Begin Transcation");

                // Clear any all device input that has been buffered (for data events)
                this.oposPinpad.ClearInput();

                this.oposPinpad.Amount = amount;
                //CheckResultCode();  // We know verifone has problems with amount.
                this.oposPinpad.AccountNumber = accountNumber;
                this.oposPinpad.TerminalID    = LSRetailPosis.Settings.ApplicationSettings.Terminal.TerminalId;
                if (amount < 0)
                {   // Money is being refunded to the debit card - this is credit
                    this.oposPinpad.TransactionType = (int)EFTTransactionType.Credit;
                }
                else
                {   // Debit trans
                    this.oposPinpad.TransactionType = (int)EFTTransactionType.Debit;
                }

                this.oposPinpad.Track1Data = String.Empty;
                this.oposPinpad.Track2Data = String.Empty;
                this.oposPinpad.Track3Data = String.Empty;
                this.oposPinpad.Track4Data = String.Empty;

                this.oposPinpad.DataEventEnabled = true;

                // NOTE FILED PS#2802: Terminal Host not same as TerminalID
                int th = Convert.ToInt32(this.oposPinpad.TerminalID);

                // Try to do BeginEFTTransaction (if busy, do retry until available or TMO).
                // If we are going to support retry logic, we may need to check for device
                // OPOS_E_BUSY with System.Threading.Thread.Sleep(2000);
                //
                Peripherals.CheckResultCode(this, oposPinpad.BeginEFTTransaction(encryptionAlgorithm, th));
                Peripherals.CheckResultCode(this, oposPinpad.EnablePINEntry());
            }
        }
Пример #6
0
        /// <summary>
        /// End PinPad transaction.
        /// </summary>
        /// <param name="normal"></param>
        public void EndTransaction(bool normal)
        {
            if (IsActive)
            {
                NetTracer.Information("Peripheral [PinPad] - End Transcation");

                int resultCode = 0;

                if (normal)
                {
                    // Tell the device to end the EFT transcation (Normal)
                    resultCode = oposPinpad.EndEFTTransaction((int)EFTTransactionCompletion.Normal);
                }
                else
                {
                    // Tell the device to end the EFT transcation (Abonormal)
                    resultCode = oposPinpad.EndEFTTransaction((int)EFTTransactionCompletion.Abnormal);
                }

                Peripherals.CheckResultCode(this, resultCode);
            }
        }