public JsonResult Create(EbayType obj)
 {
     try
     {
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return Json(new { ErrorMsg = "出错了", IsSuccess = false });
     }
     return Json(new { IsSuccess = "true" });
 }
        public string SetStock(EbayType obj)
        {
            try
            {
                NSession.Save(obj);
                NSession.Flush();
                return "保存成功";
            }
            catch (Exception e)
            {
                return "保存出错";
            }

        }
Exemplo n.º 3
0
        public static void GetMyeBaySelling(AccountType sa, ISession NSession)
        {
            if (sa == null) return;
            ApiContext context = EBayUtil.GetGenericApiContext("US");
            context.ApiCredential.eBayToken = sa.ApiToken;
            GetMyeBaySellingCall apicall = new GetMyeBaySellingCall(context);
            apicall.ActiveList = new ItemListCustomizationType();
            int i = 1;
            DeleteALL(sa.AccountName, NSession);

            do
            {
                apicall.ActiveList.Pagination = new PaginationType();
                apicall.ActiveList.Pagination.EntriesPerPage = 200;
                apicall.ActiveList.Pagination.PageNumber = i;
                apicall.GetMyeBaySelling();

                if (apicall.ActiveListReturn != null && apicall.ActiveListReturn.ItemArray != null && apicall.ActiveListReturn.ItemArray.Count > 0)
                {

                    foreach (ItemType actitem in apicall.ActiveListReturn.ItemArray)
                    {

                        try
                        {
                            if (actitem.SellingStatus != null)
                            {
                                EbayType ei = new EbayType();
                                ei.ItemId = actitem.ItemID;


                                ei.ItemTitle = actitem.Title;
                                ei.Price = actitem.SellingStatus.CurrentPrice.Value.ToString();


                                ei.Currency = actitem.SellingStatus.CurrentPrice.currencyID.ToString();
                                ei.StartNum = actitem.Quantity;
                                ei.NowNum = actitem.QuantityAvailable;
                                ei.ProductUrl = actitem.ListingDetails.ViewItemURL;
                                if (actitem.PictureDetails != null && actitem.PictureDetails.GalleryURL != null)
                                {
                                    ei.PicUrl = actitem.PictureDetails.GalleryURL;
                                }
                                ei.StartTime = actitem.ListingDetails.StartTime;
                                ei.Account = sa.AccountName;
                                ei.Status = "销售中";
                                ei.SKU = "";
                                if (actitem.SKU != null)
                                {
                                    ei.SKU = actitem.SKU;
                                    if (ei.NowNum == 0)
                                    {
                                        ei.Status = "卖完";
                                    }
                                    NSession.Clear();
                                    ei.CreateOn = DateTime.Now;
                                    NSession.Save(ei);
                                    NSession.Flush();
                                }
                                else
                                {
                                    if (actitem.Variations != null)
                                    {
                                        foreach (VariationType v in actitem.Variations.Variation)
                                        {
                                            NSession.Clear();
                                            ei.SKU = v.SKU;
                                            ei.StartNum = v.Quantity;
                                            ei.NowNum = v.Quantity - v.SellingStatus.QuantitySold;
                                            ei.Status = "销售中";
                                            if (ei.NowNum == 0)
                                            {
                                                ei.Status = "卖完";
                                            }
                                            ei.ItemTitle = v.VariationTitle;

                                            ei.CreateOn = DateTime.Now;
                                            NSession.Save(ei);
                                            NSession.Flush();
                                        }
                                    }
                                    else
                                    {
                                        ei.SKU = "";
                                        if (ei.NowNum == 0)
                                        {
                                            ei.Status = "卖完";
                                        }
                                        NSession.Clear();
                                        ei.CreateOn = DateTime.Now;
                                        NSession.Save(ei);
                                        NSession.Flush();
                                    }

                                }



                            }
                        }
                        catch (Exception)
                        {
                            continue;

                        }


                    }
                    i++;
                    if (i > apicall.ActiveListReturn.PaginationResult.TotalNumberOfPages)
                    {
                        break;
                    }
                }


            } while (apicall.ActiveListReturn != null && apicall.ActiveListReturn.ItemArray != null && apicall.ActiveListReturn.ItemArray.Count == 200);

        }