protected void btnTest_Click(object sender, EventArgs e)
        {
            string q = GB2312ToUTF8(txtQ.Text);// Server.UrlEncode(txtQ.Text);
            ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
            TOPDataList<ItemListItem> list;
            try
            {
                if (ddlQueryType.SelectedValue.Equals("key", StringComparison.OrdinalIgnoreCase))
                {
                    list = facade.QueryItemListByKey(q);
                }
                else
                {
                    list = facade.QueryItemListByNicks(q.Split(','));
                }

                lblItemCount.Text = string.Format("{0}条记录", list.TotalResultNum);
            }
            catch (ResponseException ex)
            {
                Response.Write(ex.Message + " - " + ex.ErrorCode + " - " + ex.ErrorDescription);
                list = null;
                lblItemCount.Text = "0条记录";
            }
            repeater.DataSource = list;
            repeater.DataBind();
        }
 public void TestGetItem()
 {
     ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
     // <p><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421747.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421748.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421749.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421751.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421752.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421753.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421754.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421756.jpg" /><img alt="" src="http://image.rakuten.co.jp/simple-mart/cabinet/h001/img55421757.jpg" /></p>
     ItemDetail item = facade.GetItem("ff5877fe8e9fa838043b43d7f20f7dfd", "zhongjy001");
     Assert.IsNotNull(item);
     Assert.AreEqual("", item.Description);
     Assert.IsFalse(string.IsNullOrEmpty(item.Description));
 }
        public void TestGetItemPropValues_测试电脑()
        {
            ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
            ItemDetail item = facade.GetItem("4e30aff3293626fbf0d9cbd2be5d9f03", "liangweidaren");

            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("4e30aff3293626fbf0d9cbd2be5d9f03", "liangweidaren");
            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列表");
            }
        }
 public void TestUpdateItemDescription()
 {
     ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
     // ff5877fe8e9fa838043b43d7f20f7dfd_T1UyRlXgKkItQ5DJM__075740.jpg
     string rtn = facade.UpdateItemDescription("ff5877fe8e9fa838043b43d7f20f7dfd", "ff5877fe8e9fa838043b43d7f20f7dfd_T1UyRlXgKkItQ5DJM__075740.jpg");
     Assert.AreEqual("", rtn);
 }
 public void TestQuerySkuListByNicks_测试()
 {
     ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
     TOPDataList<ItemListItem> itemList = facade.QueryItemListByNicks("jimmy422");
     Assert.IsTrue(itemList.Count > 0);
 }
 public void TestGetSkuListByNick_测试()
 {
     ItemFacade facade = new ItemFacade(defaultAppKey, defaultAppSecret);
     TOPDataList<Sku> skuList = facade.GetSkuListByNick("e451e370789042d8ad387d087a372d25", "jimmy422");
     Assert.IsTrue(skuList.Count > 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列表");
     }
 }
        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();
        }