Esempio n. 1
0
        /// <summary>
        /// Rempli la liste des options de shipping
        /// </summary>
        /// <param name="ville"></param>
        /// <param name="country"></param>
        /// <param name="province"></param>
        /// <param name="postalcode"></param>
        public void CallGetQuickEstimate(string ville,string country,string province, string postalcode)
        {
            EstimatingService service = CreateEstimatingService();
            GetQuickEstimateRequestContainer request = new GetQuickEstimateRequestContainer();
            GetQuickEstimateResponseContainer response = new GetQuickEstimateResponseContainer();

            // Setup the request to perform a create shipment
            //TODO : Define the Billing account and the account that is registered with PWS
            request.BillingAccountNumber = "9999999999";
            //TODO : Populate the Origin Information
            request.SenderPostalCode = "J2S6A6";
            //TODO : Populate the Desination Information
            request.ReceiverAddress = new ShortAddress();
            request.ReceiverAddress.City = ville;
            request.ReceiverAddress.Country = country;
            request.ReceiverAddress.Province = province;
            request.ReceiverAddress.PostalCode = postalcode;
            request.PackageType = "ExpressEnvelope";
            request.TotalWeight = new TotalWeight();
            request.TotalWeight.Value = 1;
            request.TotalWeight.WeightUnit = WeightUnit.lb;

            try
            {
                // Call the service
                response = service.GetQuickEstimate(request);
                int i = 0;
                foreach (ShipmentEstimate sh in response.ShipmentEstimates)
                {
                    DictionaryCollection dc = new DictionaryCollection();
                    dc.DateArrivee = response.ShipmentEstimates[i].ExpectedDeliveryDate;
                    dc.DateDepart = response.ShipmentEstimates[i].ShipmentDate;
                    dc.Prix = response.ShipmentEstimates[i].TotalPrice;
                    dc.ServiceNom = response.ShipmentEstimates[i].ServiceID;
                    // Display the response
                    lstShipping.Add(dc);
                    i++;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
 /// <remarks/>
 public void GetQuickEstimateAsync(GetQuickEstimateRequestContainer GetQuickEstimateRequest, object userState) {
     if ((this.GetQuickEstimateOperationCompleted == null)) {
         this.GetQuickEstimateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetQuickEstimateOperationCompleted);
     }
     this.InvokeAsync("GetQuickEstimate", new object[] {
                 GetQuickEstimateRequest}, this.GetQuickEstimateOperationCompleted, userState);
 }
Esempio n. 3
0
 /// <remarks/>
 public void GetQuickEstimateAsync(GetQuickEstimateRequestContainer GetQuickEstimateRequest) {
     this.GetQuickEstimateAsync(GetQuickEstimateRequest, null);
 }