static ReactiveResponse FromHttpResponse(HttpResponseMessage httpResponse) { var response = new ReactiveResponse(); response.StatusCode = (int)httpResponse.StatusCode; response.Headers = FromHttpHeaders(httpResponse.Headers); response.Content = FromHttpContent(httpResponse.Content); return response; }
void ObserveResponse(ReactiveResponse response) { Response = response; contentSubscription?.Dispose(); contentSubscription = response.WhenAnyValue(x => x.Content) .Subscribe(ObserveContent); headersSubscription?.Dispose(); headersSubscription = response.WhenAnyValue(x => x.Headers) .Subscribe(ObserveHeaders); }
public async Task <ReactiveResponse> GetPrescriptionBarcodeDetailesByPrescriptionId(long prescriptionId) { var response = new ReactiveResponse(); try { var result = await _prescriptionBarcodeDetailesRepository.GetWhere(a => a.PrescriptionBarcode.PrescriptionId == prescriptionId); response.ItemsInfo = new List <PrescriptionBarcodeDetailesResponse>(); PrescriptionBarcodeDetailesResponse prescriptionBarcodeDetailesResponse; foreach (var item in result) { prescriptionBarcodeDetailesResponse = new PrescriptionBarcodeDetailesResponse(); result.CopyPropertiesTo(prescriptionBarcodeDetailesResponse); response.ItemsInfo.Add(prescriptionBarcodeDetailesResponse); } return(response.ToSuccess <ReactiveResponse>()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <ReactiveResponse> ReActivePrescriptionId(long PrescriptionId) { var response = new ReactiveResponse(); response.ItemsInfo = new List <PrescriptionBarcodeDetailesResponse>(); var prescriptionBarcodeDetailes = new PrescriptionBarcodeDetailes(); var prescriptionBarcodeDetailesResponse = new PrescriptionBarcodeDetailesResponse(); try { if (PrescriptionId == 0) { return(response.ToIncompleteInput <ReactiveResponse>()); } TTAC tTAC = new TTAC(_serviceProvider); var result = await _prescriptionBarcodeDetailesRepository.GetWhere(a => a.PrescriptionBarcode.PrescriptionId == PrescriptionId && a.Status == 0); if (result == null) { return(response.ToRowNotFound <ReactiveResponse>()); } if (result.Count == 0) { return(response.ToRowNotFound <ReactiveResponse>()); } foreach (var item in result) { TTACReactiveRequest tTACReactiveRequest = new TTACReactiveRequest(); TTACReactiveResponse tTACReactiveResponse = new TTACReactiveResponse(); var prescriptionBarcode = await _prescriptionBarcodeRepository.FirstOrDefault(a => a.Id == item.PrescriptionBarcodeId); var prescription = await _prescriptionRepository.FirstOrDefault(a => a.Id == prescriptionBarcode.PrescriptionId); tTACReactiveRequest.Amount = prescriptionBarcode.Amount; tTACReactiveRequest.TrackingCode = (int)item.TrackingCode; tTACReactiveRequest.BarcodeUid = item.BarcodeUid; tTACReactiveRequest.PharmacyGln = prescription.PharmacyGln; tTACReactiveRequest.Username = Constants.TTAC_UserName; tTACReactiveRequest.Password = Constants.TTAC_Password; tTACReactiveResponse = await tTAC.CallReactiveApi(tTACReactiveRequest); response.ErrorCode = tTACReactiveResponse.ErrorCode; response.ErrorMessage = tTACReactiveResponse.ErrorMessage; foreach (var resultItem in tTACReactiveResponse.ItemsInfo) { prescriptionBarcodeDetailes = new PrescriptionBarcodeDetailes(); prescriptionBarcodeDetailes.PrescriptionBarcodeId = item.PrescriptionBarcodeId; prescriptionBarcodeDetailes.PrescriptionBarcodeDetailesTypesId = (int)PrescriptionBarcodeDetailesTypeEnum.ReActiveBarcodeItems; resultItem.CopyPropertiesTo(prescriptionBarcodeDetailes); resultItem.CopyPropertiesTo(prescriptionBarcodeDetailesResponse); response.ItemsInfo.Add(prescriptionBarcodeDetailesResponse); if (tTACReactiveResponse.ErrorCode == 0 && (resultItem.Status == 100 || resultItem.Status == 111)) { prescriptionBarcode.PrescriptionBarcodeStatusId = (int)PrescriptionBarcodeStatusEnum.ReActiveRequest; await _prescriptionBarcodeRepository.Update(prescriptionBarcode); } await _prescriptionBarcodeDetailesRepository.Add(prescriptionBarcodeDetailes); } } response.HasError = false; return(response); } catch (Exception e) { response.ToApiError <ReactiveResponse>(); _logService.LogText(e.StackTrace); throw new Exception(e.Message); } }
public async Task <ReactiveResponse> ReActive(ReactiveRequest reactiveRequest) { var response = new ReactiveResponse(); response.ItemsInfo = new List <PrescriptionBarcodeDetailesResponse>(); var prescriptionBarcodeDetailes = new PrescriptionBarcodeDetailes(); var prescriptionBarcodeDetailesResponse = new PrescriptionBarcodeDetailesResponse(); try { if (string.IsNullOrEmpty(reactiveRequest.BarcodeUid) || string.IsNullOrEmpty(reactiveRequest.PharmacyGln) || reactiveRequest.Amount == 0 || reactiveRequest.TrackingCode == 0) { return(response.ToIncompleteInput <ReactiveResponse>()); } TTAC tTAC = new TTAC(_serviceProvider); var result = await _prescriptionBarcodeDetailesRepository.FirstOrDefault(a => a.TrackingCode == reactiveRequest.TrackingCode && a.BarcodeUid == reactiveRequest.BarcodeUid); if (result == null) { return(response.ToRowNotFound <ReactiveResponse>()); } prescriptionBarcodeDetailes.PrescriptionBarcodeId = result.PrescriptionBarcodeId; prescriptionBarcodeDetailes.PrescriptionBarcodeDetailesTypesId = (int)PrescriptionBarcodeDetailesTypeEnum.ReActiveBarcodeItems; TTACReactiveRequest tTACReactiveRequest = new TTACReactiveRequest(); TTACReactiveResponse tTACReactiveResponse = new TTACReactiveResponse(); reactiveRequest.CopyPropertiesTo(tTACReactiveRequest); tTACReactiveRequest.Username = Constants.TTAC_UserName; tTACReactiveRequest.Password = Constants.TTAC_Password; tTACReactiveResponse = await tTAC.CallReactiveApi(tTACReactiveRequest); response.ErrorCode = tTACReactiveResponse.ErrorCode; response.ErrorMessage = tTACReactiveResponse.ErrorMessage; foreach (var item in tTACReactiveResponse.ItemsInfo) { prescriptionBarcodeDetailes = new PrescriptionBarcodeDetailes(); item.CopyPropertiesTo(prescriptionBarcodeDetailes); item.CopyPropertiesTo(prescriptionBarcodeDetailesResponse); response.ItemsInfo.Add(prescriptionBarcodeDetailesResponse); prescriptionBarcodeDetailes.PrescriptionBarcodeId = result.PrescriptionBarcodeId; prescriptionBarcodeDetailes.PrescriptionBarcodeDetailesTypesId = (int)PrescriptionBarcodeDetailesTypeEnum.ReActiveBarcodeItems; if (tTACReactiveResponse.ErrorCode == 0 && item.Status == 100) { var prescriptionBarcode = await _prescriptionBarcodeRepository.FirstOrDefault(a => a.Id == result.PrescriptionBarcodeId); prescriptionBarcode.PrescriptionBarcodeStatusId = (int)PrescriptionBarcodeStatusEnum.ReActiveRequest; await _prescriptionBarcodeRepository.Update(prescriptionBarcode); } await _prescriptionBarcodeDetailesRepository.Add(prescriptionBarcodeDetailes); } response.HasError = false; return(response); } catch (Exception e) { _logService.LogText("PrescriptionBarcodeInternalError" + e.Message.ToString()); throw new Exception(e.Message); } }
void ObserveReceiving(ReactiveResponse response) { ResponseReady?.Invoke(this, response); }