Example #1
0
        public void DoPrintJob()
        {
            try
            {
                Token token = null;

                bool      complete       = false;
                bool      success        = true;
                string    additionalInfo = String.Empty;
                IPrintJob printJob       = null;
                CardData  cardData       = null;

                // Go through steps proided the process hasnt completed or a step was not sucessful
                for (int step = 0; complete == false && success == true; step++)
                {
                    switch (step)
                    {
                    case 0:     // Connect to printer and do any setup
                        success = PrinterConnectAndSetup(out token, out additionalInfo);
                        break;

                    case 1:     // Get the print Job and settings
                        success = GetPrintJob(token, out printJob, out additionalInfo);
                        break;

                    case 2:     // Set Printer settings
                        success = SetPrinterSetting(printJob, out additionalInfo);
                        break;

                    case 3:     // Start physical printing
                        success  = StartPhysicalPrint(printJob, out cardData, out additionalInfo);
                        complete = true;
                        break;

                    default: complete = true; break;
                    }
                }

                if (complete && success)
                {
                    // Update Indigo
                    _cardPrinting.PrintingComplete(token, cardData);
                    Dictionary <string, string> _printerInfo = _printer.GetPrinterInfo();
                    string cardscount = "-1";
                    _printerInfo.TryGetValue("Total Cards Printed", out cardscount);
                    if (!string.IsNullOrEmpty(cardscount))
                    {
                        PrinterInfo printerInfo = new PrinterInfo
                        {
                            TotalPrints = int.Parse(cardscount),
                            SerialNo    = _printer.DeviceId
                        };
                        // Send Analytics
                        _cardPrinting.PrinterAuditDetails(token, printerInfo);
                    }

                    OnUiUpdate(CardPrintingLogicResource.PrintingDoneUi, false, true, EventArgs.Empty);
                }
                else
                {
                    OnUiUpdate(CardPrintingLogicResource.PrintingFailedUi + additionalInfo, false, true, EventArgs.Empty);
                    _cardPrinting.PrintFailed(token, additionalInfo);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException enfex)
            {
                OnUiUpdate(enfex.Message, false, true, EventArgs.Empty);
                //Console.WriteLine(enfex);
            }
            catch
            {
                throw;
                //OnUiUpdate(String.Format("{0}{1}{2}{3}{4}", _pinPad.DllPath, Environment.NewLine,ex.Message, Environment.NewLine, ex.ToString()), EventArgs.Empty);
                //Console.WriteLine(ex);
            }
            finally
            {
                _printer.Disconnect();
                _printer.OnDeviceNotifcation -= DeviceNotifcation;
                _printer.Dispose();
            }
        }
Example #2
0
 public Response <string> PrintFailed(Token printToken, string comments)
 {
     return(_printProxy.PrintFailed(printToken, comments));
 }