private void PrintServiceDocumentString(ClientHelper clientHelper) { var request = new Request(0x40) .Append(value, exactLength, justification) .Append(textAttributes); clientHelper.Client.GetResponse(request); }
public void Print(ClientHelper clientHelper, DocumentType documentType) { var request = new Request(0x41) .Append(printText ? 2 : 0) .Append(2) .Append(80) .Append(2) .Append(data); clientHelper.Client.GetResponse(request); }
public void FiscalReportS(String id, Int32 password, Int32 shift1, Int32 shift2, Int32 isFull, out Int32 errorCode) { try { StartOrWork(clients[id]); var request = new Request(0x61) .Append(isFull) .Append(shift1) .Append(shift2) .Append(password); clients[id].Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
public void FiscalReportD(String id, Int32 password, Int32 year1, Int32 month1, Int32 day1, Int32 year2, Int32 month2, Int32 day2, Int32 isFull, out Int32 errorCode) { try { StartOrWork(clients[id]); var request = new Request(0x62) .Append(isFull) .Append(new DateTime(year1, month1, day1), false) .Append(new DateTime(year2, month2, day2), false) .Append(password); clients[id].Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
public void Fiscalization(String id, Int32 oldPassword, Int32 newPassword, Int64 machineRegNum, Int64 taxpayerIndNum, out Int32 errorCode) { try { StartOrWork(clients[id]); var request = new Request(0x60) .Append(oldPassword) .Append(machineRegNum) .Append(taxpayerIndNum) .Append(newPassword); clients[id].Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
public Int32 GetCashMoney(String id, out Int32 errorCode) { var cashMoney = 0; try { var request = new Request(0x02) .Append(7); var response = clients[id].Client.GetResponse(request); cashMoney = (Int32)(response.GetDecimal(1) * 100); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } return cashMoney; }
public void MoveCash(String id, Int32 money, Int32 directionIn, out Int32 errorCode) { try { OpenDocument(clients[id], directionIn == 1 ? DocumentType.CashIn : DocumentType.CashOut, 0); var request = new Request(0x48) .Append(Resources.Amount_Title) .Append((Decimal)money / 100); clients[id].Client.GetResponse(request); CloseDocument(clients[id]); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
public void ShiftReport(String id, Int32 isZReport, out Int32 errorCode) { try { StartOrWork(clients[id]); var request = new Request(isZReport == 1 ? (Byte)0x21 : (Byte)0x20) .Append(clients[id].CashierName, Cashier_Name_Len); clients[id].Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
private void SetTableString(ClientHelper clientHelper, Int32 tableNumber, Int32 tableRow, String value, out Int32 errorCode) { if (value == null) value = String.Empty; try { var request = new Request(0x12) .Append(tableNumber) .Append(tableRow) .Append(value, 40); clientHelper.Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode == 0x0F ? Constants.E_SUCCESS : e.ErrorCode; } }
private void AddPayment(ClientHelper clientHelper, Int32 paymentType, Int32 amount) { var request = new Request(0x47) .Append(paymentType) .Append((Decimal)amount / 100) .Append(String.Empty); clientHelper.Client.GetResponse(request); }
private void SetDateTime(ClientHelper clientHelper, Boolean repeatOnError) { try { var request = new Request(0x14) .Append(DateTime.Today, false) .Append(DateTime.Now, true); clientHelper.Client.GetResponse(request); } catch (ProtocolException e) { if (e.ErrorCode == 0x0A && repeatOnError) { SetDateTime(clientHelper, false); return; } throw; } }
private void AddPosition(DocumentType documentType, String id, String goodName, Int32 quantity, Int32 price, Int32 deptNo, out Int32 errorCode) { try { OpenDocument(clients[id], documentType, deptNo); var request = new Request(0x42) .Append(goodName, 56) .Append(String.Empty) .Append((Decimal)quantity / 1000) .Append((Decimal)price / 100); clients[id].Client.GetResponse(request); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
private void OpenDocument(ClientHelper clientHelper, DocumentType documentType, Int32 deptNo) { var ecrFlags = StartOrWork(clientHelper); if (ecrFlags.DocumentStatus.Type == DocumentType.None) { var request = new Request(0x30) .Append((Int32)documentType) .Append(deptNo) .Append(clientHelper.CashierName, Cashier_Name_Len) .Append(0); clientHelper.Client.GetResponse(request); PrintBufferedItems(documentType, clientHelper); } }
public Int32 GetReceiptNumber(String id, Int32 receiptType, out Int32 errorCode) { var receiptNumber = 0; try { var request = new Request(0x03); request.Append(2); var response = clients[id].Client.GetResponse(request); receiptNumber = response.GetInt32(4); errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } return receiptNumber; }
public void GetHardwareInfo2(String id, out String hardwareTypeId, out String hardwareNumber, out Int32 isFiscalized, out Int32 errorCode) { hardwareTypeId = Resources.Hardware_Type_Id; hardwareNumber = String.Empty; isFiscalized = 0; try { var request = new Request(0x02) .Append(1); hardwareNumber = clients[id].Client .GetResponse(request) .GetString(1); isFiscalized = GetEcrFlags(clients[id].Client).CurrentStatus.NonFiscal ? 0 : 1; errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } }
private EcrStatusFlags StartOrWork(ClientHelper clientHelper) { var ecrFlags = GetEcrFlags(clientHelper.Client); if (ecrFlags.CurrentStatus.StartOfWorkHasNotBeenCalled) { var request = new Request(0x10) .Append(DateTime.Now, false) .Append(DateTime.Now, true); try { clientHelper.Client.GetResponse(request); } catch (ProtocolException e) { if (e.ErrorCode != 0x0B) throw; } } return ecrFlags; }
public Int32 GetMoneyRegister(String id, Int32 register, out Int32 errorCode) { Int32 registerValue = 0; try { if (register == 1 || register == 3) { var request = new Request(0x03) .Append(1); var response = clients[id].Client.GetResponse(request); registerValue = (Int32)(response.GetDecimal(1) * 100); } errorCode = Constants.E_SUCCESS; } catch (KeyNotFoundException) { errorCode = Constants.E_NOT_FOUND; } catch (TimeoutException) { errorCode = Constants.E_TIMEOUT; } catch (ProtocolException e) { errorCode = e.ErrorCode; } return registerValue; }
public Response GetResponse(Request request) { WriteRequest(request.ToArray()); var response = new Response(ReadResponse()); if (request.PacketId != response.PacketId) throw new InvalidOperationException(Resources.Packet_Id_Differs); if (!response.IsCrcValid) throw new InvalidOperationException(Resources.Invalid_Response_CRC); if (response.ErrorCode != 0) throw new ProtocolException(response); return response; }