/// <summary> /// Get the inbound shipments from the read-only inbound shipment repository. /// </summary> /// <returns>If success, all inbound shipments. Else, an empty list.</returns> public async Task <IList <InboundShipment> > GetInboundShipments(string filter = null) { filter = filter?.ToLower(); try { var filteredItems = await _inboundShipmentRepository .ReadInboundShipmentsWithFilter(filter).ConfigureAwait(false); // sort by shipment flag and document number filteredItems = filteredItems.OrderBy(item => item.DocumentNumber).ToList(); _receiptWorkItemTable = _receiptWorkItemTable ?? await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); // Ensure that inbound shipments without remaining quantities are not returned. return((await Task.WhenAll(filteredItems .Select(FilterOnQuantityRemaining) ).ConfigureAwait(false))?.Where(item => item != null).ToArray()); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to read inbound shipments: {ex}"); ex.Report(); return(new List <InboundShipment>()); } }
/// <summary> /// Get a ReceiptWorkItem instance from the cloud service. /// </summary> /// <param name="receiptId">The unique identifier of the receipt work item.</param> /// <returns>If exception, null. Else null or instance.</returns> public async Task <ReceiptWorkItem> GetReceiptWorkItem(string receiptId) { if (string.IsNullOrWhiteSpace(receiptId)) { return(null); } try { var workItemTable = await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); return(await workItemTable.ReadItemAsync(receiptId).ConfigureAwait(false)); } catch (Exception ex) { _logService.WriteErrorLogEntry( $"An error occured while reading receipt work item ({receiptId}): {ex}" ); ex.Report(); return(null); } }
private async Task AddNoteWorkItem(NoteWorkItem noteWorkItem) { try { var notesWorkItemTable = await _cloudService.GetTableAsync <NoteWorkItem>().ConfigureAwait(false); await notesWorkItemTable.CreateItemAsync(noteWorkItem).ConfigureAwait(false); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to create notes work item: {ex}"); ex.Report(); } }
/// <summary> /// Get all ReceiptWorkItems from the Azure cloud service table. These items are filtered /// by the current branch identifier. Only receipt work items for the current branch will /// be returned from this method. /// </summary> /// <returns> /// An asynchronous Task instance that returns a list of ReceiptWorkItem instances. /// </returns> public async Task <IList <ReceiptWorkItem> > GetReceiptWorkItems() { try { var receiptWorkItemTable = await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); var items = await receiptWorkItemTable .ReadItemsAsync( 0, int.MaxValue, // Filter by current branch identifier. item => item.BranchId == _branchId ).ConfigureAwait(false); return(new List <ReceiptWorkItem>(items)); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to read receipt work items: {ex}"); ex.Report(); return(new List <ReceiptWorkItem>()); } }
/// <summary> /// Get the cloud table backing the work items. /// </summary> /// <returns>An asynchronous Task that returns the backing cloud table.</returns> private async Task <ICloudTable <ReceiptWorkItem> > GetCloudTable() { _table = _table ?? await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); return(_table); }
/// <summary> /// Get of fetch a cloud table instance. /// </summary> private async Task <ICloudTable <SignatureWorkItem> > GetCloudTable() { _cloudTable = _cloudTable ?? await _cloudService.GetTableAsync <SignatureWorkItem>().ConfigureAwait(false); return(_cloudTable); }