protected void MapQuerierOnQueryCompleted(object sender, MapEventArgs e) { try { if (MapQueue.ContainsKey(e.Map.Id)) { MapQueue.Remove(e.Map.Id); } if (!MapCompleted.ContainsKey(e.Map.Id)) { MapCompleted.Add(e.Map.Id, e.Map); } if (MapQueue.Count == 0) { OnProgressChanged(this, new ProgressChangedEventArgs(100, null)); OnExportCompleted(this, new ExportCompletedEventArgs(OutputFileLocation, UserState, RootMap.Name)); } else { OnProgressChanged(this, new ProgressChangedEventArgs(MapCompleted.Count * 100 / (MapQueue.Count + MapCompleted.Count), null)); var nextMap = MapQueue.Values.FirstOrDefault(); if (nextMap != null) { if (!MapCompleted.ContainsKey(nextMap.Id)) { ReadNextMap(nextMap); } else { var mapArgs = new MapEventArgs { Container = e.Container, Map = nextMap }; MapQuerierOnQueryCompleted(sender, mapArgs); } } else { throw new NullReferenceException("Map in queue is null"); } } } catch (Exception ex) { OnExceptionRaised(sender, "Error occurred when querying map data", ex); } }
protected void MapQuerierOnMapAdded(object sender, MapEventArgs e) { if (!MapQueue.ContainsKey(e.Map.Id) && !MapCompleted.ContainsKey(e.Map.Id)) { MapQueue.Add(e.Map.Id, e.Map); if (ProgressChanged != null) { ProgressChanged(this, new ProgressChangedEventArgs(MapCompleted.Count * 100 / (MapQueue.Count + MapCompleted.Count), null)); } } }