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) { Gazprom.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) { _state = s; OnStateChanged(_state, status.Substring(2)); } } }