private ShippingResult USPSTrackingResultWrap(USPSTrackingResult.TrackResponse resultingMessage) { ShippingResult shippingResult = new ShippingResult(); shippingResult.ServiceType = resultingMessage.Items[0].Class; shippingResult.StatusCode = resultingMessage.Items[0].StatusCategory; shippingResult.Status = resultingMessage.Items[0].Status; shippingResult.StatusSummary = resultingMessage.Items[0].StatusSummary; if (resultingMessage.Items[0].Error != null) { if (!string.IsNullOrEmpty(resultingMessage.Items[0].Error.Number.ToString())) { shippingResult.Delivered = false; shippingResult.StatusCode = "Error"; shippingResult.Status = resultingMessage.Items[0].Error.Description; shippingResult.StatusSummary = resultingMessage.Items[0].Error.Description; shippingResult.Message = resultingMessage.Items[0].Error.Description; } } if (!string.IsNullOrEmpty(shippingResult.StatusCode)) { if (shippingResult.StatusCode.ToUpper().Trim() == "DELIVERED") { shippingResult.Delivered = true; foreach (var item in resultingMessage.Items[0].TrackSummary) { if (item.Event.ToUpper().Contains("DELIVERED")) { shippingResult.DeliveredDateTime = item.EventDate + " " + item.EventTime; //by CJ on Oct-05-2016, to have the signatureName. shippingResult.SignatureName = string.IsNullOrEmpty(item.Name) ? "" : item.Name; break; } } } } if (resultingMessage.Items[0].TrackDetail != null) { if (resultingMessage.Items[0].TrackDetail.Length > 0) { foreach (var detail in resultingMessage.Items[0].TrackDetail) { ShippingResultEventDetail eventDetail = new ShippingResultEventDetail(); eventDetail.Event = detail.Event; eventDetail.EventDateTime = detail.EventDate + " " + detail.EventTime; eventDetail.EventAddress = detail.EventCity + " " + detail.EventState + " " + detail.EventZIPCode; shippingResult.TrackingDetails.Add(eventDetail); } } } return(shippingResult); }
private ShippingResult FedExTrackingResultWrap(FedExTrackingResult.TrackReply resultMessage) { ShippingResult shippingResult = new ShippingResult(); if (resultMessage.HighestSeverity == "ERROR") { shippingResult.StatusCode = "ERROR"; shippingResult.Status = resultMessage.Notifications[0].Message; shippingResult.Message = resultMessage.Notifications[0].Message; } else if (resultMessage.HighestSeverity == "SUCCESS") { if (resultMessage.TrackDetails[0].StatusCode.Trim().ToUpper() == "DL") { shippingResult.Delivered = true; } shippingResult.StatusCode = resultMessage.TrackDetails[0].StatusCode; shippingResult.Status = resultMessage.TrackDetails[0].StatusDescription; shippingResult.StatusSummary = resultMessage.TrackDetails[0].StatusDescription; shippingResult.ServiceType = resultMessage.TrackDetails[0].ServiceType; if (shippingResult.Delivered) { shippingResult.DeliveredDateTime = !string.IsNullOrEmpty(resultMessage.TrackDetails[0].ActualDeliveryTimestamp) ? resultMessage.TrackDetails[0].ActualDeliveryTimestamp : ""; // by CJ on Oct-05-2016 to include Signature. shippingResult.SignatureName = !string.IsNullOrEmpty(resultMessage.TrackDetails[0].DeliverySignatureName) ? resultMessage.TrackDetails[0].DeliverySignatureName : ""; } else { shippingResult.ScheduledDeliveryDate = !string.IsNullOrEmpty(resultMessage.TrackDetails[0].EstimatedDeliveryTimestamp) ? resultMessage.TrackDetails[0].EstimatedDeliveryTimestamp : ""; } if (resultMessage.TrackDetails[0].Events != null) { if (resultMessage.TrackDetails[0].Events.Length > 0) { foreach (var detail in resultMessage.TrackDetails[0].Events) { ShippingResultEventDetail eventDetail = new ShippingResultEventDetail(); eventDetail.Event = detail.EventType + " " + detail.EventDescription;; eventDetail.EventDateTime = detail.Timestamp; if (detail.Address != null) { eventDetail.EventAddress = detail.Address[0].City + " " + detail.Address[0].StateOrProvinceCode + " " + detail.Address[0].PostalCode; } shippingResult.TrackingDetails.Add(eventDetail); } } } } return(shippingResult); }