public void Load(string path, bool overwriteMobile = true, bool overwriteTiles = true) { Loggers.PerformanceLogger.Debug("Loading package from {0} started.", path); FileHelper.TryDeleteFiles(new DirectoryInfo(clientConfigurationProvider.TemporaryFolderPath)); ClearAll(); DirectoryInfo pathInfo = new DirectoryInfo(path); IEnumerable <DirectoryInfo> directoriesToCopy = pathInfo.GetDirectories().Where(di => di.Name != FileNameConstants.TileFolderName && di.Name != FileNameConstants.MobilePackageFolderName); IEnumerable <FileInfo> filesToCopy = pathInfo.EnumerateFiles(); clientConfigurationProvider.CurrentTemporaryFolder = Path.Combine(clientConfigurationProvider.TemporaryFolderPath, Guid.NewGuid().ToString()); foreach (DirectoryInfo dirinfo in directoriesToCopy) { FileHelper.CopyAll(dirinfo, new DirectoryInfo(clientConfigurationProvider.CurrentTemporaryFolder)); } foreach (FileInfo fileinfo in filesToCopy) { fileinfo.CopyTo(Path.Combine(clientConfigurationProvider.CurrentTemporaryFolder, fileinfo.Name), true); } string[] allfilePaths = Directory.GetFiles(clientConfigurationProvider.CurrentTemporaryFolder, "*", SearchOption.AllDirectories); var filePathsDTO = allfilePaths.Where(p => Path.GetExtension(p) == ".model"); var filePathPackageDescriptor = allfilePaths.Where(p => Path.GetFileName(p) == FileNameConstants.ServerPackageDescriptorFileName).SingleOrDefault(); PackageDescriptor = GetServerPackageDescriptor(filePathPackageDescriptor); Loggers.PerformanceLogger.Debug("Package consistency check started."); foreach (var filecount in PackageDescriptor.FileCount) { if (!((Directory.GetFiles(path, "*" + filecount.Key, SearchOption.AllDirectories).Count(s => s.EndsWith(filecount.Key))) == filecount.Value)) { throw new IncompletePackageException(); } } Loggers.PerformanceLogger.Debug("Package consistency check finished."); DirectoryInfo tileDirectory = new DirectoryInfo(Path.Combine(path, FileNameConstants.TileFolderName)); if (tileDirectory.Exists && overwriteTiles || (tileDirectory.Exists && !Directory.Exists(clientConfigurationProvider.TileFolder))) { FileHelper.CopyAll(tileDirectory, new DirectoryInfo(clientConfigurationProvider.TileFolder), (int progress, string text) => { this.progressService.Update(LocalizationLocator.MobileLocalization.CreateMapCache, progress); }); } DirectoryInfo mobileDirectory = new DirectoryInfo(Path.Combine(path, FileNameConstants.MobilePackageFolderName)); if ((mobileDirectory.Exists && overwriteMobile) || (mobileDirectory.Exists && !Directory.Exists(clientConfigurationProvider.MobilePackageFolder))) { FileHelper.CopyAll(mobileDirectory, new DirectoryInfo(clientConfigurationProvider.MobilePackageFolder)); this.OnMobileChanged(); } //all changes to an Observable Collection must be done by the same Thread it was created by, becaus of Thread Affinity Func <ObservableCollection <XMLKeyValuePair <Guid, string> > > func = new Func <ObservableCollection <XMLKeyValuePair <Guid, string> > >(PackageDescriptor.GetObservableCollection); InspektionsroutenDictionary = (ObservableCollection <XMLKeyValuePair <Guid, string> >)Application.Current.Dispatcher.Invoke(func); OnPackageDescriptorChanged(EventArgs.Empty); Loggers.PerformanceLogger.Debug("Loading Vector-Data started."); dtoService.LoadFile(); //Vectorlayers IEnumerable <AchsenSegmentDTO> achsenSegmente = dtoService.Get <AchsenSegmentDTO>(); IEnumerable <StrassenabschnittGISDTO> strabs = dtoService.Get <StrassenabschnittGISDTO>(); IEnumerable <ZustandsabschnittGISDTO> zabs = dtoService.Get <ZustandsabschnittGISDTO>(); string achsString = geoJsonService.GenerateGeoJsonStringFromEntities(achsenSegmente); string strabString = geoJsonService.GenerateGeoJsonStringFromEntities(strabs); string zabString = geoJsonService.GenerateGeoJsonStringFromEntities(zabs); DataChangedEventArgs args = new DataChangedEventArgs(); args.AchsenGeoJson = achsString; args.StrabsGeoJson = strabString; args.ZabsGeoJson = zabString; PackageDescriptor.LayerConfig.ForEach(c => c.BasePath = clientConfigurationProvider.TileFolder); args.LayerInfo = PackageDescriptor.LayerConfig; args.ActiveInspectionRouteId = InspektionsroutenDictionary.First().Key; MobileLocalization localization = LocalizationLocator.MobileLocalization; foreach (var propertyInfo in typeof(MobileLocalization).GetProperties()) { if (propertyInfo.CanRead) { args.MobileLocalization.Add(propertyInfo.Name, propertyInfo.GetValue(localization, null).ToString()); } } string[] sldPaths; if (clientConfigurationProvider.UseLocalFiles) { sldPaths = Directory.GetFiles(".\\Mobile\\style\\sld", "*.sld", SearchOption.TopDirectoryOnly); } else { sldPaths = Directory.GetFiles(Path.Combine(clientConfigurationProvider.MobilePackageFolder, "style\\sld"), "*.sld", SearchOption.TopDirectoryOnly); } string[] sldcontent = new string[sldPaths.Length]; int i = 0; foreach (string sldpath in sldPaths) { StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(sldpath)) { String line; while ((line = sr.ReadLine()) != null) { sb.AppendLine(line); } } sldcontent[i] = sb.ToString(); i++; } args.Slds = sldcontent; formService.OnDataChanged(args); Loggers.PerformanceLogger.Debug("Loading Vector-Data finished."); Loggers.PerformanceLogger.Debug("Package loaded"); OnPackageLoaded(); }