private void ProcessCancelTransaction(object state)
        {
            string status = EgateAPI.egGetOpStatus(current.Id, true).GetString();

            cancel = (status[0] == EgateAPI.StatusResult) ? CancelState.Completed : CancelState.None;
            OnMessage(String.Format("Транзакция отменена : {0}", cancel), false);

            if (cancel == CancelState.Completed)
            {
                SberBank.TransactionCancelled++;
            }
        }
        private void ProcessTransaction(object sender, ElapsedEventArgs e)
        {
            string status = EgateAPI.egGetOpStatus(current.Id, false).GetString();

            if (status[0] == EgateAPI.StatusResult)
            {
                timer.Stop();
                OnMessage(String.Format("Запрос обработан : {0}", status.Substring(1)), false);

                AuthResponse response = null;
                try
                {
                    byte[] ba;
                    string result = EgateAPI.egGetAuthResult(current.Id).GetString(out ba);
                    if (IsValidResult(result))
                    {
                        lastTransactionResult = (cancel == CancelState.Completed) ? TransactionResult.Cancelled : TransactionResult.OK;
                    }
                    else
                    {
                        lastTransactionResult = TransactionResult.Error;
                        OnError(current);
                    }

                    response = AuthResponse.Parse(result, ba);
                }
                catch (Exception x)
                {
                    OnMessage(x.Message, true);
                }
                finally
                {
                    OnTransactionCompleted(lastTransactionResult, response);
                    state = EquipmentState.CardTaken;
                    OnStateChanged(state, status.Substring(1));
                }
            }
            else if (status[0] == EgateAPI.StatusBusy)
            {
                EquipmentState s = state;
                switch (status[1])
                {
                case EgateAPI.StatusWaitCard:
                    //if (_state == EquipmentState.Started)
                    s = EquipmentState.WaitingForCard;
                    break;

                case EgateAPI.StatusCardEntered:
                    //if (_state == EquipmentState.WaitingForCard)
                    s = EquipmentState.CardInserted;
                    break;

                case EgateAPI.StatusPinEntered:
                    if (state == EquipmentState.CardInserted)
                    {
                        s = EquipmentState.PinEntered;
                    }
                    break;

                case EgateAPI.StatusAuthCompleted:
                    if ((state != EquipmentState.Started) && (state != EquipmentState.WaitingForCard))
                    {
                        s = EquipmentState.AuthCompleted;
                    }
                    break;

                default:
                    s = state;
                    break;
                }

                if (state == s)
                {
                    return;
                }
                state = s;
                OnStateChanged(state, status.Substring(2));
            }
        }