protected override void ImportMethod() { using (Utils.ProgressBlock fixpr = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, 0)) { for (int fileindex = 0; fileindex < _filenames.Length; fileindex++) { Utils.GPXProcessor gpxProcessor = new Utils.GPXProcessor(Core); Utils.GPXProcessor.ResultData res = gpxProcessor.ProcessGeocachingComGPXFile(_filenames[fileindex]); List<string> ignoredGeocaches = new List<string>(); List<string> ignoredLogs = new List<string>(); if (res != null && res.Geocaches.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Geocaches.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Geocache gc in res.Geocaches) { if (!AddGeocache(gc, gpxProcessor.CachesGPXVersion)) { ignoredGeocaches.Add(gc.Code); } index++; procStep++; if (procStep >= 100) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Geocaches.Count, index); procStep = 0; } } } } if (res != null && res.Waypoints.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGWAYPOINTS, res.Geocaches.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Waypoint wp in res.Waypoints) { if (!ignoredGeocaches.Contains(wp.GeocacheCode)) { AddWaypoint(wp); } index++; procStep++; if (procStep >= 200) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGWAYPOINTS, res.Waypoints.Count, index); procStep = 0; } } } } if (res != null && res.Logs.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGLOGS, res.Logs.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Log l in res.Logs) { if (!ignoredGeocaches.Contains(l.GeocacheCode)) { AddLog(l); } else { ignoredLogs.Add(l.ID); } index++; procStep++; if (procStep >= 500) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGLOGS, res.Logs.Count, index); procStep = 0; } } } } if (res != null && res.LogImages.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGLOGIMAGES, res.LogImages.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.LogImage l in res.LogImages) { if (!ignoredLogs.Contains(l.LogID)) { AddLogImage(l); } index++; procStep++; if (procStep >= 100) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGLOGIMAGES, res.LogImages.Count, index); procStep = 0; } } } } fixpr.UpdateProgress(STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, fileindex + 1); } } }
protected override void ImportMethod() { using (Utils.ProgressBlock fixpr = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, 0)) { for (int fileindex = 0; fileindex < _filenames.Length; fileindex++) { Utils.GPXProcessor gpxProcessor = new Utils.GPXProcessor(Core); Utils.GPXProcessor.ResultData res = gpxProcessor.ProcessGeocachingComGPXFile(_filenames[fileindex]); List <string> ignoredGeocaches = new List <string>(); List <string> ignoredLogs = new List <string>(); if (res != null && res.Geocaches.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Geocaches.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Geocache gc in res.Geocaches) { if (!AddGeocache(gc, gpxProcessor.CachesGPXVersion)) { ignoredGeocaches.Add(gc.Code); } index++; procStep++; if (procStep >= 100) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGGEOCACHES, res.Geocaches.Count, index); procStep = 0; } } } } if (res != null && res.Waypoints.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGWAYPOINTS, res.Geocaches.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Waypoint wp in res.Waypoints) { if (!ignoredGeocaches.Contains(wp.GeocacheCode)) { AddWaypoint(wp); } index++; procStep++; if (procStep >= 200) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGWAYPOINTS, res.Waypoints.Count, index); procStep = 0; } } } } if (res != null && res.Logs.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGLOGS, res.Logs.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.Log l in res.Logs) { if (!ignoredGeocaches.Contains(l.GeocacheCode)) { AddLog(l); } else { ignoredLogs.Add(l.ID); } index++; procStep++; if (procStep >= 500) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGLOGS, res.Logs.Count, index); procStep = 0; } } } } if (res != null && res.LogImages.Count > 0) { using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORTING, STR_IMPORTINGLOGIMAGES, res.LogImages.Count, 0)) { int index = 0; int procStep = 0; foreach (Framework.Data.LogImage l in res.LogImages) { if (!ignoredLogs.Contains(l.LogID)) { AddLogImage(l); } index++; procStep++; if (procStep >= 100) { progress.UpdateProgress(STR_IMPORTING, STR_IMPORTINGLOGIMAGES, res.LogImages.Count, index); procStep = 0; } } } } fixpr.UpdateProgress(STR_IMPORTING, STR_IMPORTINGDATA, _filenames.Length, fileindex + 1); } } }