Beispiel #1
0
        public short ReadAndPrint(string productBin, ICardPrintDetails cardPrintDetails, out IDeviceMagData magData)
        {
            RaiseDeviceNotification("Call to ReadAndPrint()", false, EventArgs.Empty);
            magData = null;
            System.Threading.Thread.Sleep(3000);
            ExtractDetails(productBin, cardPrintDetails);

            return(PrinterCodes.Success);
        }
Beispiel #2
0
        public short Print(string productBin, ICardPrintDetails cardPrintDetails)
        {
            RaiseDeviceNotification("Call to Print()", false, EventArgs.Empty);

            System.Threading.Thread.Sleep(3000);

            //var pollTask = PollJobStatusAsync();

            ExtractDetails(productBin, cardPrintDetails);
            //pollTask.Wait();

            return(PrinterCodes.Success);
        }
Beispiel #3
0
        private int PositionAndPrint(ICardPrintDetails cardPrintDetails, Dictionary <string, string> jobSettings)
        {
            _zebraCardPrinter.SetJobSettings(jobSettings);

            // Build graphics for print job
            List <GraphicsInfo> _graphics = new List <GraphicsInfo>();

            _graphics.Add(CreateFrontGraphics(_zebraCardPrinter, (ZebraCardPrintDetails)cardPrintDetails));
            // _graphics.Add(CreateBackGraphics(_zebraCardPrinter, (ZebraCardPrintDetails)cardPrintDetails));

            if (_skipPrinting)
            {
                return(-99);
            }

            // Send job
            return(_zebraCardPrinter.Print(1, _graphics));
        }
Beispiel #4
0
        private void ExtractDetails(string productBin, ICardPrintDetails cardPrintDetails)
        {
            var info = new StringBuilder();

            info.AppendLine("ProductBIN: " + productBin);

            foreach (var detail in cardPrintDetails.FrontPanelText)
            {
                info.AppendLine("Front Text Panel - " + detail.Text);
            }

            foreach (var detail in cardPrintDetails.BackPanelText)
            {
                info.AppendLine("Back Text Panel - " + detail.Text);
            }

            info.AppendLine("Front Image Count - " + cardPrintDetails.FrontPanelImages.Length);
            info.AppendLine("Back Image Count - " + cardPrintDetails.BackPanelImages.Length);

            RaiseDeviceNotification(info.ToString(), false, EventArgs.Empty);

            System.Threading.Thread.Sleep(5000);
        }
Beispiel #5
0
        public short Print(string productBin, ICardPrintDetails cardPrintDetails)
        {
            if (!HasMagEncoder()) // If we have a mag reader then read the mag and check product bin matches card inserted
            {
                IDeviceMagData magData;
                return(ReadAndPrint(productBin, cardPrintDetails, out magData));
            }
            else // No mag reader installed, just do print
            {
                _currentPrintJob = PositionAndPrint(cardPrintDetails, new Dictionary <string, string> {
                    { ZebraCardJobSettingNames.CARD_SOURCE, _cardSource.ToString() },
                    { ZebraCardJobSettingNames.CARD_DESTINATION, CardDestination.Eject.ToString() }
                });
                var pollJobTask = PollJobStatusAsync();

                // Poll job status
                if (_currentPrintJob != -99)
                {
                    pollJobTask.Wait();
                    return(pollJobTask.Result);
                }
            }
            return(PrinterCodes.Success);
        }
