void LoadBarcodes()
        {
            try
            {
                _posexplorer        = new PosExplorer();
                _barcodescannerList = _posexplorer.GetDevices(DeviceType.Scanner);

                IEnumerable <PosDeviceInfo> posdevinfo = PosDeviceInfo.CreatePosDeviceInfoCollection(_barcodescannerList);

                foreach (PosDeviceInfo item in posdevinfo)
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new Action(() => lbBarcodeDevs.Items.Add(item)));
                    }
                }
            }
            catch (PosControlException ex)
            {
                _logger.LogError(ex, "The application received an error ", "frmHardwaresetup", "ActivateScanner");
                Helper.ShowMessage("The application received an error  \n" + ex.Message,
                                   "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "The application received an error ", "frmHardwaresetup", "ActivateScanner");
                Helper.ShowMessage("The application received an error  \n" + ex.Message,
                                   "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        void InitializePrinter()
        {
            //<<<step1>>>--Start
            //Use a Logical Device Name which has been set on the SetupPOS.
            //string strLogicalName = "PosPrinter";
            string printerName = Properties.Settings.Default.DefaultPrinterName;

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo =
                    PosDeviceInfo.CreatePosDeviceInfoCollection(posExplorer.GetDevices(DeviceType.PosPrinter))
                    .Where(d => d.Description == printerName)
                    .FirstOrDefault().DeviceInfo;

                SetStatusMessage("Checking if device drivers are installed...");

                try
                {
                    //deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter);
                    m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Application received an error while trying to initialize device.",
                                     "frmStartUp", "InitializePrinter");
                    SetStatusMessage("Application received an error while trying to initialize device.");
                    return;
                }
            }
            catch (PosControlException ex)
            {
                _logger.LogError(ex, "Application received an error while trying to initialize device...",
                                 "frmStartUp", "InitializePrinter");
                SetStatusMessage("Application received an error while trying to initialize device...");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Application received an error while trying to initialize device...",
                                 "frmStartUp", "InitializePrinter");
                SetStatusMessage("Application received an error while trying to initialize device...");
            }
            //<<<step1>>>--End
        }
Exemple #3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            if (new GenericService <Company>().GetAll().ToList().Count == 0)
            {
                new frmAddCompany().ShowDialog();
            }

            SetUserName();

            try
            {
                this.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        posExplorer           = new PosExplorer(this);
                        string barocodename   = Properties.Settings.Default.DefaultScannerName;
                        DeviceInfo deviceInfo =
                            PosDeviceInfo.CreatePosDeviceInfoCollection(posExplorer.GetDevices(DeviceType.Scanner))
                            .Where(d => d.Description == barocodename)
                            .FirstOrDefault().DeviceInfo;

                        ActivateScanner(deviceInfo);
                    }
                    catch (PosControlException ex)
                    {
                        _logger.LogError(ex, "The application received an error ", "frmMain", "ActivateScanner");
                        Helper.ShowMessage("The application received an error  \n" + ex.Message,
                                           "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    catch (Exception ex)
                    {
                        Helper.ShowMessage(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        _logger.LogError(ex, "An error occurred", "frmMain", "scanner initialization");
                    }
                }));
            }

            catch (Exception ex)
            {
                Helper.ShowMessage(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _logger.LogError(ex, "An error occurred", "frmMain", "scanner initialization");
            }
        }