private void ProcessReconcilation(object state) { Instance 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); //int code = GetStatusCode(result); //if (!AuthResponse.IsValidCode(code)) //{ // OnError(instance); // return; //} 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); } }