Skip to content

Commit 34b3560

Browse files
committed
Performance optimizations
1 parent 254be02 commit 34b3560

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

Repository.ascx.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,15 +1763,16 @@ private void BindObjectList()
17631763

17641764
bool bIsPersonal = false;
17651765
bIsPersonal = false;
1766+
bool isAdministrator = PortalSecurity.IsInRole("Administrators");
17661767

1767-
if (Settings["IsPersonal"] != null) {
1768+
if (Settings["IsPersonal"] != null) {
17681769
bIsPersonal = bool.Parse(Settings["IsPersonal"].ToString());
17691770
}
17701771

17711772

17721773
if (bIsPersonal) {
17731774
foreach (RepositoryInfo dataitem in repositoryItems) {
1774-
if (int.Parse(dataitem.CreatedByUser) == UserId | PortalSecurity.IsInRole("Administrators")) {
1775+
if (int.Parse(dataitem.CreatedByUser) == UserId | isAdministrator) {
17751776
bindableList.Add(dataitem);
17761777
}
17771778
}
@@ -1789,7 +1790,7 @@ private void BindObjectList()
17891790
if (dataitem.SecurityRoles.StartsWith("U:")) {
17901791
string _targetUser = dataitem.SecurityRoles.Substring(2);
17911792
// admins see all items
1792-
if (string.IsNullOrEmpty(_targetUser) | PortalSecurity.IsInRole("Administrators")) {
1793+
if (string.IsNullOrEmpty(_targetUser) | isAdministrator) {
17931794
bindableList.Add(dataitem);
17941795
} else {
17951796
if (HttpContext.Current.User.Identity.IsAuthenticated) {
@@ -1933,6 +1934,7 @@ private bool CheckAnyUserRoles(string roles)
19331934
if (!string.IsNullOrEmpty(Item)) {
19341935
if (PortalSecurity.IsInRole(Item)) {
19351936
found = true;
1937+
continue;
19361938
}
19371939
}
19381940
}

RepositoryDashboard.ascx.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ private bool CheckAnyUserRoles(string roles)
623623
if (!string.IsNullOrEmpty(Item)) {
624624
if (PortalSecurity.IsInRole(Item)) {
625625
found = true;
626+
continue;
626627
}
627628
}
628629
}
@@ -654,20 +655,25 @@ private ArrayList RecalcCategoryCount(ArrayList categories)
654655
ArrayList repositoryItems = repository.GetRepositoryObjects(m_RepositoryId, "", "Downloads", 1, -1, "", -1);
655656
ArrayList bindableList = new ArrayList();
656657
LoadBindableList(bIsPersonal, repositoryItems, bindableList);
657-
658-
// recalc the category counts
659-
foreach (RepositoryCategoryInfo category in categories) {
660-
foreach (RepositoryInfo item in bindableList) {
661-
ArrayList cats = rc.GetRepositoryObjectCategories(item.ItemId);
662-
foreach (RepositoryObjectCategoriesInfo _cat in cats) {
663-
if (_cat.CategoryID == category.ItemId) {
664-
category.Count = category.Count + 1;
665-
}
666-
}
667-
}
668-
}
669-
670-
return categories;
658+
659+
// recalc the category counts
660+
foreach (RepositoryInfo item in bindableList)
661+
{
662+
ArrayList cats = rc.GetRepositoryObjectCategories(item.ItemId);
663+
foreach (RepositoryObjectCategoriesInfo _cat in cats)
664+
{
665+
foreach (RepositoryCategoryInfo category in categories)
666+
{
667+
if (_cat.CategoryID == category.ItemId)
668+
{
669+
category.Count = category.Count + 1;
670+
}
671+
}
672+
}
673+
}
674+
675+
676+
return categories;
671677

672678
}
673679

@@ -761,10 +767,12 @@ private void BindData()
761767
}
762768

763769
private void LoadBindableList(bool bIsPersonal, ArrayList repositoryItems, ArrayList bindableList)
764-
{
765-
if (bIsPersonal) {
766-
foreach (RepositoryInfo dataitem in repositoryItems) {
767-
if (int.Parse(dataitem.CreatedByUser) == UserId | PortalSecurity.IsInRole("Administrators")) {
770+
{
771+
if (bIsPersonal)
772+
{
773+
bool isAdministrator = PortalSecurity.IsInRole("Administrators");
774+
foreach (RepositoryInfo dataitem in repositoryItems) {
775+
if (int.Parse(dataitem.CreatedByUser) == UserId | isAdministrator) {
768776
bindableList.Add(dataitem);
769777
}
770778
}

0 commit comments

Comments
 (0)