private void UpdateAreas(out int total, out int added, out int updated)
        {
            added   = 0;
            updated = 0;

            TOP.Management.Facade.AreaFacade areaFacade = new TOP.Management.Facade.AreaFacade();

            TOP.Core.Facade.AreaFacade topFacade = new TOP.Core.Facade.AreaFacade(varHelper.TOP_AppKey, varHelper.TOP_AppSecret);
            TOPDataList <Area>         list      = topFacade.GetAllAreas();

            total = list.Count;
            foreach (Area area in list)
            {
                if (areaFacade.IsAreaExist(area.AreaId))
                {
                    areaFacade.UpdateArea(area.AreaId, area.AreaType, area.AreaName, area.ParentId, area.Zip);
                    updated++;
                }
                else
                {
                    areaFacade.AddArea(string.Empty, area.AreaId, area.AreaType, area.AreaName, area.ParentId, area.Zip);
                    added++;
                }
            }
        }
예제 #2
0
        public void TestQuerySkuListByKey_测试()
        {
            ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
            TOPDataList <ItemListItem> itemList = facade.QueryItemListByKey("NIKE");

            Assert.IsTrue(itemList.Count > 0);
        }
예제 #3
0
        public void TestGetSkuListByNick_测试()
        {
            ItemFacade        facade  = new ItemFacade(defaultAppKey, defaultAppSecret);
            TOPDataList <Sku> skuList = facade.GetSkuListByNick("e451e370789042d8ad387d087a372d25", "jimmy422");

            Assert.IsTrue(skuList.Count > 0);
        }
        public void TestRequestTOPDataList_测试请求服务器_正确()
        {
            string nick = "fengxiangxia";

            AnalyseData analyser          = new AnalyseData(defaultAppKey, defaultAppSecret);
            Dictionary <string, string> q = new Dictionary <string, string>();

            q.Add("nicks", nick);
            TOPDataList <ItemListItem> list = analyser.RequestTOPDataList <ItemListItem>("taobao.items.get", q);

            Assert.AreEqual(40, list.Count);
            Assert.IsTrue(list.TotalResultNum > 100);
            Assert.IsFalse(string.IsNullOrEmpty(list[0].Title));
        }
예제 #5
0
        private void BindItem(ItemDetail item)
        {
            lblName.Text        = item.Title;
            imgItemPic.ImageUrl = item.PicPath;
            if (item.ItemType.Equals("fixed", StringComparison.OrdinalIgnoreCase))
            {
                lblPriceTitle.Text = "一口价";
            }
            else
            {
                lblPriceTitle.Text = "拍卖";
            }
            lblPrice.Text = double.Parse(item.Price).ToString("N2");
            if (item.FreightPayer.Equals("seller", StringComparison.OrdinalIgnoreCase))
            {
                lblFee.Text = "卖家承担运费";
            }
            else
            {
                lblFee.Text = string.Format("平邮: {0}; 快递: {1}; EMS: {2}"
                                            , double.Parse(item.FeePost).ToString("N2")
                                            , double.Parse(item.FeeExpress).ToString("N2")
                                            , double.Parse(item.FeeEms).ToString("N2"));
            }
            lblLocation.Text = item.Location;
            if (item.StuffStatus.Equals("new", StringComparison.OrdinalIgnoreCase))
            {
                lblType.Text = "全新";
            }
            else if (item.StuffStatus.Equals("unused", StringComparison.OrdinalIgnoreCase))
            {
                lblType.Text = "全新";
            }
            else if (item.StuffStatus.Equals("second", StringComparison.OrdinalIgnoreCase))
            {
                lblType.Text = "二手";
            }
            else
            {
                lblType.Text = "错误";
            }

            TOPDataList <ItemPropValue> mainProps = facade.GetItemPropValues(item.CategoryId, item.Properties);

            rptProperties.DataSource = mainProps;
            rptProperties.DataBind();

            lblDescription.Text = item.Description;
        }
예제 #6
0
        public void TestGetSkuById_测试()
        {
            ItemFacade        facade  = new ItemFacade(defaultAppKey, defaultAppSecret);
            TOPDataList <Sku> skuList = facade.GetSkuListByNick("e451e370789042d8ad387d087a372d25", "jimmy422");

            if (skuList.Count > 0)
            {
                Sku sku = facade.GetSku(skuList[0].Id, "jimmy422");
                Assert.IsNotNull(sku);
            }
            else
            {
                Assert.Fail("没查询到商品的Sku列表");
            }
        }
