Example #1
0
        public void IDS_Test(int OrderID)
        {
            Packages package = db.Packages.AsNoTracking().First(p => p.OrderID.Value.Equals(OrderID));

            IDS_API   IDS     = new IDS_API(package.Method.Carriers.CarrierAPI);
            var       result  = IDS.GetTrackingNumber(package);
            IDS_Track Track   = new IDS_Track(package.Method.Carriers.CarrierAPI);
            var       result2 = Track.GetTrackingNumber(result);
            //var label = IDS.GetTrackingNumber(package.TrackingNumber);
        }
Example #2
0
        public ActionResult GetSelectOption(List <string> optionType)
        {
            AjaxResult result = new AjaxResult();

            if (optionType.Any())
            {
                var optionList = new Dictionary <string, object>();

                try
                {
                    foreach (string type in optionType)
                    {
                        switch (type)
                        {
                        case "shippingMethod":
                            Method = new GenericRepository <ShippingMethod>(db);
                            optionList.Add(type, Method.GetAll(true).Where(m => m.IsEnable).Select(m => new { text = m.Name, value = m.ID }));
                            break;

                        case "carrier":
                            Carriers = new GenericRepository <Carriers>(db);
                            optionList.Add(type, Carriers.GetAll(true).Where(c => c.IsEnable).Select(c => new
                            {
                                text  = string.Format("{0}【{1}】", c.Name, (c.CarrierAPI != null ? c.CarrierAPI.Name : "無")),
                                value = c.ID,
                                type  = c.CarrierAPI != null ? Enum.GetName(typeof(EnumData.CarrierType), c.CarrierAPI.Type) : ""
                            }).ToList());
                            break;

                        case "methodType":
                            var FedEx_shippingMethod = Enum.GetValues(typeof(FedExShipService.ServiceType)).Cast <FedExShipService.ServiceType>().Select(b => new { text = b.ToString(), value = (int)b }).ToList();

                            Winit_API winit = new Winit_API();
                            List <deliveryWayData> deliveryWay = new List <deliveryWayData>();
                            foreach (var warehouse in winit.warehouseIDs)
                            {
                                deliveryWay.AddRange(winit.GetDeliveryWay(warehouse.Value).data.ToObject <deliveryWayData[]>());
                            }

                            var Winit_shippingMethod = deliveryWay.OrderBy(w => w.deliveryID).Select(w => new { text = w.deliveryWay, value = int.Parse(w.deliveryID) }).Distinct().ToList();

                            IDS_API IDS   = new IDS_API();
                            int     index = 0;
                            var     IDS_shippingMethod = IDS.GetServiceTypeList().Select(s => new { text = s, value = index++ }).ToList();

                            optionList.Add(type, new Dictionary <string, object>()
                            {
                                { "FedEx", FedEx_shippingMethod }, { "DHL", null }, { "Winit", Winit_shippingMethod }, { "IDS", IDS_shippingMethod }
                            });
                            break;

                        case "boxType":
                            var FedEx_boxType = Enum.GetValues(typeof(FedExShipService.PackagingType)).Cast <FedExShipService.PackagingType>().Select(b => new { text = b.ToString(), value = (int)b }).ToList();

                            optionList.Add(type, new Dictionary <string, object>()
                            {
                                { "FedEx", FedEx_boxType }
                            });
                            break;

                        case "carrierApi":
                            CarrierAPI = new GenericRepository <CarrierAPI>(db);
                            List <object> apiList = new List <object>()
                            {
                                new { text = "無", value = 0 }
                            };
                            apiList.AddRange(CarrierAPI.GetAll(true).Where(a => a.IsEnable).Select(a => new { text = a.Name, value = a.Id }));
                            optionList.Add(type, apiList);
                            break;
                        }
                    }

                    result.data = optionList;
                }
                catch (Exception e)
                {
                    result.status  = false;
                    result.message = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }