/// <summary> /// Upload the HEX file to the cash register /// </summary> /// <param name="intelHex"></param> public async void UploadHexFile(IntelHex intelHex) { FirmwareInfo firmwareInfo = new FirmwareInfo(); firmwareInfo.Set("Version", intelHex.Headers.Version); firmwareInfo.Set("Description", intelHex.Headers.Description); firmwareInfo.Set("FirmwareGUID", intelHex.Headers.FirmwareGUID); Task <dynamic> task = this.SendFirmwareInfo(firmwareInfo); dynamic result = await task; ResponseFirmware responseFirmwareInfo = ParseFirmwareInfoResponse(result); if (responseFirmwareInfo.IsSuccess) { } }
/// <summary> /// Parse response from the '/cgi/fw_burn' method /// </summary> /// <param name="response"></param> /// <returns></returns> public ResponseFirmware ParseFirmwareResponseBurn(dynamic response) { ResponseFirmware responseFirmware = new ResponseFirmware(); responseFirmware.Error = ""; responseFirmware.IsSuccess = false; try { if (response != null) { if (response.fw_burn_error != null) { responseFirmware = CheckFirmwareFieldForError(response.fw_burn_error); } } } catch (Exception ex) { ShowError(ex.ToString()); } return(responseFirmware); }
/// <summary> /// Parse response from the '/cgi/fw_version' method /// </summary> /// <param name="response"></param> /// <returns></returns> public ResponseFirmware ParseFirmwareInfoResponse(dynamic response) { ResponseFirmware responseFirmware = new ResponseFirmware(); responseFirmware.Error = ""; responseFirmware.IsSuccess = false; try { if (response != null) { if (response.fw_info_error != null) { responseFirmware = CheckFirmwareFieldForError(response.fw_info_error); } } } catch (Exception ex) { responseFirmware.Error = "System error: " + ex.Message; } return(responseFirmware); }
/// <summary> /// Check if the response is success or not /// </summary> /// <param name="field"></param> /// <returns></returns> public ResponseFirmware CheckFirmwareFieldForError(dynamic field) { ResponseFirmware response = new ResponseFirmware(); response.IsSuccess = true; response.Error = ""; try { int responseCode = int.Parse(field); if (responseCode != RESPONSE_SUCCESS) { response.IsSuccess = false; response.Error = ECRDictionary.GetTranslation(field); return(response); } } catch (Exception) { response.IsSuccess = false; response.Error = ECRDictionary.GetTranslation(field); return(response); } return(response); }