예제 #7
0
        public void TestGetItemPropValues_测试裤子()
        {
            ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
            ItemDetail item   = facade.GetItem("e451e370789042d8ad387d087a372d25", "jimmy422");

            Assert.IsNotNull(item);

            TOPDataList <ItemPropValue> mainProps = facade.GetItemPropValues(item.CategoryId, item.Properties);
            string propStr = string.Empty;

            foreach (ItemPropValue prop in mainProps)
            {
                propStr += prop.SortOrder + "." + prop.PropertyName + ":" + prop.Name + "(" + prop.NameAlias + ")\n";
            }
            Assert.IsFalse(string.IsNullOrEmpty(propStr));
            Assert.IsNotNull(mainProps);
            Assert.IsTrue(mainProps.Count > 0);

            TOPDataList <Sku> skuList = facade.GetSkuListByNick("e451e370789042d8ad387d087a372d25", "jimmy422");

            if (skuList.Count > 0)
            {
                string propStrings = propStr;
                for (int i = 0; i < skuList.Count; i++)
                {
                    Sku sku = skuList[i];

                    Assert.IsNotNull(sku);

                    TOPDataList <ItemPropValue> props = facade.GetItemPropValues(item.CategoryId, sku.Properties);
                    propStr = string.Empty;
                    foreach (ItemPropValue prop in props)
                    {
                        propStr += prop.SortOrder + "." + prop.PropertyName + ":" + prop.Name + "(" + prop.NameAlias + ")\n";
                    }
                    Assert.IsFalse(string.IsNullOrEmpty(propStr));
                    Assert.IsNotNull(props);
                    Assert.IsTrue(props.Count > 0);

                    propStrings += propStr;
                }
                Assert.IsFalse(string.IsNullOrEmpty(propStrings));
            }
            else
            {
                Assert.Fail("没查询到商品的Sku列表");
            }
        }
        private int UpdateSubItemCategories(string parentId)
        {
            ItemCategoryFacade localFacade = new ItemCategoryFacade();

            localFacade.DeleteItemCategoryByParentId(parentId);

            CategoryFacade             topFacade = new CategoryFacade(varHelper.TOP_AppKey, varHelper.TOP_AppSecret);
            TOPDataList <ItemCategory> list      = topFacade.GetItemCategories(parentId, string.Empty);

            foreach (ItemCategory category in list)
            {
                if (!localFacade.IsItemCategoryExist(category.Id))
                {
                    localFacade.AddItemCategory(string.Empty, category.Id, category.ParentId, category.Name, category.IsParent, category.Status, category.SortOrder);
                }
            }
            return(list.Count);
        }
        public void TestDoAnalyse_解析XML文本成功_部分匹配()
        {
            string xml = ""
                         + "<rsp>"
                         + "    <totalResults>23</totalResults>"
                         + "    <item>"
                         + "        <iid><![CDATA[11111111]]></iid>"
                         + "        <title><![CDATA[标题一]]></title>"
                         + "        <detail_url><![CDATA[http://item.taobao.com/auction/item1.jhtml]]></detail_url>"
                         + "    </item>"
                         + "    <item_new>"
                         + "        <iid><![CDATA[22222222]]></iid>"
                         + "        <title><![CDATA[标题二]]></title>"
                         + "        <detail_url><![CDATA[http://item.taobao.com/auction/item2.jhtml]]></detail_url>"
                         + "    </item_new>"
                         + "    <item>"
                         + "        <iid><![CDATA[33333333]]></iid>"
                         + "        <title><![CDATA[标题三]]></title>"
                         + "        <detail_url><![CDATA[http://item.taobao.com/auction/item3.jhtml]]></detail_url>"
                         + "    </item>"
                         + "</rsp>";

            TOPDataList <DataItem_Item_item> list = new TOPDataList <DataItem_Item_item>();

            Assert.AreEqual(0, list.TotalResultNum);
            Assert.AreEqual(0, list.Count);

            list.AnalyseXML(xml);

            Assert.AreEqual(XmlAnalyseState.Success, list.AnalyseState);
            Assert.AreEqual(23, list.TotalResultNum);
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("11111111", list[0].Id);
            Assert.AreEqual("标题一", list[0].Title);
            Assert.AreEqual("http://item.taobao.com/auction/item1.jhtml", list[0].DetailUrl);
        }
