/// <summary> /// return the all leaf categories /// </summary> /// <param name="parentCategoryID"></param> /// <param name="categoryTypeCollection"></param> /// <returns></returns> private static bool getAllSubCategories(int parentCategoryID, ApiContext apiContext, out CategoryTypeCollection categoryTypeCollection, out string message) { //basic init GetCategoriesCall api = new GetCategoriesCall(apiContext); setBasicInfo(ref api); //return all childs categories StringCollection parent = new StringCollection(); parent.Add(parentCategoryID.ToString()); api.CategoryParent = parent; api.ViewAllNodes = true; api.LevelLimit = 10; categoryTypeCollection = null; message = string.Empty; try { //call categoryTypeCollection = api.GetCategories(); } catch (Exception e) { message = e.Message; return(false); } return(true); }
public void GetCategories() { bool isValid = true; GetCategoriesCall api = new GetCategoriesCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); api.LevelLimit = 1; api.ViewAllNodes = true; api.Timeout = 300000; // CategoryTypeCollection cats = api.GetCategories(); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!"); Assert.IsNotNull(cats); Assert.IsTrue(cats.Count > 0); //the return category's level must be 1. foreach (CategoryType category in cats) { if (category.CategoryLevel != 1) { isValid = false; break; } } Assert.IsTrue(isValid, "the return value is not valid"); // Save the result. TestData.Categories = cats; }
/// <summary> /// return all categories on us sit /// </summary> /// <param name="categoryTypeCollection"></param> /// <returns></returns> private static bool getAllCategories(ApiContext apiContext, out CategoryTypeCollection categoryTypeCollection, out string message) { //basic init categoryTypeCollection = new CategoryTypeCollection(); GetCategoriesCall api = new GetCategoriesCall(apiContext); setBasicInfo(ref api); message = string.Empty; try { if (allCategories == null) { //call categoryTypeCollection = api.GetCategories(); //cach all categories allCategories = categoryTypeCollection; } else { categoryTypeCollection = allCategories; } } catch (Exception e) { message = e.Message; return(false); } return(true); }
/// <summary> /// init the call /// </summary> /// <param name="api"></param> private static void setBasicInfo(ref GetCategoriesCall api) { //set basic info to the call api.CategorySiteID = Convert.ToString(0); DetailLevelCodeTypeCollection detailLevel = new DetailLevelCodeTypeCollection(); DetailLevelCodeType type = DetailLevelCodeType.ReturnAll; detailLevel.Add(type); api.DetailLevelList = detailLevel; }
/// <summary> /// call GetCategories to get all categories for a given site /// </summary> /// <returns>generic object</returns> protected override object callApi() { GetCategoriesCall api = new GetCategoriesCall(context); //set detail level api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); api.Timeout = 480000; api.ViewAllNodes = true; //execute call api.GetCategories(); return(api.ApiResponse); }
/// <summary> /// get last update time from site /// </summary> /// <returns>string</returns> protected override string getLastUpdateTime() { GetCategoriesCall api = new GetCategoriesCall(context); //set output selector api.ApiRequest.OutputSelector = new StringCollection(new String[] { "UpdateTime" }); //execute call api.GetCategories(); DateTime updateTime = api.ApiResponse.UpdateTime; return(updateTime.ToString("yyyy-MM-dd-hh-mm-ss")); }
public CategoryTypeCollection GetCategories(SiteCodeType siteid) { var apicall = new GetCategoriesCall(api); // Enable HTTP compression to reduce the download size. apicall.EnableCompression = true; apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); apicall.ViewAllNodes = true; apicall.Site = siteid; return(apicall.GetCategories()); }
private void BtnGetCategories_Click(object sender, System.EventArgs e) { try { LstCategories.Items.Clear(); GetCategoriesCall apicall = new GetCategoriesCall(Context); // Enable HTTP compression to reduce the download size. apicall.EnableCompression = this.ChkEnableCompression.Checked; apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); apicall.ViewAllNodes = !ChkViewLeaf.Checked; if (TxtLevel.Text.Length > 0) { apicall.LevelLimit = Convert.ToInt32(TxtLevel.Text); } if (TxtParent.Text.Length > 0) { apicall.CategoryParent = new StringCollection(); apicall.CategoryParent.Add(TxtParent.Text); } CategoryTypeCollection cats = apicall.GetCategories(); foreach (CategoryType category in cats) { string[] listparams = new string[8]; listparams[0] = category.CategoryID; listparams[1] = category.CategoryLevel.ToString(); listparams[2] = category.CategoryName; listparams[3] = category.CategoryParentID[0].ToString(); listparams[4] = category.LeafCategory.ToString(); listparams[5] = category.BestOfferEnabled.ToString(); listparams[6] = apicall.ApiResponse.MinimumReservePrice.ToString(); ListViewItem vi = new ListViewItem(listparams); this.LstCategories.Items.Add(vi); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// get a number of CatalogEnabled Categories. /// </summary> /// <param name="number"></param> /// <param name="apiContext"></param> /// <param name="categories"></param> /// <param name="message"></param> /// <returns></returns> //private static bool getCatagoryEnabledCategory(int number,ApiContext apiContext,CategoryEnableCodeType enableType,out CategoryTypeCollection categories,out string message) //{ // CategoryTypeCollection categoryTypeCollection; // categories=new CategoryTypeCollection(); // bool isSuccess,isCatalogEnable; // if(number<=0) // { // number=1; // } // if(getAllCategories(apiContext,out categoryTypeCollection,out message)) // { // foreach(CategoryType category in categoryTypeCollection) // { // if(category.LeafCategory) // { // isSuccess = isCatagoryEnabled(apiContext,category.CategoryID,enableType,out isCatalogEnable,out message); // if(isSuccess) // { // if(isCatalogEnable) // { // categories.Add(category); // } // if(categories.Count>=number) // { // return true; // } // } // else // { // message=message+";get features failure!"; // return false; // } // } // }//end foreach // return true; // } // return false; //} /// <summary> /// check an category whether it is catalog-enabled. /// </summary> /// <param name="apiContext"></param> /// <param name="categorid"></param> /// <param name="isCatalogEnable"></param> /// <param name="message"></param> /// <returns></returns> //private static bool isCatagoryEnabled(ApiContext apiContext,string categorid,CategoryEnableCodeType enableType,out bool isEnable,out string message) //{ // CategoryTypeCollection categories; // isEnable=false; // message=string.Empty; // GetCategory2CSCall api =new GetCategory2CSCall(apiContext); // //GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext); // DetailLevelCodeType detaillevel= DetailLevelCodeType.ReturnAll; // api.DetailLevelList=new DetailLevelCodeTypeCollection(new DetailLevelCodeType[]{detaillevel}); // api.CategoryID=categorid; // try // { // categories = api.GetCategoryFeatures(); // foreach(CategoryType category in categories) // { // if(string.Compare(category.CategoryID,categorid,false)==0) // { // if(enableType==CategoryEnableCodeType.CatalogEnabled) // { // isEnable=category.CatalogEnabled; // break; // } // else if(enableType==CategoryEnableCodeType.ProductSearchPageAvailable) // { // isEnable=category.ProductSearchPageAvailable; // break; // } // } // } // } // catch(Exception e) // { // message=e.Message; // return false; // } // return true; //} /// <summary> /// check whether a category id is valid. /// </summary> /// <param name="apiContext"></param> /// <param name="isValid"></param> /// <param name="message"></param> /// <returns></returns> private static bool isValidCategory(ApiContext apiContext, ref string categoryID, out bool isValid, out string message) { CategoryTypeCollection categories = null; message = string.Empty; isValid = false; GetCategoriesCall api = new GetCategoriesCall(apiContext); setBasicInfo(ref api); StringCollection parents = new StringCollection(); parents.Add(categoryID); api.CategoryParent = parents; try { categories = api.GetCategories(); if (categories != null && categories.Count > 0) { foreach (CategoryType category in categories) { if (string.Compare(category.CategoryID, categoryID, true) == 0) { isValid = true; break; } } } } catch (Exception e) { message = e.Message; return(false); } return(true); }
/// <summary> /// Install plugin /// </summary> public override void Install() { _context.Install(); var settings = new ConfigurationModel { AppID = "PhuocPha-worldbuy-PRD-28e35c535-94b2bb4b", DevID = "4343ce44-efa1-4c33-a431-18daed74c054", Token = "v^1.1#i^1#p^1#r^0#I^3#f^0#t^H4sIAAAAAAAAAOVXa2wUVRTu9oVIizESwYK4nRZjkJm98+ruDt2FpS20aWkXtiBQCZnHHXZgdmYzc5ftxjTWGpr4gB/+MPFFahRJE8WKSg3aRCQEoeAfNfEBPzQQrMQYeQQjwXhndinbSngWIXH/bObcM+ee7zvfOXcu6C6dPLe3sfd8uWdSYV836C70eOgpYHJpyeNTiworSgpAnoOnr7u6u7in6JdaW0zoSWE5tJOmYUNvZ0I3bME1hoiUZQimaGu2YIgJaAtIFmKRpS0CQwEhaZnIlE2d8DbVhwiOlRiFkThallRIcwq2GpditpshgpFYKShyNTDA8KzEAbxu2ynYZNhINBBeB7SfBEGS5tqBX+BogaapGkCvIbwroWVrpoFdKECE3XQF910rL9erpyraNrQQDkKEm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ve+tiiZct2WcZbJU/81HXvA+rPof3NM/oeenjf4Ef97efC2/U9+0bK2YXxAx21p4deLZ2XPliVOHvh/Q3qzl3bza9+/Lx6xwWmujTR8eyOv3zD06xNXUdjP+zS7zm4YviF9JeNRQfOD84+8uHeoddnt758RGrZ8u6TA8e/qGCPvbL/4tRDFd7j2+K1g1+f/Hbh/Dmd/emnXlt7cfPWqmYVrN4xMrRgdd2JrsrTR6lvsuX7B4CTuGQaDwAA", CertID = "PRD-8e35c5356f0f-1449-425a-a638-6322" }; _settingService.SaveSetting(settings); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.AppID", "App ID"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.CertID", "Cert ID"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.Token", "Token"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.DevID", "Dev ID"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.CategoryId", "Category Worldbuy"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.CategoryEbayId", "Category Ebay"); this.AddOrUpdatePluginLocaleResource("Plugins.AffiliateEbay.MapCategory.Error", "Danh mục đã được map"); this.AddOrUpdatePluginLocaleResource("Plugins.AffiliateEbay.MapCategory.Added", "Map danh mục thành công"); this.AddOrUpdatePluginLocaleResource("Plugins.AffiliateEbay.CallApi.Error", "Map danh mục trước khi lấy sản phẩm"); this.AddOrUpdatePluginLocaleResource("Admin.Catalog.Products.Added", "Lấy sản phẩm thành công"); this.AddOrUpdatePluginLocaleResource("Plugin.Configuration.Settings.Ebay", "Lấy sản phẩm thành công"); this.AddOrUpdatePluginLocaleResource("Nop.Plugin.Affiliate.Ebay.Mapping", "Mapping Category"); this.AddOrUpdatePluginLocaleResource("Nop.Plugin.Affiliate.Ebay.Product", "Get Product"); this.AddOrUpdatePluginLocaleResource("Nop.Plugin.Affiliate.Ebay.Setting", "Config Plugin"); this.AddOrUpdatePluginLocaleResource("Nop.Plugin.Affiliate.Ebay", "Plugin Ebay"); this.AddOrUpdatePluginLocaleResource("Plugin.Configuration.Settings.Ebay", "Configure Ebay"); this.AddOrUpdatePluginLocaleResource("Plugin.Ebay.Configuration.Settings.CallApi", "Get Product Ebay"); this.AddOrUpdatePluginLocaleResource("Plugin.Ebay.Configuration.Settings.MappingCategory", "Mapping Category"); this.AddOrUpdatePluginLocaleResource("Plugins.Widgets.Affiliate.Ebay.KeyWord", "Keyword"); //Insert CategoryEbay // set devId, appId, certId in ApiAccount ApiAccount account = new ApiAccount(); account.Developer = "4343ce44-efa1-4c33-a431-18daed74c054"; account.Application = "PhuocPha-worldbuy-PRD-28e35c535-94b2bb4b"; account.Certificate = "PRD-8e35c5356f0f-1449-425a-a638-6322"; // set ApiAccount and token in ApiCredential ApiCredential credential = new ApiCredential(); credential.ApiAccount = account; credential.eBayToken = "AgAAAA**AQAAAA**aAAAAA**JYLgWQ**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6ACl4CiC5KHowqdj6x9nY+seQ**Pt8DAA**AAMAAA**XEESS+BUaGiTZWWj64HwUby9/+ABWbn3NBturqmQgtWJzIW3f/FNc8Wm/EtypFpT5NU6yfvf9lBvyp7kUifGyih/PIQTmDWVrDJjXU+PxJX6QEGFzw4noZK/E1n01EFm6heicUJ5XVj8KY0GA7WVatXy3k2AVDc6psRDoscGAya5mZVDhHgqdyiTHTs/G/5y6G01HBS9ehbkui4eRbggCX6eyee9nCz/UmLOn19C9WJmCpLng8PxcifyEu4Ca8UInQJsaAqYKKGVflBofV0D+6jd4URuEaKl3J2lZbUrjPIBgmCZtYHv8LOKw5OgCRQKCl014DBz91PgOKpUfZCvh7suXazzNOdjh2t4qitzPCi7uMTmzXUzN7WjN5pbFx+3n90FOe+uKjZN1ZhrFx7295qtt5eFh7xxV0ZqdwbBQUILUKm9tE5/KYlpKS+3wjMFpTw66hYuw0s2CIv7axomq+NV2d+rEY2FXAKD3v8OWVnbIFjzQJY+cV8bpMxxDkHsTN9G7lOhbCGxGlRkV1xy5JYeGmqzGYhuDRZ9glfERySkCXJflU94H/bOls8GgEVDrV6iDvcBgPYVhf8YgLN4MUCY3U/osTZbAXh+bV5RPgvtZLNQ4ZB1WhP/qtCsufdkJKnnpxYy1Zswl8QBRZK4+TVkf7/CEqfNSsJGEllxzmznD+Ox4KL+A1n8nzk/NYPMceXFZPS3l4047juy6lTQ6BSBzP+N0CMjezHAoA4tE0vdlJKTRFPyt1sSCjj03MVX"; // add ApiCredential to ApiContext ApiContext context = new ApiContext(); context.ApiCredential = credential; // set eBay server URL to call context.SoapApiServerUrl = "https://api.ebay.com/wsapi"; // set timeout in milliseconds - 3 minutes context.Timeout = 180000; // set wsdl version number context.Version = "1027"; // create ApiCall object - we'll use it to make the call GetCategoriesCall apicall = new GetCategoriesCall(context); apicall.LevelLimit = 3; apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); CategoryTypeCollection cats = apicall.GetCategories(); foreach (CategoryType category in cats) { var cate = new CategoryEbay(); var ebayId = Convert.ToInt32(category.CategoryParentID.ItemAt(0)); var getCate = _affiliateEbayService.GetByEbayId(ebayId); if (getCate != null) { cate.ParentCategoryId = getCate.Id; } else { cate.ParentCategoryId = 0; } cate.EbayId = Convert.ToInt32(category.CategoryID); cate.Name = category.CategoryName; cate.Level = category.CategoryLevel; cate.Published = true; cate.Deleted = false; _affiliateEbayService.InsertCategoryEbay(cate); } base.Install(); }