Beispiel #1
0
 public ReturnTransitEvent(Transit.RESPONSE obj = null)
 {
     if (obj != null)
     {
         Response = obj;
     }
 }
        private void Ups_OnTransitReturn(object sender, UPS.ReturnTransitEvent e)
        {
            Transit.RESPONSE r = e.Response;

            var code = ShippingMethodDropDownList.Text;

            string sum = "************************\r\n";

            try
            {
                code = (code.Split('-'))[1];
            }
            catch { }
            foreach (var unit in r.Summary)
            {
                var cd = unit.Service.Description.Replace("UPS ", "").Replace(" ", "");
                if (cd == code)
                {
                    try
                    {
                        System.Globalization.CultureInfo provider = new System.Globalization.CultureInfo("en-US");
                        var d = DateTime.ParseExact(unit.EstimatedArrival.Arrival.Date, "yyyyMMdd", provider);
                        ArrivalDate.Value = d.ToShortDateString();
                        string dn = "PM";
                        int    a  = Convert.ToInt32(unit.EstimatedArrival.Arrival.Time);

                        if (a <= 119999)
                        {
                            dn = "AM";
                        }
                        else
                        {
                            a = a - 120000;
                        }
                        var t = a.ToString();
                        t = t.Insert(2, ":");
                        t = t.Insert(5, ":");
                        ArrivalTime.Value = t + " " + dn;
                    }
                    catch { }
                    return;
                }
                sum += unit.Service.Description +
                       "\r\nBusiness Days: "
                       + unit.EstimatedArrival.BusinessDaysInTransit +
                       "\r\nArrival Date: " + unit.EstimatedArrival.Arrival.Date + " @ " + unit.EstimatedArrival.Arrival.Time + "\r\n************************\r\n";
            }
        }