Beispiel #6
0
 public short ReadAndPrint(string productBin, ICardPrintDetails cardPrintDetails, out IDeviceMagData magData)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
        public short Print(string productBin, ICardPrintDetails cardPrintDetails)
        {
            int    alarm    = 0;
            int    actionID = 0;
            int    copies   = 1;
            string err;
            string printingStatus, magStatus, contactStatus, contactlessStatus;
            int    errorCode, copiesCompleted, copiesRequested;

            try
            {
                _zebraSDK.JobControl.FeederSource = FeederSourceEnum.AutoDetect;
                _zebraSDK.JobControl.Destination  = DestinationTypeEnum.Eject;

                alarm = _zebraSDK.PrintGraphicsLayers(copies, out actionID);
                int count = 0;
                while (count <= 30)
                {
                    //string printingStatus, magStatus, contactStatus, contactlessStatus;
                    //int errorCode, copiesCompleted, copiesRequested;

                    alarm = _zebraSDK.GetJobStatus(actionID, out printingStatus, out errorCode, out copiesCompleted, out copiesRequested,
                                                   out magStatus, out contactStatus, out contactlessStatus);

                    if (printingStatus.Equals("done_ok", StringComparison.OrdinalIgnoreCase)) // job completed successfully
                    {
                        return(PrinterCodes.Success);
                    }
                    else if (printingStatus.ToLower().Contains("error")) // job failed
                    {
                        return(PrinterCodes.UnknownError);
                    }
                    else if (alarm > 0 && alarm != 4001) //Some alarm raised other than out of cards
                    {
                        return(PrinterCodes.UnknownError);
                    }

                    System.Threading.Thread.Sleep(1000);
                    count++;
                }

                return(PrinterCodes.PrintJobTimedOut);
            }
            catch (Exception ex)
            {
                //error += ex.ToString();
            }
            finally
            {
                _zebraSDK.ClearGraphicsLayers();

                if (alarm > 0 && actionID > 0)
                {
                    _zebraSDK.JobCancel(actionID);
                    err = _zebraSDK.Device.GetStatusMessageString(alarm);
                    //TODO : Log the alarm code
                }
            }

            return(PrinterCodes.UnknownError);
        }
Beispiel #8
0
        public short ReadAndPrint(string productBin, ICardPrintDetails cardPrintDetails, out IDeviceMagData magData)
        {
            magData = null;

            if (cardPrintDetails == null)
            {
                throw new Exception("No printing data available to print to card.");
            }

            if (!HasMagEncoder())
            {
                throw new Exception("Device does not have a Magstripe encoder installed.");
            }

            string status;
            List <IDeviceErrorDescriptor> errors;

            if (CheckPrinterStatus(out status, out errors))
            {
                try
                {
                    // Set the card destination to 'Hold' after we have read the mag stripe

                    _zebraCardPrinter.SetJobSettings(new Dictionary <string, string> {
                        { ZebraCardJobSettingNames.CARD_SOURCE, _cardSource.ToString() },
                        { ZebraCardJobSettingNames.CARD_DESTINATION, CardDestination.Hold.ToString() }
                    });

                    // Set the card source to 'Internal' and destination to 'Eject'
                    _currentPrintJob = PositionAndPrint(cardPrintDetails, new Dictionary <string, string> {
                        { ZebraCardJobSettingNames.CARD_SOURCE, CardSource.Internal.ToString() },
                        { ZebraCardJobSettingNames.CARD_DESTINATION, CardDestination.Eject.ToString() }
                    });


                    ZebraMagData deviceMagData = new ZebraMagData(_zebraCardPrinter.ReadMagData(DataSource.Track1 | DataSource.Track2 | DataSource.Track3));


                    // Check that product matches BIN
                    if (!deviceMagData.TrackDataToString(2).StartsWith(productBin))
                    {
                        return(PrinterCodes.ProductBinAndCardMismatch);
                    }
                    var pollJobTask = PollJobStatusAsync();

                    magData = deviceMagData;

                    // Poll job status
                    if (_currentPrintJob != -99)
                    {
                        pollJobTask.Wait();
                        //  _zebraCardPrinter.EjectCard();
                        return(pollJobTask.Result);
                    }

                    return(PrinterCodes.Success);
                }
                catch
                {
                    _zebraCardPrinter.EjectCard();
                    throw;
                }
            }

            throw new Exception("Printer in failed state.");
        }