예제 #10
0
        public void TestDoAnalyse_解析XML文本成功_部分匹配()
        {
            string xml = ""
                + "<rsp>"
                + "    <totalResults>23</totalResults>"
                + "    <item>"
                + "        <iid><![CDATA[11111111]]></iid>"
                + "        <title><![CDATA[标题一]]></title>"
                + "        <detail_url><![CDATA[http://item.taobao.com/auction/item1.jhtml]]></detail_url>"
                + "    </item>"
                + "    <item_new>"
                + "        <iid><![CDATA[22222222]]></iid>"
                + "        <title><![CDATA[标题二]]></title>"
                + "        <detail_url><![CDATA[http://item.taobao.com/auction/item2.jhtml]]></detail_url>"
                + "    </item_new>"
                + "    <item>"
                + "        <iid><![CDATA[33333333]]></iid>"
                + "        <title><![CDATA[标题三]]></title>"
                + "        <detail_url><![CDATA[http://item.taobao.com/auction/item3.jhtml]]></detail_url>"
                + "    </item>"
                + "</rsp>";

            TOPDataList<DataItem_Item_item> list = new TOPDataList<DataItem_Item_item>();

            Assert.AreEqual(0, list.TotalResultNum);
            Assert.AreEqual(0, list.Count);

            list.AnalyseXML(xml);

            Assert.AreEqual(XmlAnalyseState.Success, list.AnalyseState);
            Assert.AreEqual(23, list.TotalResultNum);
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("11111111", list[0].Id);
            Assert.AreEqual("标题一", list[0].Title);
            Assert.AreEqual("http://item.taobao.com/auction/item1.jhtml", list[0].DetailUrl);
        }
예제 #11
0
        public TOPDataList <T> AnalyseDataList <T>(string responseXml)
            where T : TOPDataItem, new()
        {
            TOPDataList <T> list = new TOPDataList <T>();
            XmlDocument     doc  = new XmlDocument();

            doc.LoadXml(responseXml);
            XmlElement element = doc.DocumentElement;

            if (element.Name.Equals("rsp", StringComparison.OrdinalIgnoreCase))
            {
                list.AnalyseXML(element.OuterXml);

                return(list);
            }
            else if (element.Name.Equals("error_rsp", StringComparison.OrdinalIgnoreCase))
            {
                throw new ResponseException(element.OuterXml, "服务器返回错误响应消息");
            }
            else
            {
                throw new Exception(string.Format("无法解析服务器返回XML格式 - \"{0}\"", element.Name));
            }
        }
예제 #12
0
        private void UpdateItems()
        {
            ucProgress.Title         = "正在更新商品...";
            ucProgress.Summary       = "正在从服务器获取需要更新的商品信息...";
            ucProgress.ProgressTotal = 100;
            ucProgress.ProgressValue = 1;
            ucProgress.Total         = -1;
            ucProgress.Value         = -1;
            ucProgress.DisplayProgress();
            Application.DoEvents();

            string currentPath = Assembly.GetExecutingAssembly().Location;
            string dir         = new FileInfo(currentPath).DirectoryName;

            dir = dir + "\\ShopItems";
            if (cbForce.Checked)
            {
                if (Directory.Exists(dir))
                {
                    Directory.Delete(dir, true);
                }
            }
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
            TOPDataList <SampleListItem> list = facade.QuerySampleListByNick(currentPageIndex++, pageSize, nick);

            while (true)
            {
                TOPDataList <SampleListItem> tmp = facade.QuerySampleListByNick(currentPageIndex++, pageSize, nick);
                list.AddRange(tmp);
                if (tmp.Count < pageSize)
                {
                    break;
                }
            }

            ucProgress.ProgressValue = 100;
            ucProgress.DisplayProgress();
            Application.DoEvents();

            ucProgress.Total         = list.Count;
            ucProgress.ProgressTotal = list.Count;

            isCanceled = false;
            using (WebClient client = new WebClient())
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (isCanceled)
                    {
                        break;
                    }
                    SampleListItem item = list[i];
                    ucProgress.Summary       = item.Title;
                    ucProgress.Value         = i + 1;
                    ucProgress.ProgressValue = i + 1;
                    ucProgress.DisplayProgress();
                    Application.DoEvents();
                    SaveItem(item, dir, client);
                }
            }
            ucProgress.Summary = "更新完毕";
            ucProgress.DisplayProgress();
            Application.DoEvents();
        }