コード例 #1
0
 public Task <KnownTrackingResponse> KnownAWBTrackingAsync(List <string> AWBs
                                                           , Enums.LevelOfDetails levelOfDetails           = Enums.LevelOfDetails.AllCheckpoints
                                                           , Enums.PiecesEnabled detailsRequested          = Enums.PiecesEnabled.ShipmentOnly
                                                           , Enums.EstimatedDeliveryDateEnabled eddEnabled = Enums.EstimatedDeliveryDateEnabled.No)
 {
     return(Task.Run(() => KnownAWBTracking(AWBs, levelOfDetails, detailsRequested, eddEnabled)));
 }
コード例 #2
0
        // ReSharper disable once InconsistentNaming
        public KnownTrackingResponse KnownAWBTracking(List <string> AWBs
                                                      , Enums.LevelOfDetails levelOfDetails           = Enums.LevelOfDetails.AllCheckpoints
                                                      , Enums.PiecesEnabled detailsRequested          = Enums.PiecesEnabled.ShipmentOnly
                                                      , Enums.EstimatedDeliveryDateEnabled eddEnabled = Enums.EstimatedDeliveryDateEnabled.No)
        {
            KnownTrackingRequest ktr = new KnownTrackingRequest
            {
                Request = new Request
                {
                    ServiceHeader = new ServiceHeader()
                },
                AWBNumber      = new AWBNumber(AWBs),
                PiecesEnabled  = detailsRequested,
                LevelOfDetails = levelOfDetails,
                EstimatedDeliveryDateEnabled = eddEnabled
            };
            //foreach (string awb in AWBs)
            //{
            //    ktr.AWBNumber.ArrayOfAWBNumberItem.Add(new AWBNumber(awb));
            //}

            // Validate the request

            List <ValidationResult> validationResult = Common.Validate(ref ktr);

            if (validationResult.Any())
            {
                throw new GloWSValidationException(validationResult);
            }

            LastJSONRequest  = JsonConvert.SerializeObject(KnownTrackingRequest.DecorateRequest(ktr), Formatting.Indented);
            LastJSONResponse = SendRequestAndReceiveResponse(LastJSONRequest, "TrackingRequest");

            KnownTrackingResponse retval;

            try
            {
                // Deserialize the result back to an object.
                List <string> errors = new List <string>();

                retval = JsonConvert.DeserializeObject <KnownTrackingResponse>(LastJSONResponse, new JsonSerializerSettings()
                {
                    Error = delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
                    {
                        errors.Add(args.ErrorContext.Error.Message);
                        args.ErrorContext.Handled = true;
                    }
                });
            }
            catch
            {
                retval = new KnownTrackingResponse();
            }

            return(retval);
        }