private void writeSiteWideCharTypeObjectToDisk(SiteWideCharacteristicsTypeCollection obj) { XmlSerializer serializer = new XmlSerializer(typeof(SiteWideCharacteristicsTypeCollection)); TextWriter writer = new StreamWriter(SW_FILE_NAME); serializer.Serialize(writer, obj); writer.Close(); }
private SiteWideCharacteristicsTypeCollection readSiteWideCharTypeObjectFromDisk() { XmlSerializer serializer = new XmlSerializer(typeof(SiteWideCharacteristicsTypeCollection)); FileStream fs = new FileStream(SW_FILE_NAME, FileMode.Open); SiteWideCharacteristicsTypeCollection siteWideCharacters = (SiteWideCharacteristicsTypeCollection)serializer.Deserialize(fs); fs.Close(); return(siteWideCharacters); }
/// <summary> /// Get Site-Wide characteristics sets by category ID. /// </summary> /// <param name="catId">A specific category ID for which fetch Site-Wide CategoryCS data.</param> public int[] GetSiteWideCharSetsAttrIds(string catId) { SiteWideCharacteristicsTypeCollection swAttrs = GetSiteWideCharacteristics(catId); Int32Collection attrSetIds = new Int32Collection(); for (int i = 0; i < swAttrs.Count; i++) { SiteWideCharacteristicsType swCharSet = swAttrs.ToArray()[i]; int attrSetId = swCharSet.CharacteristicsSet.AttributeSetID; attrSetIds.Add(attrSetId); } return(attrSetIds.ToArray()); }
private void init(string catId) { if (currentVersion == null || currentVersion.Length == 0) { currentVersion = getCurrentAttributeSystemVersion(); } string site = apiContext.Site.ToString(); CATCS_FILE_NAME_PREFIX = (catId == null)?"ALL":catId; ROOT_DIR = "C:\\TEMP"; //System.Environment.GetEnvironmentVariable(AttributesMaster.SDK_ENV_NAME); DirectoryInfo dirInfo = new DirectoryInfo(ROOT_DIR); if (!dirInfo.Exists) { dirInfo.Create(); } string fileNamePrefix = site + "." + CATCS_FILE_NAME_PREFIX + "." + currentVersion; string[] dataFiles = getDataFiles(dirInfo); bool foundVersion = false; bool foundAllVersion = false; if (dataFiles != null && dataFiles.Length != 0) { foundVersion = FoundVersion(dataFiles, fileNamePrefix); if (!foundVersion) { foundAllVersion = FoundVersion(dataFiles, site + "." + "ALL" + "." + currentVersion); } if (foundAllVersion) { fileNamePrefix = site + "." + "ALL" + "." + currentVersion; } } CATCS_FILE_NAME = ROOT_DIR + "\\" + fileNamePrefix + "." + CATCS_FILE_EXTENSION; SW_FILE_NAME = ROOT_DIR + "\\" + fileNamePrefix + "." + SW_FILE_EXTENSION; if (foundVersion || foundAllVersion) { mCats = readCategoryTypeObjectFromDisk(); mSiteWideCharacteristicSets = readSiteWideCharTypeObjectFromDisk(); } else { mCats = DownloadCategoryCS(catId); writeCategoryTypeObjectToDisk(mCats); writeSiteWideCharTypeObjectToDisk(mSiteWideCharacteristicSets); } }
/// <summary> /// Get CategoryCS data by calling eBay API. Special version for fast example usage. /// </summary> /// <param name="asn">The <c>ApiContext</c> object to make API call.</param> /// <param name="categoryId">A specific category ID for which to download CategoryCS data.</param> public CategoryTypeCollection DownloadCategoryCS(ApiContext asn, string categoryId) { GetCategory2CSCall api = new GetCategory2CSCall(asn); //api.ErrorLevel = ErrorLevelEnum.BothShortAndLongErrorStrings; if (categoryId != null) { api.CategoryID = categoryId; } api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); //.DetailLevel = 1; api.Timeout = 480000; mCats = api.GetCategory2CS(); mSiteWideCharacteristicSets = api.SiteWideCharacteristicList; return(mCats); }
private void init(string catId) { if(currentVersion == null || currentVersion.Length == 0) { currentVersion = getCurrentAttributeSystemVersion(); } string site = apiContext.Site.ToString(); CATCS_FILE_NAME_PREFIX = (catId == null)?"ALL":catId; ROOT_DIR = "C:\\TEMP"; //System.Environment.GetEnvironmentVariable(AttributesMaster.SDK_ENV_NAME); DirectoryInfo dirInfo = new DirectoryInfo(ROOT_DIR); if(!dirInfo.Exists) { dirInfo.Create(); } string fileNamePrefix = site + "." + CATCS_FILE_NAME_PREFIX + "." + currentVersion; string[] dataFiles = getDataFiles(dirInfo); bool foundVersion = false; bool foundAllVersion = false; if(dataFiles != null && dataFiles.Length != 0) { foundVersion = FoundVersion(dataFiles, fileNamePrefix); if(!foundVersion) { foundAllVersion = FoundVersion(dataFiles, site + "." + "ALL" + "." + currentVersion); } if(foundAllVersion) { fileNamePrefix = site + "." + "ALL" + "." + currentVersion; } } CATCS_FILE_NAME = ROOT_DIR + "\\" + fileNamePrefix + "." + CATCS_FILE_EXTENSION; SW_FILE_NAME = ROOT_DIR + "\\" + fileNamePrefix + "." + SW_FILE_EXTENSION; if(foundVersion || foundAllVersion) { mCats = readCategoryTypeObjectFromDisk(); mSiteWideCharacteristicSets = readSiteWideCharTypeObjectFromDisk(); } else { mCats = DownloadCategoryCS(catId); writeCategoryTypeObjectToDisk(mCats); writeSiteWideCharTypeObjectToDisk(mSiteWideCharacteristicSets); } }
/// <summary> /// Get Site-Wide characteristics sets by category ID. /// </summary> /// <param name="catId">A specific category ID for which fetch Site-Wide CategoryCS data.</param> /// <returns>SiteWideCharacteristicsTypeCollection</returns> public SiteWideCharacteristicsTypeCollection GetSiteWideCharacteristics(string catId) { if (!validate()) { init(catId); } SiteWideCharacteristicsTypeCollection swAttrs = new SiteWideCharacteristicsTypeCollection(); for (int i = 0; i < mSiteWideCharacteristicSets.Count; i++) { SiteWideCharacteristicsType swCharSet = mSiteWideCharacteristicSets.ToArray()[i]; if (isExcludedCategoryID(catId, swCharSet)) { continue; } swAttrs.Add(swCharSet); } return(swAttrs); }
/// <summary> /// Returns collection of Site Wide AttributeSet objects for a given array category Ids. /// Each element of the array contains a VCS Id, if it exists for a given category Id. /// </summary> /// <param name="catIds">int[]</param> /// <returns>Collection of site wide AttributeSet objects</returns> public IAttributeSetCollection GetSiteWideAttributeSetsForCategories(Int32Collection catIds) { IAttributeSetCollection attrSetsList = new AttributeSetCollection(); int i = 0; foreach (int catId in catIds) { SiteWideCharacteristicsTypeCollection swAttrs = mCategoryCSProvider.GetSiteWideCharacteristics(catId.ToString()); foreach (SiteWideCharacteristicsType swChar in swAttrs) { AttributeSet swAst = new AttributeSet(); swAst.attributeSetID = swChar.CharacteristicsSet.AttributeSetID; swAst.CategoryID = catId; swAst.CategoryOrdinal = i++; swAst.Name = swChar.CharacteristicsSet.Name; attrSetsList.Add(swAst); } } return(attrSetsList); }
/// <summary> /// Get Site-Wide characteristics sets by category ID. /// </summary> /// <param name="catId">A specific category ID for which fetch Site-Wide CategoryCS data.</param> /// <returns>SiteWideCharacteristicsTypeCollection</returns> public SiteWideCharacteristicsTypeCollection GetSiteWideCharacteristics(string catId) { if(!validate()) { init(catId); } SiteWideCharacteristicsTypeCollection swAttrs = new SiteWideCharacteristicsTypeCollection(); for(int i = 0; i < mSiteWideCharacteristicSets.Count; i++) { SiteWideCharacteristicsType swCharSet = mSiteWideCharacteristicSets.ToArray()[i]; if(isExcludedCategoryID(catId, swCharSet)) { continue; } swAttrs.Add(swCharSet); } return swAttrs; }
/// <summary> /// Get CategoryCS data by calling eBay API. Special version for fast example usage. /// </summary> /// <param name="asn">The <c>ApiContext</c> object to make API call.</param> /// <param name="categoryId">A specific category ID for which to download CategoryCS data.</param> public CategoryTypeCollection DownloadCategoryCS(ApiContext asn, string categoryId) { GetCategory2CSCall api = new GetCategory2CSCall(asn); //api.ErrorLevel = ErrorLevelEnum.BothShortAndLongErrorStrings; if (categoryId != null) { api.CategoryID = categoryId; } api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); //.DetailLevel = 1; api.Timeout = 480000; mCats = api.GetCategory2CS(); mSiteWideCharacteristicSets = api.SiteWideCharacteristicList; return mCats; }
private void writeSiteWideCharTypeObjectToDisk(SiteWideCharacteristicsTypeCollection obj) { XmlSerializer serializer = new XmlSerializer(typeof(SiteWideCharacteristicsTypeCollection)); TextWriter writer = new StreamWriter(SW_FILE_NAME); serializer.Serialize(writer, obj); writer.Close(); }