예제 #1
0
        private void Update_Carrier()
        {
            int[] OrderIDs = new int[] { 5453707, 5453746, 5453757, 5453766, 5453775, 5453802, 5453835, 5453902, 5453909, 5453928, 5453929, 5453950, 5453955, 5453958, 5453962, 5454001, 5454002, 5454022, 5454029, 5454030, 5454046, 5454047, 5454089, 5453707, 5454090, 5454091, 5454098, 5454099, 5454167, 5454171, 5454173, 5454175, 5454180, 5454181, 5454182, 5454183, 5454184, 5454186, 5454189, 5454190, 5454191, 5454192, 5454193, 5454195, 5454196, 5454197, 5454200, 5454219 };

            SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString());

            using (IRepository <Packages> Packages = new GenericRepository <Packages>(db))
            {
                foreach (int orderID in OrderIDs)
                {
                    OrderService.OrderData orderData = SCWS.Get_OrderData(orderID);
                    OrderService.Order     SC_order  = orderData.Order;
                    string shippingCarrier           = SC_order.ShippingCarrier;

                    Packages package            = Packages.GetAll().First(p => p.OrderID.Value.Equals(orderID));
                    string   newShippingCarrier = package.Method.Carriers.Name;

                    if (!shippingCarrier.Equals(newShippingCarrier))
                    {
                        SCWS.Update_OrderShippingStatus(SC_order, newShippingCarrier);
                        Response.Write(string.Format("Order【{0}】Carrier - {1} change to Carrier - {2}", orderID, shippingCarrier, newShippingCarrier));
                    }

                    package.Orders.ShippingCarrier = newShippingCarrier;
                    Packages.Update(package);
                }
                Packages.SaveChanges();
            }
        }
예제 #2
0
        public void Index()
        {
            SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString());

            Orders order = db.Orders.Find(5622262);

            OrderService.OrderData orderData = SCWS.Get_OrderData(order.OrderID);
            Order SC_order = orderData.Order;
        }
예제 #3
0
        private void Update_Warehouse()
        {
            int[] OrderIDs = new int[] { 5455086, 5455090, 5455158, 5455216 };

            SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString());

            using (IRepository <Items> Items = new GenericRepository <Items>(db))
            {
                foreach (int orderID in OrderIDs)
                {
                    OrderService.OrderData orderData = SCWS.Get_OrderData(orderID);
                    OrderService.Order     SC_order  = orderData.Order;

                    var SC_items = SC_order.Items.ToArray();
                    foreach (var item in SC_items)
                    {
                        item.ShipFromWareHouseID = 111;
                    }
                    SCWS.Update_OrderItem(SC_items);
                }
            }
        }
예제 #4
0
        private void BingMap_Test()
        {
            using (SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString()))
            {
                var SC_order = SCWS.Get_OrderData(5481021);
                var address  = DataProcess.SetAddressData(new Addresses()
                {
                }, SC_order.Order.ShippingAddressOriginal, SC_order.Order.BillingAddress);

                BingMapsRESTToolkit.GeocodeRequest request = new BingMapsRESTToolkit.GeocodeRequest();
                request.BingMapsKey = "AlN5NYeihAOh4srrmzv0D3NI8uPonD4yOw-_5ssdHnaxuCE11asVp6M2o4j5PtuI";
                request.Address     = new BingMapsRESTToolkit.SimpleAddress()
                {
                    CountryRegion = address.CountryCode,
                    PostalCode    = address.PostalCode,
                    AdminDistrict = !string.IsNullOrEmpty(address.City) ? address.City : address.StateName,
                    Locality      = address.StreetLine1,
                    AddressLine   = address.StreetLine2
                };

                BingMapsRESTToolkit.Response response = request.Execute().Result;
            }
        }
