private void ProcessReconcilation(object state) { var instance = CreateInstance(); if (!instance.IsValid) { return; } string result = String.Empty; try { result = EgateAPI.egAuthRequest(instance.Id, EgateAPI.ProtocolId, CreateRequest(OperationType.TotalsReconcilation).Append(" 1 1").ToString()).GetString(); } finally { ReleaseInstance(instance); } if (!IsValidResult(result)) { OnError(instance); } reconcilation = ReconcilationState.Completed; OnMessage(String.Format("Результат сверки итогов : {0}", result), false); }
private void AcquireKey() { if (Ready) { return; } Instance instance = null; try { instance = CreateInstance(); string result = EgateAPI.egAuthRequest(instance.Id, EgateAPI.ProtocolId, CreateRequest(OperationType.RequestWorkKey).ToString()).GetString(); if (!IsValidResult(result)) { OnError(instance); return; } OnMessage(String.Format("Ответ на запрос ключа : {0}", result), false); result = EgateAPI.egGetAuthResult(instance.Id).GetString(); if (!IsValidResult(result)) { OnError(instance); return; } AuthResponse response = null; try { response = AuthResponse.Parse(result, null); } catch (Exception x) { OnMessage(x.Message, true); } if ((response == null) || !AuthResponse.IsValidCode(response.GCSCode)) { return; } keyAcqiured = true; OnMessage(String.Format("Ключ получен успешно : {0}", response), false); } finally { ReleaseInstance(instance); } }