public int PreParseForSingle(FileStream fs, ACacheStore store) { XmlReader rdr = XmlReader.Create(fs); //rdr.Settings.IgnoreWhitespace = true; int count = 0; List <String> waypoints = new List <String>(); while (rdr.Read()) { if (rdr.Name == "wpt" && rdr.IsStartElement()) { count++; } else if (rdr.Name == "waypoint" && rdr.IsStartElement()) { count++; } else if (rdr.LocalName == "name" && rdr.IsStartElement()) { waypoints.Add(ACacheStore.Escape(rdr.ReadElementContentAsString())); } } rdr.Close(); store.PurgeAllTravelBugs(waypoints.ToArray()); if (m_purgeLogs) { store.PurgeAllLogs(waypoints.ToArray()); } store.PurgeAllAttributes(waypoints.ToArray()); return(count); }
public void clearForImport(FileStream fs, ACacheStore store) { XmlReader rdr = XmlReader.Create(fs); //rdr.Settings.IgnoreWhitespace = true; List <String> waypoints = new List <String>(); while (rdr.Read()) { if (rdr.LocalName == "name" && rdr.IsStartElement()) { waypoints.Add(ACacheStore.Escape(rdr.ReadElementContentAsString())); } } rdr.Close(); store.PurgeAllTravelBugs(waypoints.ToArray()); if (m_purgeLogs) { store.PurgeAllLogs(waypoints.ToArray()); } store.PurgeAllAttributes(waypoints.ToArray()); return; }
public void Start(String filename, ACacheStore store) { this.Show (); try { m_parser.StartUpdate(store); FileStream stream = File.OpenRead(filename); m_total = m_parser.PreParseForSingle(stream, store); stream.Close(); stream = File.OpenRead(filename); m_progress = 0; m_progressCount = 0; m_timeStart = DateTime.Now; ParseFile (stream, store); stream.Close(); if (!m_parser.Cancel) m_parser.EndUpdate(store); } catch (Exception e) { this.Hide (); OCMApp.ShowException(e); this.Dispose (); } }
public void WriteGPXFile(String name, List <Geocache> caches, Dictionary <string, string> waypointmappings, ACacheStore store) { m_Store = store; FileStream stream = new System.IO.FileStream(name, FileMode.Create, FileAccess.Write, FileShare.Write, 655356); m_mappings = waypointmappings; XmlTextWriter writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8); //Pretty-print the document writer.Formatting = Formatting.Indented; writer.Indentation = 1; writer.IndentChar = '\t'; List <string> usedCacheNames = new List <string>(); string[] namesForPreSeach = new string[caches.Count]; for (int i = 0; i < caches.Count; i++) { namesForPreSeach[i] = caches[i].Name; } m_CacheLogs = CacheStore.GetCacheLogsMulti(namesForPreSeach); m_TravelBugs = CacheStore.GetTravelBugMulti(namesForPreSeach); m_Attrs = CacheStore.GetAttributesMulti(namesForPreSeach); try { // Write out XML processing directive, some applications expect this writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteStartElement("gpx", NS_GPX); writer.WriteAttributeString("creator", "OCM"); writer.WriteAttributeString("version", "1.0"); if (IsMyFinds) { writer.WriteElementString("name", NS_GPX, "My Finds Pocket Query"); } else { writer.WriteElementString("name", NS_GPX, "Cache Listing from OCM"); } writer.WriteElementString("desc", NS_GPX, "Cache Listing from OCM"); writer.WriteElementString("author", NS_GPX, "Open Cache Manager"); writer.WriteElementString("email", NS_GPX, "*****@*****.**"); writer.WriteElementString("url", NS_GPX, "http://sourceforge.net/projects/opencachemanage/"); writer.WriteElementString("urlname", NS_GPX, "Sourceforge Link"); writer.WriteElementString("time", NS_GPX, System.DateTime.Now.ToString(XSD_DT)); WriteCaches(caches, writer, usedCacheNames, name); if (m_includeChildren && !m_cancel) { List <Waypoint> points = CacheStore.GetChildWaypoints(usedCacheNames.ToArray()); foreach (Waypoint pt in points) { pt.WriteToGPX(writer, this); } } writer.WriteEndElement(); this.Complete(this, new WriteEventArgs("Done")); } catch (Exception e) { throw e; } finally { writer.Flush(); writer.Close(); } }
public void parseGPXFile(FileStream fs, ACacheStore store) { m_store = store; XmlReader reader = XmlReader.Create(fs); reader.Settings.IgnoreWhitespace = true; while (reader.Read()) { if (m_cancel) { m_store.CancelUpdate(); return; } switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "time") gpx_date = reader.ReadElementContentAsDateTime(); if (reader.Name == "loc") m_source = reader.GetAttribute("src"); if (reader.Name == "url") { string val = reader.ReadElementContentAsString(); if (val.Contains("opencaching")||val.Contains("gctour")) m_source = "opencaching"; } if (reader.Name == "wpt") { Waypoint pt = processWaypoint(reader); pt.Updated = gpx_date; m_store.AddWaypointOrCache(pt, m_preserveFound, true); if ((pt is Geocache) && (m_bookmark != null)) m_store.AddBoormarkEntry(m_bookmark,pt.Name); } if (reader.Name == "waypoint" && reader.IsStartElement()) { Waypoint pt = processLocWaypoint(reader); pt.Updated = System.DateTime.Now; m_store.AddWaypointOrCache(pt, m_preserveFound, true); if ((pt is Geocache) && (m_bookmark != null)) m_store.AddBoormarkEntry(m_bookmark,pt.Name); } break; case XmlNodeType.EndElement: break; } } reader.Close(); this.Complete(this, EventArgs.Empty); }
public void WriteToGPS(List<Geocache> cacheList, Dictionary<string,string> waypointmappings, ACacheStore store) { writer = new GPXWriter (); writer.NameMode = m_nameMode; writer.DescriptionMode = m_descMode; writer.Limit = m_Limit; writer.LogLimit = m_LogLimit; writer.IncludeChildWaypoints = true; writer.WriteAttributes = m_incAttr; if (m_format == "OCM_GPX") { if (m_file == "%auto%") { string dBShort = Utilities.GetShortFileName(store.StoreName); dBShort = dBShort.Substring(0, dBShort.Length - 4); dBShort+= ".gpx"; m_file = "/media/GARMIN/Garmin/GPX/" + dBShort; } writer.HTMLOutput = HTMLMode.GARMIN; writer.UseOCMPtTypes = true; WriteGPXFile (cacheList, waypointmappings, store); return; } else if (m_format == "delgpx") { writer.HTMLOutput = HTMLMode.PLAINTEXT; writer.UseOCMPtTypes = false; if (m_file == "%auto%") { string dBShort = Utilities.GetShortFileName(store.StoreName); dBShort = dBShort.Substring(0, dBShort.Length - 4); dBShort+= ".gpx"; m_file = "/media/EM_USERMAPS/waypoints/" + dBShort; } WriteGPXFile (cacheList, waypointmappings, store); return; } if (m_format == "edge") { writer.UseOCMPtTypes = true; writer.IncludeGroundSpeakExtensions = false; WriteGPXFile (cacheList, waypointmappings, store); return; } writer.IncludeGroundSpeakExtensions = true; writer.UseOCMPtTypes = true; writer.IncludeChildWaypoints = m_includeChildren; if (m_format == "garmin_gpi") { writer.UseOCMPtTypes = false; writer.IncludeGroundSpeakExtensions = false; if (m_forcePlainText) writer.HTMLOutput = HTMLMode.PLAINTEXT; else writer.HTMLOutput = HTMLMode.GARMIN; } else if (m_format == "garmin") { writer.IncludeGroundSpeakExtensions = false; } writer.Complete += HandleWriterComplete; String tempFile = Path.GetTempFileName (); writer.WriteWaypoint += HandleWriterWriteWaypoint; writer.WriteGPXFile (tempFile, cacheList, waypointmappings, store); this.StartSend (this, new WriteEventArgs ("Sending Waypoints to GPS")); StringBuilder builder = new StringBuilder (); builder.Append ("-i gpx -f "); builder.Append (tempFile); builder.Append (" -o "); builder.Append (m_format); if (!String.IsNullOrEmpty(m_otherBabelParams)) { builder.Append(","); builder.Append(m_otherBabelParams); } builder.Append (" -F "); builder.Append (m_file); if (writer.Cancel) { throw new Exception ("Aborted"); } ProcessStartInfo sp = new ProcessStartInfo(); sp.Arguments = builder.ToString(); sp.FileName = "gpsbabel"; Process babel = Process.Start (sp); babel.WaitForExit (); if (babel.ExitCode != 0) throw new Exception ("Failed to send caches to GPS"); this.Complete (this, new WriteEventArgs ("Complete")); }
public void StartUpdate(ACacheStore store) { store.StartUpdate(); }
/// <summary> /// Sends Geocaches to a device /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A gps profiles <see cref="GPSProfile"/> /// </param> /// <param name="includeChildren"> /// If true, include child waypoints<see cref="System.Boolean"/> /// </param> /// <param name="store"> /// The source cache store <see cref="ACacheStore"/> /// </param> public void Start(List<Geocache> caches, GPSProfile profile, bool includeChildren, ACacheStore store) { try { total = caches.Count + 1; if (profile.CacheLimit != -1 && profile.CacheLimit < caches.Count) total = profile.CacheLimit + 1; writer.Limit = profile.CacheLimit; writer.BabelFile = profile.OutputFile; writer.BabelFormat = profile.BabelFormat; writer.DescMode = profile.DescMode; writer.NameMode = profile.NameMode; writer.LogLimit = profile.LogLimit; writer.IncludeAttributes = profile.IncludeAttributes; writer.OtherBabelParams = profile.OtherProperties; writer.IncludeChildren = includeChildren; writer.ForcePlainText = profile.ForcePlainText; OCMApp.UpdateGUIThread(); writer.WriteToGPS (caches, profile.WaypointMappings, store); this.Show (); } catch (Exception e) { this.Hide (); OCMApp.ShowException(e); } }
public void SetDBFile(string filename, bool isNew) { if (!isNew) CheckDBFile(filename); FilterList advanced = null; List<FilterList> comboFilt = null; if (m_Store != null) { advanced = m_Store.AdvancedFilters; comboFilt = m_Store.CombinationFilter; m_Store.Dispose(); } m_Store = new FileStore(filename); m_Store.AdvancedFilters = advanced; m_Store.CombinationFilter = comboFilt; m_Config.DBFile = filename; m_Window.Title = Utilities.GetShortFileName(filename) + "- OCM"; }
public void InitializeApp(string filename, bool quitAfterImport) { m_Store = new FileStore(m_Config.DBFile); InitalizeTracing (); m_Locations = LocationList.LoadLocationList(); m_QuickFilters = QuickFilters.LoadQuickFilters(); m_Profiles = GPSProfileList.LoadProfileList(); m_Tools = EToolList.LoadEToolList(); m_Bookmarks = new BookmarkManager(this); m_CentreLat = AppConfig.LastLat; m_CentreLon = AppConfig.LastLon; m_CentreName = AppConfig.LastName; m_Window = new OCMMainWindow(this); QuickFilter startup = m_QuickFilters.GetFilter(AppConfig.StartupFilter); if (startup != null) m_Window.CacheList.ApplyInitalQuickFilter(startup); if (filename != null) { if (filename.EndsWith(".zip")) ImportZip(filename); else ImportGPXFile(filename); if (quitAfterImport) this.End(); else ShowMainWindow(); } else { m_splash = new OCMSplash(); m_splash.Show(); UpdateGUIThread(); m_splash.Preload(this, startup); } }
public void CreateDB() { FileChooserDialog dlg = new FileChooserDialog (Catalog.GetString ("Create database"), null, FileChooserAction.Save, Catalog.GetString ("Cancel"), ResponseType.Cancel, Catalog.GetString ("Save"), ResponseType.Accept); dlg.SetCurrentFolder (AppConfig.DataDirectory); dlg.CurrentName = "newdb.ocm"; FileFilter filter = new FileFilter (); filter.Name = "OCM Databases"; filter.AddPattern ("*.ocm"); dlg.AddFilter (filter); if (dlg.Run () == (int)ResponseType.Accept) { if (System.IO.File.Exists (dlg.Filename)) { dlg.Hide (); MessageDialog mdlg = new MessageDialog (null, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, Catalog.GetString ("Are you sure you want to overwrite '{0}'"), dlg.Filename); if ((int)ResponseType.No == mdlg.Run ()) { mdlg.Hide (); return; } else { mdlg.Hide (); System.IO.File.Delete (dlg.Filename); } } dlg.Hide(); AppConfig.DBFile = dlg.Filename; m_Store = new FileStore(dlg.Filename); return; } dlg.Destroy (); return; }
public void clearForImport(FileStream fs, ACacheStore store) { XmlReader rdr = XmlReader.Create(fs); rdr.Settings.IgnoreWhitespace = true; List<String> waypoints = new List<String>(); while (rdr.Read()) { if (rdr.LocalName == "name" && rdr.IsStartElement()) { waypoints.Add(ACacheStore.Escape(rdr.ReadElementContentAsString())); } } rdr.Close(); store.PurgeAllTravelBugs(waypoints.ToArray()); if (m_purgeLogs) store.PurgeAllLogs(waypoints.ToArray()); store.PurgeAllAttributes(waypoints.ToArray()); return; }
public int PreParseForSingle(FileStream fs, ACacheStore store) { XmlReader rdr = XmlReader.Create(fs); rdr.Settings.IgnoreWhitespace = true; int count = 0; List<String> waypoints = new List<String>(); while (rdr.Read()) { if (rdr.Name == "wpt" && rdr.IsStartElement()) { count++; } else if (rdr.Name == "waypoint" && rdr.IsStartElement()) { count++; } else if (rdr.LocalName == "name" && rdr.IsStartElement()) { waypoints.Add(ACacheStore.Escape(rdr.ReadElementContentAsString())); } } rdr.Close(); store.PurgeAllTravelBugs(waypoints.ToArray()); if (m_purgeLogs) store.PurgeAllLogs(waypoints.ToArray()); store.PurgeAllAttributes(waypoints.ToArray()); return count; }
private void WriteGPXFile(List <Geocache> cacheList, Dictionary <string, string> waypointmappings, ACacheStore store) { writer.Complete += HandleWriterComplete; writer.WriteWaypoint += HandleWriterWriteWaypoint; writer.WriteGPXFile(m_file, cacheList, waypointmappings, store); this.Complete(this, new WriteEventArgs("Complete")); return; }
public void WriteToGPS(List <Geocache> cacheList, Dictionary <string, string> waypointmappings, ACacheStore store) { writer = new GPXWriter(); writer.NameMode = m_nameMode; writer.DescriptionMode = m_descMode; writer.Limit = m_Limit; writer.LogLimit = m_LogLimit; writer.IncludeChildWaypoints = true; writer.WriteAttributes = m_incAttr; if (m_format == "OCM_GPX") { if (m_file == "%auto%") { string dBShort = Utilities.GetShortFileName(store.StoreName); dBShort = dBShort.Substring(0, dBShort.Length - 4); dBShort += ".gpx"; m_file = "/media/GARMIN/Garmin/GPX/" + dBShort; } writer.HTMLOutput = HTMLMode.GARMIN; writer.UseOCMPtTypes = true; WriteGPXFile(cacheList, waypointmappings, store); return; } else if (m_format == "delgpx") { writer.HTMLOutput = HTMLMode.PLAINTEXT; writer.UseOCMPtTypes = false; if (m_file == "%auto%") { string dBShort = Utilities.GetShortFileName(store.StoreName); dBShort = dBShort.Substring(0, dBShort.Length - 4); dBShort += ".gpx"; m_file = "/media/EM_USERMAPS/waypoints/" + dBShort; } WriteGPXFile(cacheList, waypointmappings, store); return; } if (m_format == "edge") { writer.UseOCMPtTypes = true; writer.IncludeGroundSpeakExtensions = false; WriteGPXFile(cacheList, waypointmappings, store); return; } writer.IncludeGroundSpeakExtensions = true; writer.UseOCMPtTypes = true; writer.IncludeChildWaypoints = m_includeChildren; if (m_format == "garmin_gpi") { writer.UseOCMPtTypes = false; writer.IncludeGroundSpeakExtensions = false; if (m_forcePlainText) { writer.HTMLOutput = HTMLMode.PLAINTEXT; } else { writer.HTMLOutput = HTMLMode.GARMIN; } } else if (m_format == "garmin") { writer.IncludeGroundSpeakExtensions = false; } writer.Complete += HandleWriterComplete; String tempFile = Path.GetTempFileName(); writer.WriteWaypoint += HandleWriterWriteWaypoint; writer.WriteGPXFile(tempFile, cacheList, waypointmappings, store); this.StartSend(this, new WriteEventArgs("Sending Waypoints to GPS")); StringBuilder builder = new StringBuilder(); builder.Append("-i gpx -f "); builder.Append(tempFile); builder.Append(" -o "); builder.Append(m_format); if (!String.IsNullOrEmpty(m_otherBabelParams)) { builder.Append(","); builder.Append(m_otherBabelParams); } builder.Append(" -F \""); builder.Append(m_file.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("$", "\\$").Replace("`", "\\`")); builder.Append("\""); if (writer.Cancel) { throw new Exception("Aborted"); } ProcessStartInfo sp = new ProcessStartInfo(); sp.Arguments = builder.ToString(); sp.FileName = "gpsbabel"; Process babel = Process.Start(sp); babel.WaitForExit(); if (babel.ExitCode != 0) { throw new Exception("Failed to send caches to GPS"); } this.Complete(this, new WriteEventArgs("Complete")); }
private void ShowOpenDBDialog() { try { FileChooserDialog dlg = new FileChooserDialog (Catalog.GetString ("Open Database"), null, FileChooserAction.Open, Catalog.GetString ("Cancel"), ResponseType.Cancel, Catalog.GetString ("Open"), ResponseType.Accept); dlg.SetCurrentFolder (AppConfig.DataDirectory); FileFilter filter = new FileFilter (); filter.Name = "OCM Databases"; filter.AddPattern ("*.ocm"); dlg.AddFilter (filter); if (dlg.Run () == (int)ResponseType.Accept) { dlg.Hide (); AppConfig.DBFile = dlg.Filename; m_Store = new FileStore(dlg.Filename); } else { dlg.Hide (); } } catch (Exception) { return; } }
/// <summary> /// Sends Geocaches to a device, always including child waypoints /// </summary> /// <param name="caches"> /// A list of geocaches <see cref="List<Geocache>"/> /// </param> /// <param name="profile"> /// A GPS profile <see cref="GPSProfile"/> /// </param> /// <param name="store"> /// The source CacheStore <see cref="ACacheStore"/> /// </param> public void Start(List<Geocache> caches, GPSProfile profile, ACacheStore store) { Start(caches, profile, true, store); }
public void Start(String filename, List<Geocache> list, Dictionary<string,string> wmappings, ACacheStore store) { total = list.Count; if (m_writer.Limit != -1 && m_writer.Limit < total) total = m_writer.Limit; fileLabel.Markup = Catalog.GetString("<b>File: </b>") + filename; m_writer.WriteGPXFile(filename, list, wmappings, store); }
public void parseGPXFile(FileStream fs, ACacheStore store) { m_store = store; XmlReader reader = XmlReader.Create(fs); //reader.Settings.IgnoreWhitespace = true; while (reader.Read()) { if (m_cancel) { m_store.CancelUpdate(); return; } switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "time") { gpx_date = reader.ReadElementContentAsDateTime(); } if (reader.Name == "loc") { m_source = reader.GetAttribute("src"); } if (reader.Name == "url") { string val = reader.ReadElementContentAsString(); if (val.Contains("opencaching") || val.Contains("gctour")) { m_source = "opencaching"; } } if (reader.Name == "wpt") { Waypoint pt = processWaypoint(reader); pt.Updated = gpx_date; m_store.AddWaypointOrCache(pt, m_preserveFound, true); if ((pt is Geocache) && (m_bookmark != null)) { m_store.AddBoormarkEntry(m_bookmark, pt.Name); } } if (reader.Name == "waypoint" && reader.IsStartElement()) { Waypoint pt = processLocWaypoint(reader); pt.Updated = System.DateTime.Now; m_store.AddWaypointOrCache(pt, m_preserveFound, true); if ((pt is Geocache) && (m_bookmark != null)) { m_store.AddBoormarkEntry(m_bookmark, pt.Name); } } break; case XmlNodeType.EndElement: break; } } reader.Close(); this.Complete(this, EventArgs.Empty); }
public void WriteGPXFile(String name, List<Geocache> caches, Dictionary<string,string> waypointmappings, ACacheStore store) { m_Store = store; FileStream stream = new System.IO.FileStream(name, FileMode.Create, FileAccess.Write, FileShare.Write, 655356); m_mappings = waypointmappings; XmlTextWriter writer = new XmlTextWriter (stream, System.Text.Encoding.UTF8); //Pretty-print the document writer.Formatting = Formatting.Indented; writer.Indentation = 1; writer.IndentChar = '\t'; List<string> usedCacheNames = new List<string>(); string[] namesForPreSeach = new string[caches.Count]; for(int i=0; i < caches.Count; i++) { namesForPreSeach[i] = caches[i].Name; } m_CacheLogs = CacheStore.GetCacheLogsMulti(namesForPreSeach); m_TravelBugs = CacheStore.GetTravelBugMulti(namesForPreSeach); m_Attrs = CacheStore.GetAttributesMulti(namesForPreSeach); try { // Write out XML processing directive, some applications expect this writer.WriteRaw ("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteStartElement ("gpx", NS_GPX); writer.WriteAttributeString("creator", "OCM"); writer.WriteAttributeString("version", "1.0"); if (IsMyFinds) writer.WriteElementString("name", NS_GPX, "My Finds Pocket Query"); else writer.WriteElementString ("name", NS_GPX, "Cache Listing from OCM"); writer.WriteElementString ("desc", NS_GPX, "Cache Listing from OCM"); writer.WriteElementString ("author", NS_GPX, "Open Cache Manager"); writer.WriteElementString ("email", NS_GPX, "*****@*****.**"); writer.WriteElementString ("url", NS_GPX, "http://sourceforge.net/projects/opencachemanage/"); writer.WriteElementString ("urlname", NS_GPX, "Sourceforge Link"); writer.WriteElementString ("time", NS_GPX, System.DateTime.Now.ToString (XSD_DT)); WriteCaches (caches, writer, usedCacheNames); if (m_includeChildren && !m_cancel) { List<Waypoint> points = CacheStore.GetChildWaypoints(usedCacheNames.ToArray()); foreach(Waypoint pt in points) { pt.WriteToGPX(writer, this); } } writer.WriteEndElement (); this.Complete(this, new WriteEventArgs("Done")); } catch (Exception e) { throw e; } finally { writer.Flush (); writer.Close (); } }
public void EndUpdate(ACacheStore store) { store.CompleteUpdate(); }
private void ParseFile(FileStream fs, ACacheStore store) { fileLabel.Markup = Catalog.GetString("<b>File: </b>") + fs.Name; m_parser.parseGPXFile (fs, store); }
public CleanupManager(ACacheStore astore, List<Geocache> caches) { logsToDelete = new List<string>(); cachesToCleanup = caches; store = astore; }
public void StartMulti(String directoryPath, ACacheStore store, bool deleteOnCompletion) { m_isMulti = true; m_timeStart = DateTime.Now; string[] files = Directory.GetFiles(directoryPath); m_parser.StartUpdate(store); // Count total files m_progress = 0; m_progressCount = 0; m_total = 0; multiFileLabel.Visible = true; List<string> dirs = new List<string>(); // Prescan for zip files and uncompress for (int i=0; i < files.Length; i++) { if (files[i].EndsWith(".zip")) { this.progressbar6.Text = Catalog.GetString("Unzipping"); DirectoryInfo info = Directory.CreateDirectory(files[i].Substring(0, files[i].Length -4)); dirs.Add(info.FullName); multiFileLabel.Text = Catalog.GetString("Unizpping"); this.waypointName.Markup = "<i>" + Catalog.GetString("Unzipping") + ":" + files[i] + "</i>"; while (Gtk.Application.EventsPending ()) Gtk.Application.RunIteration (false); ProcessStartInfo start = new ProcessStartInfo(); start.FileName = "unzip"; start.Arguments = "-o \"" + files[i] + "\" -d \"" + info.FullName + "\""; Process unzip = Process.Start(start); while (!unzip.HasExited) { // Do nothing until exit } if (deleteOnCompletion) { File.Delete(files[i]); } } } // Rescan for all GPX files, including those uncompressed by ZIP files List<string> fileList = new List<string>(); string[] directories = Directory.GetDirectories(directoryPath); BuildFileList (directoryPath, fileList); foreach (string dir in directories) { BuildFileList(dir, fileList); } int currCount = 0; foreach (string file in fileList) { if (file.EndsWith(".gpx")) { currCount++; //Clean out attributes,tbs,and logs that will be overwritten if (m_parser.Cancel) return; FileStream fs = System.IO.File.OpenRead (file); m_parser.clearForImport(fs, store); fs.Close(); // Need to reopen the file fs = System.IO.File.OpenRead (file); multiFileLabel.Text = String.Format(Catalog.GetString("Processing File {0} of {1}"), currCount, fileList.Count); ParseFile(fs, store); fs.Close(); if (deleteOnCompletion) File.Delete(file); } } if (deleteOnCompletion) { foreach (string dir in dirs) { Directory.Delete(dir); } } m_parser.EndUpdate(store); HandleCompletion(); }
private void WriteGPXFile(List<Geocache> cacheList, Dictionary<string,string> waypointmappings, ACacheStore store) { writer.Complete += HandleWriterComplete; writer.WriteWaypoint += HandleWriterWriteWaypoint; writer.WriteGPXFile (m_file, cacheList, waypointmappings,store); this.Complete (this, new WriteEventArgs ("Complete")); return; }