public static void EbayUploadTrackCode(string account, KeWeiOMS.Domain.OrderType orderType)
        {
            ISession NSession = NhbHelper.OpenSession();
            Dictionary <string, int> sendNum  = new Dictionary <string, int>();
            IList <AccountType>      accounts = NSession.CreateQuery("from AccountType where AccountName='" + account + "'").SetMaxResults(1).
                                                List <AccountType>();

            if (accounts.Count > 0)
            {
                IList <KeWeiOMS.Domain.OrderType> orderList = new List <KeWeiOMS.Domain.OrderType>();
                if (orderType.IsMerger == 1 || orderType.OrderExNo.IndexOf("|") != -1)
                {
                    orderList = NSession.CreateQuery("from OrderType where MId='" + orderType.Id + "' Or Id ='" + orderType.Id + "'").List <KeWeiOMS.Domain.OrderType>();
                }
                else
                {
                    orderList.Add(orderType);
                }
                ApiContext context = GetGenericApiContext("US");

                context.ApiCredential.eBayToken = accounts[0].ApiToken;
                eBay.Service.Call.CompleteSaleCall call = null;
                string CarrierUsed = "";
                // IList<logisticsSetupType> setups = NSession.CreateQuery("from  logisticsSetupType where LId in (select ParentID from LogisticsModeType where LogisticsCode='" + orderType.LogisticMode + "')").List<logisticsSetupType>();
                //if (setups != null)
                //{
                //    CarrierUsed = setups[0].SetupName;
                //}
                CarrierUsed = "China Post";
                call        = new eBay.Service.Call.CompleteSaleCall(context);
                foreach (KeWeiOMS.Domain.OrderType order in orderList)
                {
                    string orderid = "";
                    string itemid  = "";

                    if (order.OrderExNo.IndexOf("-") == -1)
                    {
                        orderid = order.OrderExNo;

                        GetOrdersCall       apicall = new GetOrdersCall(context);
                        OrderTypeCollection orders  = null;
                        try
                        {
                            orders = apicall.GetOrders(new StringCollection {
                                order.OrderExNo
                            });
                        }
                        catch (Exception)
                        {
                            orders = new OrderTypeCollection();
                        }

                        if (orders.Count > 0)
                        {
                            foreach (TransactionType trans in orders[0].TransactionArray)
                            {
                                itemid        = trans.Item.ItemID;
                                orderid       = trans.TransactionID;
                                call.Shipment = new ShipmentType();
                                call.Shipment.DeliveryStatus          = eBay.Service.Core.Soap.ShipmentDeliveryStatusCodeType.Delivered;
                                call.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection();

                                if (orderType.OrderNo == order.TrackCode || order.TrackCode == "" || order.TrackCode == null)
                                {
                                    //call.Shipment.ShipmentTrackingNumber = "";
                                }
                                else
                                {
                                    call.Shipment.ShippingCarrierUsed    = CarrierUsed;
                                    call.Shipment.ShipmentTrackingNumber = orderType.TrackCode.ToString();
                                }
                                call.Shipment.DeliveryDate          = DateTime.Now;
                                call.Shipment.DeliveryDateSpecified = true;
                                call.Shipment.DeliveryStatus        = ShipmentDeliveryStatusCodeType.Delivered;
                                try
                                {
                                    call.CompleteSale(itemid, orderid, true, true);
                                }
                                catch (Exception ex)
                                {
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        itemid        = order.OrderExNo.Substring(0, order.OrderExNo.IndexOf("-"));
                        orderid       = order.OrderExNo.Substring(order.OrderExNo.IndexOf("-") + 1);
                        call.Shipment = new ShipmentType();
                        call.Shipment.DeliveryStatus          = eBay.Service.Core.Soap.ShipmentDeliveryStatusCodeType.Delivered;
                        call.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection();
                        if (orderType.OrderNo == order.TrackCode || order.TrackCode == "" || order.TrackCode == null)
                        {
                            //call.Shipment.ShipmentTrackingNumber = "";
                        }
                        else
                        {
                            call.Shipment.ShippingCarrierUsed    = CarrierUsed;
                            call.Shipment.ShipmentTrackingNumber = orderType.TrackCode.ToString();
                        }

                        call.Shipment.DeliveryDate          = DateTime.Now;
                        call.Shipment.DeliveryDateSpecified = true;
                        call.Shipment.DeliveryStatus        = ShipmentDeliveryStatusCodeType.Delivered;
                        try
                        {
                            call.CompleteSale(itemid, orderid, true, true);
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        finally
                        {
                        }
                    }
                }
            }
        }
        public static void EbayUploadTrackCode(string account, KeWeiOMS.Domain.OrderType orderType)
        {
            ISession NSession = NhbHelper.OpenSession();
            Dictionary<string, int> sendNum = new Dictionary<string, int>();
            IList<AccountType> accounts = NSession.CreateQuery("from AccountType where AccountName='" + account + "'").SetMaxResults(1).
                    List<AccountType>();
            if (accounts.Count > 0)
            {

                IList<KeWeiOMS.Domain.OrderType> orderList = new List<KeWeiOMS.Domain.OrderType>();
                if (orderType.IsMerger == 1 || orderType.OrderExNo.IndexOf("|") != -1)
                {
                    orderList = NSession.CreateQuery("from OrderType where MId='" + orderType.Id + "' Or Id ='" + orderType.Id + "'").List<KeWeiOMS.Domain.OrderType>();
                }
                else
                {
                    orderList.Add(orderType);
                }
                ApiContext context = GetGenericApiContext("US");

                context.ApiCredential.eBayToken = accounts[0].ApiToken;
                eBay.Service.Call.CompleteSaleCall call = null;
                string CarrierUsed = "";
                // IList<logisticsSetupType> setups = NSession.CreateQuery("from  logisticsSetupType where LId in (select ParentID from LogisticsModeType where LogisticsCode='" + orderType.LogisticMode + "')").List<logisticsSetupType>();
                //if (setups != null)
                //{
                //    CarrierUsed = setups[0].SetupName;
                //}
                CarrierUsed = "China Post";
                call = new eBay.Service.Call.CompleteSaleCall(context);
                foreach (KeWeiOMS.Domain.OrderType order in orderList)
                {
                    string orderid = "";
                    string itemid = "";

                    if (order.OrderExNo.IndexOf("-") == -1)
                    {
                        orderid = order.OrderExNo;

                        GetOrdersCall apicall = new GetOrdersCall(context);
                        OrderTypeCollection orders = null;
                        try
                        {
                            orders = apicall.GetOrders(new StringCollection { order.OrderExNo });
                        }
                        catch (Exception)
                        {
                            orders = new OrderTypeCollection();

                        }

                        if (orders.Count > 0)
                        {
                            foreach (TransactionType trans in orders[0].TransactionArray)
                            {
                                itemid = trans.Item.ItemID;
                                orderid = trans.TransactionID;
                                call.Shipment = new ShipmentType();
                                call.Shipment.DeliveryStatus = eBay.Service.Core.Soap.ShipmentDeliveryStatusCodeType.Delivered;
                                call.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection();

                                if (orderType.OrderNo == order.TrackCode || order.TrackCode == "" || order.TrackCode == null)
                                {
                                    //call.Shipment.ShipmentTrackingNumber = "";
                                }
                                else
                                {
                                    call.Shipment.ShippingCarrierUsed = CarrierUsed;
                                    call.Shipment.ShipmentTrackingNumber = orderType.TrackCode.ToString();
                                }
                                call.Shipment.DeliveryDate = DateTime.Now;
                                call.Shipment.DeliveryDateSpecified = true;
                                call.Shipment.DeliveryStatus = ShipmentDeliveryStatusCodeType.Delivered;
                                try
                                {
                                    call.CompleteSale(itemid, orderid, true, true);
                                }
                                catch (Exception ex)
                                {
                                    break;
                                }
                                break;

                            }
                        }
                    }
                    else
                    {
                        itemid = order.OrderExNo.Substring(0, order.OrderExNo.IndexOf("-"));
                        orderid = order.OrderExNo.Substring(order.OrderExNo.IndexOf("-") + 1);
                        call.Shipment = new ShipmentType();
                        call.Shipment.DeliveryStatus = eBay.Service.Core.Soap.ShipmentDeliveryStatusCodeType.Delivered;
                        call.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection();
                        if (orderType.OrderNo == order.TrackCode || order.TrackCode == "" || order.TrackCode == null)
                        {
                            //call.Shipment.ShipmentTrackingNumber = "";
                        }
                        else
                        {
                            call.Shipment.ShippingCarrierUsed = CarrierUsed;
                            call.Shipment.ShipmentTrackingNumber = orderType.TrackCode.ToString();
                        }

                        call.Shipment.DeliveryDate = DateTime.Now;
                        call.Shipment.DeliveryDateSpecified = true;
                        call.Shipment.DeliveryStatus = ShipmentDeliveryStatusCodeType.Delivered;
                        try
                        {
                            call.CompleteSale(itemid, orderid, true, true);
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                        finally
                        {


                        }
                    }
                }
            }
        }