예제 #5
0
파일: OrderPreset.cs 프로젝트: leeleonis/QD
        private void Dispatch(Packages package)
        {
            if (Order.StatusCode.Value.Equals((int)OrderStatusCode.InProcess) && Order.PaymentStatus.Equals((int)OrderPaymentStatus.Charged))
            {
                ThreadTask threadTask = new ThreadTask(string.Format("訂單下載 - 自動提交訂單【{0}】至待出貨區", Order.OrderID), Session);
                MyHelp.Log("Orders", Order.OrderID, string.Format("訂單下載 - 自動提交訂單【{0}】至待出貨區", Order.OrderID), Session);

                package.ProcessStatus = (int)EnumData.ProcessStatus.鎖定中;
                Packages.Update(package, package.ID);

                lock (Factory)
                {
                    threadTask.AddWork(Factory.StartNew(Session =>
                    {
                        threadTask.Start();

                        string message = "";
                        using (QDLogisticsEntities db = new QDLogisticsEntities())
                        {
                            IRepository <Packages> Packages       = new GenericRepository <Packages>(db);
                            IRepository <PickProduct> PickProduct = new GenericRepository <PickProduct>(db);

                            Packages packageData = Packages.Get(package.ID);

                            try
                            {
                                HttpSessionStateBase session = (HttpSessionStateBase)Session;
                                SC_WebService SCWS           = new SC_WebService("*****@*****.**", "timfromweypro");

                                if (!SCWS.Is_login)
                                {
                                    throw new Exception("SC is not login");
                                }

                                OrderStateInfo order = SCWS.Get_OrderStatus(packageData.OrderID.Value);

                                if ((int)order.PaymentStatus == package.Orders.PaymentStatus)
                                {
                                    ShipProcess shipProcess = new ShipProcess(SCWS);

                                    MyHelp.Log("Orders", packageData.OrderID, "提交至待出貨區", session);

                                    /***** 上傳Item出貨倉 *****/
                                    var SC_order = SCWS.Get_OrderData(packageData.OrderID.Value).Order;
                                    var SC_items = SC_order.Items.Where(i => i.PackageID.Equals(packageData.ID)).ToArray();
                                    foreach (var item in SC_items)
                                    {
                                        if (!db.Skus.AsNoTracking().Any(s => s.Sku.Equals(item.ProductID)))
                                        {
                                            throw new Exception(string.Format("系統尚未有品號 {0} 資料!", item.ProductID));
                                        }

                                        item.ShipFromWareHouseID = packageData.Items.First(i => i.IsEnable == true && i.ID == item.ID).ShipFromWarehouseID.Value;
                                        SCWS.Update_OrderItem(SC_items.First(i => i.ID.Equals(item.ID)));
                                    }
                                    MyHelp.Log("Orders", packageData.OrderID, "更新訂單包裹的出貨倉", session);

                                    /***** 更新客戶地址 *****/
                                    var address = SC_order.ShippingAddress;
                                    DataProcess.SetAddressData(packageData.Orders.Addresses, address, SC_order.BillingAddress);

                                    /***** 檢查運送國家 *****/
                                    if (!string.IsNullOrEmpty(packageData.Method.CountryData))
                                    {
                                        var countryData = JsonConvert.DeserializeObject <Dictionary <string, bool> >(packageData.Method.CountryData);
                                        if (!countryData.ContainsKey(packageData.Orders.Addresses.CountryCode.ToUpper()))
                                        {
                                            throw new Exception(string.Format("訂單【{0}】國家名稱不合,請重新確認", packageData.OrderID));
                                        }

                                        if (!countryData[packageData.Orders.Addresses.CountryCode.ToUpper()])
                                        {
                                            throw new Exception(string.Format("訂單【{0}】不可寄送至國家{1}", packageData.OrderID, packageData.Orders.Addresses.CountryName));
                                        }
                                    }

                                    shipProcess.Init(packageData);
                                    var result = shipProcess.Dispatch();

                                    if (result.Status)
                                    {
                                        MyHelp.Log("Orders", packageData.OrderID, "訂單提交完成", session);

                                        if (packageData.Items.First(i => i.IsEnable.Value).ShipWarehouses.Name.Equals("TWN"))
                                        {
                                            int[] itemIDs = packageData.Items.Where(i => i.IsEnable.Value).Select(i => i.ID).ToArray();
                                            List <PickProduct> pickList = PickProduct.GetAll(true).Where(p => itemIDs.Contains(p.ItemID.Value)).ToList();
                                            foreach (Items item in packageData.Items.Where(i => i.IsEnable == true))
                                            {
                                                PickProduct pick = pickList.FirstOrDefault(pk => pk.ItemID == item.ID);

                                                if (pick != null)
                                                {
                                                    pick.IsEnable  = true;
                                                    pick.IsPicked  = false;
                                                    pick.IsMail    = false;
                                                    pick.QtyPicked = 0;
                                                    DataProcess.setPickProductData(pick, item);
                                                    PickProduct.Update(pick, pick.ID);
                                                }
                                                else
                                                {
                                                    pick = new PickProduct()
                                                    {
                                                        IsEnable = true
                                                    };
                                                    DataProcess.setPickProductData(pick, item);
                                                    PickProduct.Create(pick);
                                                }
                                            }
                                            PickProduct.SaveChanges();
                                        }

                                        packageData.ProcessStatus = (int)EnumData.ProcessStatus.待出貨;
                                    }
                                    else
                                    {
                                        message = result.Message;
                                        packageData.ProcessStatus = (int)EnumData.ProcessStatus.訂單管理;
                                    }
                                }
                                else
                                {
                                    message = "Payment status is different";
                                    packageData.Orders.StatusCode = (int)OrderStatusCode.OnHold;
                                    packageData.ProcessStatus     = (int)EnumData.ProcessStatus.訂單管理;
                                }

                                Packages.Update(packageData, packageData.ID);
                                Packages.SaveChanges();
                            }
                            catch (Exception e)
                            {
                                message = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
                                packageData.ProcessStatus = (int)EnumData.ProcessStatus.訂單管理;

                                if (!string.IsNullOrEmpty(package.WinitNo))
                                {
                                    Winit_API winit = new Winit_API();
                                    winit.CancelOutboundOrder(package.WinitNo);
                                    package.WinitNo = null;
                                }

                                Packages.Update(packageData, packageData.ID);
                                Packages.SaveChanges();
                            }
                        }

                        return(message);
                    }, Session));
                }
            }
        }
