2

我希望在我自己的数据库中缓存所有 Fedex 跟踪信息,我的公司每天有大约 150 多个跟踪号码。根据这个链接...

   http://www.fedex.com/us/developer/product/WebServices/MyWebHelp_August2010/Content/Proprietary_Developer_Guide/tTracking_and_Visibility_Services_condtionalized.htm

Fedex 服务不支持批处理..?这是否意味着我需要为每个跟踪号打一次电话?我花了大约 80 秒的时间来完成一天的销售……

目前没有更好的选择吗?或者有没有更好的方法或过程来做到这一点?

4

2 回答 2

0

使用此代码希望它会帮助你

TrackRequest request = CreateFedexMultipleTrackRequest(TrackingCode);
 TrackService service = new TrackService();
 TrackReply reply = service.track(request);
 if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
 {
   reply.CompletedTrackDetails//now manage All tracking As Your Need
 }
 //go to How to create single request for multiple tracking numbers at a time
 private static TrackRequest CreateFedexMultipleTrackRequest(string TrackingNumber)
    {
        //string[] str = new string[] {TrackingNumber};
        string[] staticIntArray = TrackingNumber.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        //int arraycount = staticIntArray.Count();
        TrackRequest request = new TrackRequest();
        request.WebAuthenticationDetail = new WebAuthenticationDetail();
        request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.UserCredential.Key = Application.FedexKey;
        request.WebAuthenticationDetail.UserCredential.Password = Application.FedexPassword;
        request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.ParentCredential.Key = Application.FedexKey;
        request.WebAuthenticationDetail.ParentCredential.Password = Application.FedexPassword;
        request.ClientDetail = new ClientDetail();
        request.ClientDetail.AccountNumber = Application.FedexAccountNumber;
        request.ClientDetail.MeterNumber = Application.FedexMeterNumber;
        request.TransactionDetail = new TransactionDetail();
        request.TransactionDetail.CustomerTransactionId = "NA";  //This is a reference field for the customer.  Any value can be used and will be provided in the response.
        request.Version = new VersionId();
        // Tracking information
        request.SelectionDetails = new TrackSelectionDetail[staticIntArray.Length];
        for (int j = 0; j <= staticIntArray.Length - 1; j++) { request.SelectionDetails[j] = new TrackSelectionDetail(); }
        for (int i = 0; i <= staticIntArray.Length - 1; i++)
        {
            request.SelectionDetails[i].PackageIdentifier = new TrackPackageIdentifier();
            request.SelectionDetails[i].PackageIdentifier.Value = staticIntArray[i]; //tracking number or door tag
            request.SelectionDetails[i].PackageIdentifier.Type = TrackIdentifierType.DOCUMENT_AIRWAY_BILL;
            request.SelectionDetails[i].ShipmentAccountNumber = "XXX";
            // Date range is optional.
            // If omitted, set to false
            request.SelectionDetails[i].ShipDateRangeBegin = DateTime.Parse("05/09/2016"); //MM/DD/YYYY
            request.SelectionDetails[i].ShipDateRangeEnd = request.SelectionDetails[0].ShipDateRangeBegin.AddDays(0);
            request.SelectionDetails[i].ShipDateRangeBeginSpecified = true;
            request.SelectionDetails[i].ShipDateRangeEndSpecified = true;
        }
        // Include detailed scans is optional.
        // If omitted, set to false
        request.ProcessingOptions = new TrackRequestProcessingOptionType[1];
        request.ProcessingOptions[0] = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS;
        return request;
    }

//您可以在fedex中一次跟踪30个号码

于 2017-10-26T10:15:20.217 回答
-1

是的,您需要将每个曲目作为单独的请求发送。通过计划将其作为服务器端进程运行,谁在乎需要多长时间!?

于 2014-04-25T14:07:50.403 回答