Esempio n. 1
0
 public void GetStore()
 {
     GetStoreCall api = new GetStoreCall(this.apiContext);
     // Make API call.
     api.GetStore();
     StoreType store = api.ApiResponse.Store;
     TestData.Store = store;
 }
Esempio n. 2
0
		private void BtnGetStore_Click(object sender, System.EventArgs e)
		{
			try
			{
				LstStoreCats.Items.Clear();
				TxtName.Text = "";
				TxtSubscription.Text = "";
				TxtDescription.Text = "";

				GetStoreCall apicall = new GetStoreCall(Context);
			
				StoreType store = apicall.GetStore();

				TxtName.Text = store.Name;
				TxtSubscription.Text = store.SubscriptionLevel.ToString();
				TxtDescription.Text = store.Description;

				foreach (StoreCustomCategoryType cat in store.CustomCategories)
				{
					string[] listparams = new string[2];
					listparams[0] = cat.CategoryID.ToString();
					listparams[1] = cat.Name;

					ListViewItem vi = new ListViewItem(listparams);
					LstStoreCats.Items.Add(vi);

				}

			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}

		}
Esempio n. 3
0
        public static CategoryContainer BuildCategoryFromeBay(bool storeCatBuild = false)
        {
            if (storeCatBuild == false)
            {
                CategoryContainer container = new CategoryContainer();

                apiContext = AppSettingHelper.GetApiContext();
                apiContext.ApiLogManager = new ApiLogManager();
                apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true));
                apiContext.ApiLogManager.EnableLogging = true;
                apiContext.Site = SiteCodeType.US;

                GetCategoriesCall catCall = new GetCategoriesCall(apiContext)
                {
                    EnableCompression = true,
                    ViewAllNodes = true
                };

                catCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                catCall.GetCategories();

                Dictionary<string, CategoryDef> catIdCMLst = new Dictionary<string, CategoryDef>();

                foreach (CategoryType category in catCall.CategoryList)
                {
                    int categoryId = Int32.Parse(category.CategoryID);
                    int? parentId = Int32.Parse(category.CategoryParentID[0]);
                    if (parentId == categoryId) { parentId = null; }

                    if (parentId == null) { catIdCMLst.Add(category.CategoryID, new CategoryDef(category.CategoryName, category.CategoryID)); }
                    else { catIdCMLst.Add(category.CategoryID, new CategoryDef(category.CategoryName, category.CategoryID, parentId.ToString())); }
                }

                // Lets get all parent categories so we can build down the tree.
                var parentQuery = from parentCategory in catIdCMLst
                                  where parentCategory.Value.ParentId == ""
                                  select parentCategory;
                foreach (var parentCategory in parentQuery)
                {
                    string catName = parentCategory.Value.CategoryName;
                    // LoadNode(parent category id, container) -> find all cats call -> LoadNode(parent category id, container)
                    string pId = parentCategory.Key;
                    CategoryItm catItm = new CategoryItm(pId, catName);
                    container.IdLinkList.Add(pId, catItm);
                    container.Items.Add(catItm);
                    LoadeBayNode(pId, catItm, catIdCMLst, container);
                }

                return container;
            }
            else
            {
                CategoryContainer container = new CategoryContainer();
                apiContext = AppSettingHelper.GetApiContext();
                apiContext.ApiLogManager = new ApiLogManager();
                apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true));
                apiContext.ApiLogManager.EnableLogging = true;
                apiContext.Site = SiteCodeType.US;

                GetStoreCall getStoreCall = new GetStoreCall(apiContext) { EnableCompression = true };
                getStoreCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                getStoreCall.CategoryStructureOnly = true;
                getStoreCall.Execute();

                StoreCustomCategoryType cType = new StoreCustomCategoryType();
                Dictionary<string, CategoryDef> catIdCMLst = new Dictionary<string, CategoryDef>();

                foreach (StoreCustomCategoryType category in getStoreCall.Store.CustomCategories)
                {
                    CategoryItm catItm = new CategoryItm(category.CategoryID.ToString(), category.Name);
                    container.IdLinkList.Add(category.CategoryID.ToString(), catItm);
                    container.Items.Add(catItm);
                    GeteBayChildCategoriesRoot(category, catItm, (int)category.CategoryID, catIdCMLst, container);
                    //container.Items.Add(catItm);
                }

                // Lets get all parent categories so we can build down the tree.
                /*var parentQuery = from parentCategory in catIdCMLst
                                  select parentCategory;
                foreach (var parentCategory in parentQuery)
                {
                    string catName = parentCategory.Value.CategoryName;
                    // LoadNode(parent category id, container) -> find all cats call -> LoadNode(parent category id, container)
                    string pId = parentCategory.Key;
                    CategoryItm catItm = new CategoryItm(pId, catName);
                    container.IdLinkList.Add(pId, catItm);
                    container.Items.Add(catItm);
                    LoadeBayNode(pId, catItm, catIdCMLst, container);
                }*/

                return container;
            }
            //}
            //catch
            //{
            //   return null;
            //}
        }