예제 #6
0
        public string Sync_Orders(int day)
        {
            string Message = "";

            try
            {
                MyHelp.Log("Orders", null, string.Format("同步{0}天訂單資料", day), Session);

                if (!SCWS.Is_login)
                {
                    throw new Exception("SC is not logged in!");
                }

                OrderStateInfo[] SC_OrderStateInfoList = SCWS.Search_Order(Today.AddDays(-day), Today);

                if (!SC_OrderStateInfoList.Any())
                {
                    throw new Exception("Not found order!");
                }

                List <Orders> orderList         = Orders.GetAll(true).Where(o => SC_OrderStateInfoList.Select(info => info.ID).ToArray().Contains(o.OrderID)).ToList();
                List <Order>  SC_Orders         = new List <Order>();
                List <int>    presetList        = new List <int>();
                int[]         dropshipWarehouse = db.Warehouses.Where(w => w.IsEnable.Value && w.WarehouseType.Value.Equals((int)WarehouseTypeType.DropShip)).Select(w => w.ID).ToArray();

                List <OrderSerialNumber> SC_SerialNumbers = new List <OrderSerialNumber>();

                int[] ignoreOrderIDs = new int[] { };
                foreach (OrderStateInfo orderStateInfo in SC_OrderStateInfoList.Where(o => o.DropShipStatus == DropShipStatusType2.None && !ignoreOrderIDs.Contains(o.ID)))
                {
                    OrderData order = SCWS.Get_OrderData(orderStateInfo.ID);
                    SC_Orders.Add(order.Order);

                    if (!orderList.Any(o => o.OrderID.Equals(orderStateInfo.ID)))
                    {
                        Addresses address = new Addresses()
                        {
                            IsEnable = true
                        };
                        Addresses.Create(address);
                        Addresses.SaveChanges();

                        orderData = new Orders()
                        {
                            OrderID = orderStateInfo.ID, ShippingAddress = address.Id, eBayUserID = order.User.eBayUserID
                        };
                        Orders.Create(orderData);
                        Orders.SaveChanges();

                        orderList.Add(orderData);
                        SC_SerialNumbers.AddRange(order.Serials);

                        presetList.Add(orderData.OrderID);
                    }
                    else
                    {
                        if (orderList.Any(o => o.OrderID.Equals(orderStateInfo.ID) && (!o.StatusCode.Equals((int)OrderStatusCode.InProcess) || !o.PaymentStatus.Equals((int)OrderPaymentStatus1.Charged))))
                        {
                            if (orderStateInfo.StatusCode.Equals(OrderStatusCode.InProcess) && orderStateInfo.PaymentStatus.Equals(OrderPaymentStatus1.Charged))
                            {
                                presetList.Add(order.Order.ID);
                            }
                        }

                        if (db.Packages.AsNoTracking().Any(p => p.IsEnable.Value && p.OrderID.Value.Equals(orderStateInfo.ID) && !p.ProcessStatus.Equals((byte)EnumData.ProcessStatus.待出貨) && !p.ProcessStatus.Equals((byte)EnumData.ProcessStatus.保留中)))
                        {
                            if (db.Items.AsNoTracking().Any(i => i.IsEnable.Value && i.OrderID.Value.Equals(orderStateInfo.ID) && !(dropshipWarehouse.Contains(i.ShipFromWarehouseID.Value) && i.SerialNumbers.Any())))
                            {
                                SC_SerialNumbers.AddRange(order.Serials);
                            }
                        }
                    }
                }


                List <Orders> orderDatas = orderList.Where(o => SC_Orders.Select(order => order.ID).Contains(o.OrderID)).ToList();
                Check_Order(orderDatas, SC_Orders);
                Orders.SaveChanges();

                List <Payments> paymentDatas = orderDatas.SelectMany(o => o.Payments.Where(p => p.IsEnable.Equals(true))).ToList();
                Check_Payment(paymentDatas, SC_Orders.SelectMany(o => o.Payments).ToList());
                Orders.SaveChanges();

                int[]           PackageIDs   = SC_Orders.SelectMany(o => o.Items).Select(i => i.PackageID).Distinct().ToArray();
                List <Packages> packageDatas = orderDatas.SelectMany(o => o.Packages.Where(p => p.IsEnable.Equals(true))).ToList();
                Check_Package(packageDatas, SC_Orders.SelectMany(o => o.Packages).Where(p => PackageIDs.Contains(p.ID)).ToList());
                Orders.SaveChanges();

                List <Items> itemDatas = packageDatas.SelectMany(p => p.Items.Where(i => i.IsEnable.Equals(true))).ToList();
                Check_Item(itemDatas, SC_Orders.SelectMany(o => o.Items).ToList());
                Orders.SaveChanges();

                int[] OrderIDs = packageDatas.Where(p => !p.ProcessStatus.Equals((byte)EnumData.ProcessStatus.待出貨) && !p.ProcessStatus.Equals((byte)EnumData.ProcessStatus.保留中))
                                 .SelectMany(p => p.Items.Where(i => !dropshipWarehouse.Contains(i.ShipFromWarehouseID.Value))).Select(i => i.OrderID.Value).ToArray();
                List <SerialNumbers> serialNumberDatas = SerialNumbers.GetAll().Where(serial => OrderIDs.Contains(serial.OrderID.Value)).ToList();
                Check_Serial(serialNumberDatas, SC_SerialNumbers);
                Orders.SaveChanges();

                foreach (OrderStateInfo orderStateInfo in SC_OrderStateInfoList.Where(o => o.DropShipStatus != DropShipStatusType2.None))
                {
                    if (orderList.Any(o => o.OrderID.Equals(orderStateInfo.ID)))
                    {
                        orderStateInfo.StatusCode = OrderStatusCode.Completed;
                        orderData = orderList.First(o => o.OrderID.Equals(orderStateInfo.ID));
                        Update_OrderState(orderData, orderStateInfo);
                        Orders.Update(orderData);
                    }
                }

                Orders.SaveChanges();
                MyHelp.Log("Orders", null, "訂單資料同步完成", Session);

                if (presetList.Any())
                {
                    using (OrderPreset preset = new OrderPreset(Session))
                    {
                        preset.Factory = this.Factory;
                        using (StockKeepingUnit Stock = new StockKeepingUnit())
                        {
                            foreach (int OrderID in presetList)
                            {
                                preset.Init(OrderID);
                                preset.Save();

                                try
                                {
                                    Stock.RecordOrderSkuStatement(OrderID, "New");
                                    Stock.OrderSyncPush(OrderID);
                                }
                                catch (Exception e)
                                {
                                    string errorMsg = string.Format("傳送訂單狀態至PO系統失敗,請通知處理人員:{0}", e.InnerException != null ? e.InnerException.Message.Trim() : e.Message.Trim());
                                    MyHelp.Log("SkuStatement", OrderID, string.Format("訂單【{0}】{1}", OrderID, errorMsg), Session);
                                }
                            }
                        }
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                Message = string.Join("; ", errorMessages);
            }
            catch (Exception e)
            {
                MyHelp.ErrorLog(e, string.Format("同步{0}天訂單資料失敗", day));
                Message = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
            }

            return(Message);
        }
예제 #7
0
        public ActionResult Dispatch(int[] packageIDs, int?method, string tracking)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                if (!packageIDs.Any())
                {
                    throw new Exception("沒有給訂單!");
                }

                int warehouseID = 0;
                if (!int.TryParse(Session["warehouseId"].ToString(), out warehouseID))
                {
                    throw new Exception("找不到出貨倉!");
                }

                SC_WebService SCWS = new SC_WebService(Session["ApiUserName"].ToString(), Session["ApiPassword"].ToString());

                if (!SCWS.Is_login)
                {
                    throw new Exception("SC is not login");
                }

                Packages = new GenericRepository <Packages>(db);
                IRepository <Box>             Box   = new GenericRepository <Box>(db);
                IRepository <DirectLineLabel> Label = new GenericRepository <DirectLineLabel>(db);

                TaskFactory factory    = System.Web.HttpContext.Current.Application.Get("TaskFactory") as TaskFactory;
                ThreadTask  threadTask = new ThreadTask("Dropship DL 訂單 Dispatch");

                lock (factory)
                {
                    threadTask.AddWork(factory.StartNew(Session =>
                    {
                        threadTask.Start();

                        string message = "";

                        HttpSessionStateBase session = (HttpSessionStateBase)Session;

                        try
                        {
                            TimeZoneConvert timeZoneConvert = new TimeZoneConvert();

                            List <Packages> dispatchList = new List <Packages>();
                            List <string> errorList      = new List <string>();

                            List <Packages> packageList = db.Packages.AsNoTracking().Where(p => p.IsEnable.Value && packageIDs.Contains(p.ID)).ToList();
                            DirectLine directLine       = db.DirectLine.Find(packageList[0].Method.DirectLine);
                            string boxID = string.Format("{0}-{1}", directLine.Abbreviation, timeZoneConvert.Utc.ToString("yyyyMMdd"));
                            int count    = db.Box.Where(b => b.IsEnable && b.DirectLine.Equals(directLine.ID) && b.BoxID.Contains(boxID)).Select(b => b.MainBox).Distinct().Count() + 1;
                            byte[] Byte  = BitConverter.GetBytes(count);
                            Byte[0]     += 64;
                            boxID        = string.Format("{0}-{1}", boxID, System.Text.Encoding.ASCII.GetString(Byte.Take(1).ToArray()));

                            foreach (Packages package in packageList)
                            {
                                DirectLineLabel label = package.Label;
                                OrderData order       = SCWS.Get_OrderData(package.OrderID.Value);
                                if (CheckOrderStatus(package, order.Order))
                                {
                                    ThreadTask uploadPOTask = new ThreadTask(string.Format("直發商待出貨區 - 更新訂單【{0}】以及PO【{1}】資料至SC", package.OrderID, package.POId), session);

                                    lock (factory)
                                    {
                                        uploadPOTask.AddWork(factory.StartNew(() =>
                                        {
                                            uploadPOTask.Start();

                                            string error = "";

                                            try
                                            {
                                                SyncProcess Sync = new SyncProcess(session, factory);
                                                error            = Sync.Update_PurchaseOrder(package.ID, false);

                                                if (string.IsNullOrEmpty(error))
                                                {
                                                    //if (directLine.Abbreviation.Equals("ECOF"))
                                                    //{
                                                    //    ThreadTask SyncTask = new ThreadTask(string.Format("Direct Line 訂單【{0}】SC更新", package.OrderID));
                                                    //    SyncTask.AddWork(factory.StartNew(() =>
                                                    //    {
                                                    //        SyncTask.Start();
                                                    //        SyncProcess sync = new SyncProcess(session);
                                                    //        return sync.Update_Tracking(package);
                                                    //    }));
                                                    //}
                                                    //else
                                                    //{
                                                    //    foreach (Items item in package.Items.Where(i => i.IsEnable.Value).ToList())
                                                    //    {
                                                    //        if (item.SerialNumbers.Any()) SCWS.Update_ItemSerialNumber(item.ID, item.SerialNumbers.Select(s => s.SerialNumber).ToArray());
                                                    //    }
                                                    //}

                                                    foreach (Items item in package.Items.Where(i => i.IsEnable.Value).ToList())
                                                    {
                                                        if (item.SerialNumbers.Any())
                                                        {
                                                            SCWS.Update_ItemSerialNumber(item.ID, item.SerialNumbers.Select(s => s.SerialNumber).ToArray());
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception e)
                                            {
                                                error = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
                                            }

                                            return(error);
                                        }));
                                    }

                                    package.ProcessStatus = (int)EnumData.ProcessStatus.已出貨;
                                    package.BoxID         = label.BoxID = boxID;
                                    label.Status          = (byte)EnumData.LabelStatus.正常;
                                    dispatchList.Add(package);
                                }
                                else
                                {
                                    MyHelp.Log("DirectLineLabel", label.LabelID, string.Format("標籤【{0}】狀態異常", label.LabelID), session);

                                    package.Orders.StatusCode    = (int)order.Order.StatusCode;
                                    package.Orders.PaymentStatus = (int)order.Order.PaymentStatus;
                                    label.Status = (byte)EnumData.LabelStatus.鎖定中;

                                    if (order.Order.StatusCode.Equals((int)OrderStatusCode.Canceled))
                                    {
                                        label.Status = (byte)EnumData.LabelStatus.作廢;

                                        SerialNumbers = new GenericRepository <SerialNumbers>(db);
                                        foreach (var ss in SerialNumbers.GetAll().Where(s => s.OrderID.Equals(package.OrderID)))
                                        {
                                            SerialNumbers.Delete(ss);
                                        }
                                        ;
                                    }

                                    errorList.Add(string.Format("標籤【{0}】狀態異常,請重新取出!", package.OrderID.Value));
                                }
                                Packages.Update(package, package.ID);
                                Label.Update(label, label.LabelID);
                            }

                            if (dispatchList.Any())
                            {
                                Box box = new Box()
                                {
                                    IsEnable        = true,
                                    BoxID           = boxID,
                                    MainBox         = boxID,
                                    DirectLine      = directLine.ID,
                                    FirstMileMethod = method ?? 0,
                                    WarehouseFrom   = warehouseID,
                                    ShippingStatus  = method.HasValue ? (byte)EnumData.DirectLineStatus.運輸中 : (byte)EnumData.DirectLineStatus.已到貨,
                                    BoxType         = (byte)EnumData.DirectLineBoxType.DirectLine,
                                    TrackingNumber  = tracking,
                                    Create_at       = timeZoneConvert.Utc
                                };
                                db.Entry(box).State = System.Data.Entity.EntityState.Added;

                                db.SaveChanges();
                                MyHelp.Log("Box", boxID, string.Format("Box【{0}】建立成功", boxID), session);

                                MyHelp.Log("Box", box.BoxID, string.Format("寄送 Box【{0}】DL資料", box.BoxID), session);
                                SendMailToCarrier(box, db.DirectLine.AsNoTracking().First(d => d.ID.Equals(box.DirectLine)));

                                MyHelp.Log("Box", box.BoxID, string.Format("Box【{0}】完成出貨", box.BoxID), session);
                            }

                            Packages.SaveChanges();

                            if (errorList.Any())
                            {
                                message = string.Join("\n", errorList.ToArray());
                            }
                        }
                        catch (Exception e)
                        {
                            message = e.InnerException != null && !string.IsNullOrEmpty(e.InnerException.Message) ? e.InnerException.Message : e.Message;
                        }

                        return(message);
                    }, HttpContext.Session));
                }
            }
            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));
        }