WebApplication gallery filter mode: include or exclude apps

This commit is contained in:
Sergey 2012-09-25 16:59:50 +03:00
parent 34e566e7d1
commit feae050792
9 changed files with 122 additions and 131 deletions

View file

@ -270,6 +270,7 @@ namespace WebsitePanel.EnterpriseServer
// x => MatchGalleryAppDependencies(x.Dependency, appsFilter.ToArray())
// || MatchMenaltoGalleryApp(x, appsFilter.ToArray())));
{
FilterResultApplications(packageId, result);
@ -293,14 +294,33 @@ namespace WebsitePanel.EnterpriseServer
int userId = SecurityContext.User.UserId;
//
SecurityContext.SetThreadSupervisorPrincipal();
//get filter mode
int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.Web);
StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId);
bool bExclude = (Utils.ParseInt(serviceSettings["GalleryAppsFilterMode"], 0) != 1); //0 - Exclude apps, 1- Include apps
//
string[] filteredApps = GetServiceAppsCatalogFilter(packageId);
//
if (filteredApps != null)
{
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
x => !Array.Exists(filteredApps,
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
if (bExclude)
{
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
x => !Array.Exists(filteredApps,
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
}
else
{
result.Value = new List<GalleryApplication>(Array.FindAll(result.Value.ToArray(),
x => Array.Exists(filteredApps,
z => z.Equals(x.Id, StringComparison.InvariantCultureIgnoreCase))));
}
}
//
SecurityContext.SetThreadPrincipal(userId);