public LoadedDto LoadWebApps() { var spFarm = SpLocationHelper.GetFarm(); var farmLocation = SpConverter.ToLocation(spFarm); // this variable will save all loaded information of all web applications var loadedElements = new LoadedDto(farmLocation); var spWebApps = SpLocationHelper.GetAllWebApplications(); foreach (var wa in spWebApps) { var waLocation = wa.ToLocation(farmLocation.UniqueId); var activatedFeatures = wa.Features.ToActivatedFeatures(waLocation); // no non full trust farm features expected on scope web app // (sand boxed and add-in features are only scoped site and web) loadedElements.AddChild(waLocation, activatedFeatures, null); } return(loadedElements); }
private LoadedDto loadChildLocations(Location location) { var loadedElements = new LoadedDto(location); Core.Models.Enums.Scope?childScope; switch (location.Scope) { case Core.Models.Enums.Scope.Web: throw new ArgumentException("FeatureAdmin should never load child locations for a web."); case Core.Models.Enums.Scope.Site: childScope = Core.Models.Enums.Scope.Web; break; case Core.Models.Enums.Scope.WebApplication: childScope = Core.Models.Enums.Scope.Site; break; case Core.Models.Enums.Scope.Farm: childScope = Core.Models.Enums.Scope.WebApplication; break; case Core.Models.Enums.Scope.ScopeInvalid: childScope = null; break; default: throw new ArgumentException("FeatureAdmin should never reach default scope in load child locations."); } List <Location> children = new List <Location>(); if (childScope != null) { if (childScope.Value == Core.Models.Enums.Scope.WebApplication) { children = demoRepository.SearchLocations(null, childScope.Value, null).Select(i => i.Item).ToList(); } else { children = demoRepository.SearchLocations(location.Id.ToString(), childScope.Value, null).Select(i => i.Item).ToList(); } // add all child locations at once loadedElements.AddChildLocations(children); foreach (var l in children) { var activatedFeatures = GetDemoActivatedFeatures(l); loadedElements.AddActivatedFeatures(activatedFeatures); var definitions = GetDemoFeatureDefinitions(l); loadedElements.AddFeatureDefinitions(definitions); } } return(loadedElements); }
public string AddLoadedLocations(LoadedDto loadedElements) { var error = AddLocations(loadedElements.ChildLocations); AddActivatedFeatures(loadedElements.ActivatedFeatures); AddFeatureDefinitions(loadedElements.Definitions); return(error); }
//public void AddActivatedFeatures(IEnumerable<ActivatedFeature> activatedFeatures) //{ // store.AddActivatedFeatures(activatedFeatures); //} public void AddLoadedLocations(LoadedDto message) { var error = store.AddLoadedLocations(message); if (!string.IsNullOrEmpty(error)) { var logMsg = new Messages.LogMessage(Core.Models.Enums.LogLevel.Error, error); eventAggregator.PublishOnUIThread(logMsg); } }
public LoadedDto LoadWebAppChildren(Location location, bool elevatedPrivileges) { var siCos = loadChildLocations(location); var allChildren = new LoadedDto(location); foreach (var s in siCos.ChildLocations) { var webs = loadChildLocations(s); allChildren.AddChildren(webs.ChildLocations, webs.ActivatedFeatures, webs.Definitions); } allChildren.AddChildren(siCos.ChildLocations, siCos.ActivatedFeatures, siCos.Definitions); return(allChildren); }
public LoadedDto LoadFarm() { var loadedFarm = new LoadedDto(null); var farm = SpLocationHelper.GetFarm(); var farmLocation = SpConverter.ToLocation(farm); var activatedFeatures = SpConverter.ToActivatedFeatures(farm.Features, farmLocation); // no non full trust farm features expected on scope farm // (sand boxed and add-in features are only scoped site and web) loadedFarm.AddChild(farmLocation, activatedFeatures, null); return(loadedFarm); }
public LoadedDto LoadFarm() { var loadedFarm = new LoadedDto(null); var location = demoRepository.SearchLocations(string.Empty, Scope.Farm, null).FirstOrDefault(); if (location != null) { var activatedFeatures = GetDemoActivatedFeatures(location.Item); var definitions = GetDemoFeatureDefinitions(location.Item); loadedFarm.AddChild(location.Item, activatedFeatures, definitions); return(loadedFarm); } return(null); }
public bool TrackLocationsProcessed(LoadedDto loadedMessage) { bool finished = false; var parent = loadedMessage.Parent; foreach (Location l in loadedMessage.ChildLocations) { TrackLocationProcessed(l); } FarmFeatureDefinitions.Processed += loadedMessage.Definitions.Count(); var features = loadedMessage.ActivatedFeatures; if (features != null) { ActivatedFeaturesLoaded += features.Count(); if (features.Any(f => f.Faulty)) { foreach (var f in features.Where(f => f.Faulty)) { LogToUi( Enums.LogLevel.Warning, string.Format( "Unclean feature found: {0}", f.ToString() ) ); } } } return(finished); }
private void ReceiveLocationsLoaded([NotNull] LoadedDto message) { TrackLocationsProcessed(message); // if web apps are loaded, load children if (message.Parent != null && message.Parent.Scope == Enums.Scope.Farm) { foreach (Location l in message.ChildLocations) { //TODO: Here, it could be checked, if a site collection is e.g. locked or readonly if (l.Scope == Enums.Scope.WebApplication) { // initiate read of locations var loadWebAppChildren = new LoadChildLocationQuery(Id, l, elevatedPrivileges); ReceiveLoadChildrenTask(loadWebAppChildren); } } } repository.AddLoadedLocations(message); SendProgress(); }
//public void AddActivatedFeatures(IEnumerable<ActivatedFeature> activatedFeatures) //{ // store.AddActivatedFeatures(activatedFeatures); //} public void AddLoadedLocations(LoadedDto message) { store.AddLoadedLocations(message); }
public LoadedDto LoadWebAppChildren(Location location, bool elevatedPrivileges) { // this variable will save all loaded information of all web applications var loadedElements = new LoadedDto(location); var spWebApp = SpLocationHelper.GetWebApplication(location.Id); if (spWebApp == null) { // The web application might have got deleted!? // throw? return(null); } var siCos = spWebApp.Sites; foreach (SPSite spSite in siCos) { Location siteLocation; //try //{ if (elevatedPrivileges) { siteLocation = SpSiteElevation.SelectAsSystem(spSite, SpConverter.ToLocation, location.UniqueId); } else { siteLocation = SpConverter.ToLocation(spSite, location.UniqueId); } // meaning that they are not installed in the farm, rather on site or web level IEnumerable <FeatureDefinition> nonFarmFeatureDefinitions; SPFeatureCollection siteFeatureCollection = SpFeatureHelper.GetFeatureCollection(spSite, elevatedPrivileges); var activatedSiteFeatures = siteFeatureCollection.ToActivatedFeatures(siteLocation, out nonFarmFeatureDefinitions); loadedElements.AddChild(siteLocation, activatedSiteFeatures, nonFarmFeatureDefinitions); if (siteLocation.LockState != LockState.NoAccess && spSite != null && spSite.AllWebs != null) { SPWebCollection allWebs; if (elevatedPrivileges) { allWebs = SpSiteElevation.SelectAsSystem(spSite, SpLocationHelper.GetAllWebs); } else { allWebs = spSite.AllWebs; } foreach (SPWeb spWeb in allWebs) { var webLocation = SpConverter.ToLocation(spWeb, siteLocation.UniqueId); nonFarmFeatureDefinitions = null; SPFeatureCollection webFeatureCollection = SpFeatureHelper.GetFeatureCollection(spWeb, elevatedPrivileges); var activatedWebFeatures = webFeatureCollection.ToActivatedFeatures(webLocation, out nonFarmFeatureDefinitions); loadedElements.AddChild(webLocation, activatedWebFeatures, nonFarmFeatureDefinitions); // https://blogs.technet.microsoft.com/stefan_gossner/2008/12/05/disposing-spweb-and-spsite-objects/ spWeb.Dispose(); } } spSite.Dispose(); // This is the right place for debugging exception handling of lock state of site collections //} //catch (Exception Ex) //{ // throw Ex; //} } return(loadedElements); }