Example #1
0
        // Waits for a smart card to be at the smart card programming station
        // --------------------------------------------------------------------------------------------------

        private void AtStation(ref Job job, int actionID, int loops, out string status)
        {
            bool timedOut = true;

            JobStatusStruct js = new JobStatusStruct();

            status = "";

            for (int i = 0; i < loops; i++)
            {
                try
                {
                    _alarm = job.GetJobStatus(actionID, out js.uuidJob, out js.printingStatus,
                                              out js.cardPosition, out js.errorCode, out js.copiesCompleted,
                                              out js.copiesRequested, out js.magStatus, out js.contactStatus,
                                              out js.contactlessStatus);
                }
                catch (Exception e)
                {
                    status = "At Station Exception: " + e.Message;
                    break;
                }

                //if (js.printingStatus.Contains("error") || js.printingStatus == "at_station" ||
                //    js.contactStatus == "at_station" || js.contactlessStatus == "at_station")
                if (js.contactlessStatus == "at_station")
                {
                    timedOut = false;
                    break;
                }
                Thread.Sleep(1000);
            }
            if (timedOut)
            {
                status = "At Station Timed Out";
            }
        }
        // Waits for a job to complete
        // --------------------------------------------------------------------------------------------------

        public void JobWait(ref Job job, int actionID, int loops, out string status)
        {
            status = string.Empty;

            try
            {
                JobStatusStruct js = new JobStatusStruct();

                while (loops > 0)
                {
                    try
                    {
                        _alarm = job.GetJobStatus(actionID, out js.uuidJob, out js.printingStatus,
                                                  out js.cardPosition, out js.errorCode, out js.copiesCompleted,
                                                  out js.copiesRequested, out js.magStatus, out js.contactStatus,
                                                  out js.contactlessStatus);

                        if (js.printingStatus == "done_ok" || js.printingStatus == "cleaning_up")
                        {
                            status = js.printingStatus + ": " + "Indicates a job completed successfully";
                            break;
                        }
                        else if (js.printingStatus.Contains("cancelled"))
                        {
                            status = js.printingStatus;
                            break;
                        }

                        if (js.contactStatus.ToLower().Contains("error"))
                        {
                            status = js.contactStatus;
                            break;
                        }

                        if (js.printingStatus.ToLower().Contains("error"))
                        {
                            status = "Printing Status Error";
                            break;
                        }

                        if (js.contactlessStatus.ToLower().Contains("error"))
                        {
                            status = js.contactlessStatus;
                            break;
                        }

                        if (js.magStatus.ToLower().Contains("error"))
                        {
                            status = js.magStatus;
                            break;
                        }

                        if (_alarm != 0 && _alarm != 4016) //no error or out of cards
                        {
                            status = "Error: " + job.Device.GetStatusMessageString(_alarm);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        status = "Job Wait Exception: " + e.Message;
                        break;
                    }

                    if (_alarm == 0)
                    {
                        if (--loops <= 0)
                        {
                            status = "Job Status Timeout";
                            break;
                        }
                    }
                    Thread.Sleep(1000);
                }
            }
            finally
            {
                _msg = status;
            }
        }