private string GetFullCategoryName(int libraryCategoryId, int companyId) { int[] libraryArray = new int[100]; int maxDeep = 0; for (int index = 0; index < libraryArray.Length; index++) { libraryArray[index] = -1; } string fullCategoryName = ""; libraryArray = GetDeepParent(libraryCategoryId, 0, maxDeep, libraryArray, companyId); for (int index = 0; index < 100; index++) { if (libraryArray[index] > 0) { if (index > 0) { fullCategoryName = fullCategoryName + "/"; } LibraryCategoriesGateway libraryCategoriesGateway = new LibraryCategoriesGateway(); libraryCategoriesGateway.LoadAllByLibraryCategoriesId(libraryArray[index], companyId); fullCategoryName = fullCategoryName + libraryCategoriesGateway.GetCategoryName(libraryArray[index]); } } return fullCategoryName; }
private int[] GetDeepParent(int currentId, int deep, int maxDeep, int[] currentLibraryArray, int companyId) { int[] libraryArray = currentLibraryArray; ViewState["currentmaxDeep"] = maxDeep; LibraryCategoriesGateway libraryCategoriesGateway = new LibraryCategoriesGateway(); libraryCategoriesGateway.LoadAllByLibraryCategoriesId(currentId, companyId); if (libraryCategoriesGateway.Table.Rows.Count > 0) { if (libraryCategoriesGateway.GetParentId(currentId) == 0) { libraryArray[0] = currentId; ViewState["currentmaxDeep"] = deep; return libraryArray; } else { libraryArray = GetDeepParent(libraryCategoriesGateway.GetParentId(currentId), deep + 1, (int)ViewState["currentmaxDeep"], libraryArray, companyId); libraryArray[(int)ViewState["currentmaxDeep"] - deep] = currentId; return libraryArray; } } else { return libraryArray; } }