public void Handle(LocationsLoaded message) { var locations = message.ChildLocations; var locationsToReplace = allItems.Where(al => locations.Any(l => l.Id == al.Id)).ToList(); if (locationsToReplace != null && locationsToReplace.Any()) { for (int i = locationsToReplace.Count() - 1; i >= 0; i--) { allItems.Remove(locationsToReplace[i]); } } foreach (Location l in locations) { allItems.Add(l); } //if (lastUpdateInitiatedSearch.AddSeconds(3) < DateTime.Now) //{ // lastUpdateInitiatedSearch = DateTime.Now; FilterResults(); //} }
private void HandleLocationsLoaded([NotNull] LocationsLoaded message) { TrackLocationsProcessed(message); #if DEBUG var dbgMsg = new FeatureAdmin.Messages.LogMessage(Core.Models.Enums.LogLevel.Debug, string.Format("Debug Load progress: {0}", StatusReport) ); eventAggregator.PublishOnUIThread(dbgMsg); #endif // if web apps are loaded, load children if (message.Parent.Scope == Enums.Scope.Farm) { foreach (Location l in message.ChildLocations) { if (l.Scope == Enums.Scope.WebApplication) { // initiate read of locations var loadWebAppChildren = new LoadLocationQuery(Id, l); LoadTask(loadWebAppChildren); } } } if (Preparations.Completed && FarmFeatureDefinitions.Completed) { // publish locations to wpf eventAggregator.PublishOnUIThread(message); } else { tempLocationStore.Add(message); } SendProgress(); }
private LocationsLoaded loadLocations(Location location) { List <ActivatedFeature> activatedFeatures = new List <ActivatedFeature>(); List <FeatureDefinition> definitions = new List <FeatureDefinition>(); if (location == null) { return(null); } List <Location> children = new List <Location>(); //if farm is loaded, set loaded farm as parent and add farm as children, too if (location.Scope == Core.Models.Enums.Scope.Farm) { location = demoLocations.Where(f => f.Scope == Core.Models.Enums.Scope.Farm).FirstOrDefault(); children.Add(location); } children.AddRange(demoLocations.Where(f => f.Parent == location.Id).ToList()); foreach (Location l in children) { var features = demoActivatedFeatures.Where(f => f.LocationId == l.Id).ToList(); activatedFeatures.AddRange(features); var defs = demoFeaturedefinitions.Where(f => f.SandBoxedSolutionLocation == l.Url && f.Scope == l.Scope).ToList(); definitions.AddRange(defs); } var loadedMessage = new LocationsLoaded(location, children, activatedFeatures, definitions); return(loadedMessage); }
public string AddLoadedLocations(LocationsLoaded message) { var error = AddLocations(message.ChildLocations); AddActivatedFeatures(message.ActivatedFeatures); AddFeatureDefinitions(message.Definitions); return(error); }
//public void AddActivatedFeatures(IEnumerable<ActivatedFeature> activatedFeatures) //{ // store.AddActivatedFeatures(activatedFeatures); //} public void AddLoadedLocations(LocationsLoaded 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 bool TrackLocationsProcessed(LocationsLoaded loadedMessage) { bool finished = false; var parent = loadedMessage.Parent; foreach (Location l in loadedMessage.ChildLocations) { TrackLocationProcessed(l); } return(finished); }
public FeatureDefinitionFactoryTests() { // get 3 locations with each 4 same activated features Guid[] lIds = { TestLocations.Ids.Id001, TestLocations.Ids.Id002, TestLocations.Ids.Id003 }; Guid[] fIds = { TestFeatureDefinitions.Ids.Id004, TestFeatureDefinitions.Ids.Id001, TestFeatureDefinitions.Ids.Id002, TestFeatureDefinitions.Ids.Id003 }; var locations = TestLocations.GetLocations(lIds, fIds); Loaded3LocationsWithFirst4ActivatedFeaturesEach = new LocationsLoaded(Guid.NewGuid(), null, locations); }
public bool TrackLocationsProcessed(LocationsLoaded loadedMessage) { bool finished = false; var parent = loadedMessage.Parent; foreach (Location l in loadedMessage.ChildLocations) { TrackLocationProcessed(l); } FarmFeatureDefinitions.Processed += loadedMessage.Definitions.Count(); ActivatedFeaturesLoaded += loadedMessage.ActivatedFeatures.Count(); return(finished); }
public LocationsLoaded LoadNonFarmLocationAndChildren(Location location) { var initialLoaded = loadLocations(location); if (location.Scope == Core.Models.Enums.Scope.WebApplication && initialLoaded.ChildLocations.Count() > 0) { List <FeatureDefinition> fDefs = new List <FeatureDefinition>(initialLoaded.Definitions); List <Location> locations = new List <Location>(initialLoaded.ChildLocations); List <ActivatedFeature> features = new List <ActivatedFeature>(initialLoaded.ActivatedFeatures); foreach (Location siteCollection in initialLoaded.ChildLocations) { var child = loadLocations(siteCollection); fDefs.AddRange(child.Definitions); locations.AddRange(child.ChildLocations); features.AddRange(child.ActivatedFeatures); } var loadedMessage = new LocationsLoaded( location, locations, features, fDefs ); return(loadedMessage); } else { return(initialLoaded); } }
private void HandleLocationsLoaded([NotNull] LocationsLoaded message) { TrackLocationsProcessed(message); // if web apps are loaded, load children if (message.Parent.Scope == Enums.Scope.Farm) { foreach (Location l in message.ChildLocations) { if (l.Scope == Enums.Scope.WebApplication) { // initiate read of locations var loadWebAppChildren = new LoadLocationQuery(Id, l); LoadTask(loadWebAppChildren); } } } repository.AddLoadedLocations(message); SendProgress(); }
/// <summary> /// Loads cities from file /// </summary> private void LoadLocations() { lock (locker) { // Do not read cities again if (allLocations.Count > 0) { return; } FileStream fileStream = null; try { string stringPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "Cities.dat"); fileStream = File.OpenRead(stringPath); using (var fileReader = new StreamReader(fileStream, Encoding.UTF8)) { string line = null; while ((line = fileReader.ReadLine()) != null) { try { string[] chunks = line.Split('\t'); float latitude = float.Parse(chunks[4], CultureInfo.InvariantCulture); float longitude = float.Parse(chunks[5], CultureInfo.InvariantCulture); float elevation = float.Parse(string.IsNullOrWhiteSpace(chunks[15]) ? "0" : chunks[15], CultureInfo.InvariantCulture); TimeZoneItem timeZone = timeZones.FirstOrDefault(tz => tz.TimeZoneId.Equals(chunks[17], StringComparison.InvariantCultureIgnoreCase)); var names = new List <string>(); names.Add(chunks[1]); names.AddRange(chunks[3].Split(',')); allLocations.Add(new GeoLocation() { Names = names.ToArray(), Country = chunks[8], Elevation = elevation, Latitude = latitude, Longitude = -longitude, TimeZone = timeZone, }); } catch (Exception ex) { Log.Error($"Unable to parse geographical location, line = {line}, error: {ex}"); } } } fileStream.Close(); } catch (Exception ex) { Log.Error($"Unable to load locations list, error: {ex}"); } finally { if (fileStream != null) { fileStream.Close(); } } } LocationsLoaded?.Invoke(); }
//public void AddActivatedFeatures(IEnumerable<ActivatedFeature> activatedFeatures) //{ // store.AddActivatedFeatures(activatedFeatures); //} public void AddLoadedLocations(LocationsLoaded message) { store.AddLocations(message.ChildLocations); store.AddActivatedFeatures(message.ActivatedFeatures); store.AddFeatureDefinitions(message.Definitions); }
public void Handle([NotNull] LocationsLoaded message) { allItems.AddActivatedFeatures(message.LoadedFeatures); FilterResults(); }