/// <summary> /// Build Category Object (ICategoryMutableObject) /// </summary> /// <param name="CategoryObjectId">Category Code</param> /// <param name="names">Description Names</param> /// <param name="SubCategory">list of SubCategory </param> /// <returns></returns> private ICategoryMutableObject BuildCategoryObject(string CategoryObjectId, List <SdmxObjectNameDescription> names, List <ICategoryMutableObject> SubCategory) { try { ICategoryMutableObject co = new CategoryMutableCore(); co.Id = CategoryObjectId; foreach (SdmxObjectNameDescription item in names) { co.AddName(item.Lingua, item.Name); } if (SubCategory != null) { foreach (ICategoryMutableObject subCo in SubCategory) { co.AddItem(subCo); } } return(co); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateICategoryMutableObject, ex); } }
private void AddChilds(ICategorySchemeMutableObject catSchema, string filter) { DataView viewCS = new DataView(_dtCSFull); DataTable dtCS = viewCS.ToTable(true, "IDCS", "IDCat", "CatCode", "IDParent"); DataTable dtCatNames = viewCS.ToTable(true, "IDCat", "CatLangName", "CatValueName"); filter += " AND IDParent = 0"; DataRow[] dRows = dtCS.Select(filter); ICategoryMutableObject cat; foreach (DataRow row in dRows) { cat = new CategoryMutableCore(); cat.Id = row["CatCode"].ToString(); SetNames(dtCatNames.Select("IDCat = " + row["IDCat"].ToString()), cat); AddRecursiveChilds(cat, dtCatNames, dtCS, row["IDCat"].ToString()); catSchema.Items.Add(cat); } }
private void AddRecursiveChilds(ICategoryMutableObject cat, DataTable dtCatNames, DataTable dtCS, string idCat) { string filter = " IDParent = " + idCat; DataRow[] dRows = dtCS.Select(filter); ICategoryMutableObject catChild; foreach (DataRow row in dRows) { catChild = new CategoryMutableCore(); catChild.Id = row["CatCode"].ToString(); SetNames(dtCatNames.Select("IDCat = " + row["IDCat"].ToString()), catChild); AddRecursiveChilds(catChild, dtCatNames, dtCS, row["IDCat"].ToString()); cat.Items.Add(catChild); } }