public static List<CacheLog> GetLogs(String fnFile, String OwnerId) { List<CacheLog> logs = new List<CacheLog>(); FileStream fstream = File.OpenRead(fnFile); TextReader reader = new StreamReader(fnFile, Encoding.Unicode); while (reader.Peek() > 0) { String logLine = reader.ReadLine(); if (String.IsNullOrEmpty(logLine)) continue; CacheLog log = new CacheLog(); String[] parts = logLine.Split(','); log.CacheCode = parts[0]; log.LogDate = DateTime.Parse(parts[1]); log.LogStatus = parts[2]; StringBuilder message = new StringBuilder(); if (parts.Length > 4) { RebuildLogMessage (parts); } if (!logLine.EndsWith("\"")) { if (parts[3] != "\"") message.Append(parts[3].Substring(1)); bool endReached = false; do { logLine = reader.ReadLine(); if (logLine == "\"") { endReached = true; } if (logLine.EndsWith("\"")) { endReached = true; message.Append(logLine.Substring(0, logLine.Length -1)); } else { message.Append(logLine); } message.Append('\n'); } while (!endReached); } else { if (parts[3].Length > 2) message.Append(parts[3].Substring(1,parts[3].Length -2)); } log.LogMessage = message.ToString(); log.LogKey = parts[0] + log.LogDate.ToFileTime().ToString(); log.LoggedBy = "OCM"; log.FinderID = OwnerId; logs.Add(log); } reader.Close(); fstream.Close(); return logs; }
public static void WriteToFile(CacheLog log, String fnFile) { List <CacheLog> logs = new List <CacheLog>(); logs.Add(log); WriteToFile(logs, fnFile); }
private void ParseTerraLog(ref Geocache cache, XmlReader reader, ref bool logsChecked) { CacheLog log = new CacheLog(); bool breakLoop = false; log.LogID = reader.GetAttribute("id"); log.LogKey = cache.Name + log.LogID; while (!breakLoop && reader.Read()) { if (reader.LocalName == "date") { log.LogDate = reader.ReadElementContentAsDateTime(); } else if (reader.LocalName == "type") { log.LogStatus = reader.ReadElementContentAsString(); } else if (reader.LocalName == "user") { log.FinderID = reader.GetAttribute("id"); log.LoggedBy = reader.ReadElementContentAsString(); if (m_ownid.Contains(log.FinderID) && log.LogStatus == "find") { cache.Symbol = "Geocache Found"; } else if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "find") { cache.Symbol = "Geocache Found"; } } else if (reader.LocalName == "entry") { log.Encoded = false; log.LogMessage = reader.ReadElementContentAsString(); log.LogMessage = log.LogMessage.Replace(">", ">"); log.LogMessage = log.LogMessage.Replace("<", "<"); log.LogMessage = log.LogMessage.Replace("&", "&"); } else if (reader.LocalName == "log") { breakLoop = true; } } if (!logsChecked) { if (log.LogStatus == "Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find") { cache.CheckNotes = true; logsChecked = true; } else if (log.LogStatus != "Write Note" && log.LogStatus != "Note") { cache.CheckNotes = false; logsChecked = true; } } m_store.AddLog(cache.Name, log); }
public void ProcessOfflineLog(Geocache cache, CacheLog log, bool ftf) { FieldNotesHandler.WriteToFile (log, Config.FieldNotesFile); if (cache == null) return; m_app.CacheStore.AddLog (log.CacheCode, log); if (log.LogStatus == "Found it") { cache.DNF = false; cache.FTF = ftf; cache.Symbol = "Geocache Found"; m_app.CacheStore.AddWaypointOrCache (cache, false, false); } else if (log.LogStatus == "Didn't find it") { cache.DNF = true; cache.FTF = false; cache.Symbol = "Geocache"; m_app.CacheStore.AddWaypointOrCache (cache, false, false); } else if (log.LogStatus == "Needs Maintenance") { cache.CheckNotes = true; } }
private void LogFindOffline() { OfflineLogDialog dlg = new OfflineLogDialog (); dlg.MainWin = this; CacheLog log = new CacheLog (); log.CacheCode = CacheList.SelectedCache.Name; log.LogDate = m_app.LoggingDate; log.LogStatus = "Found it"; log.LoggedBy = "OCM"; log.LogKey = CacheList.SelectedCache.Name + "-ofl"; log.LogMessage = String.Empty; dlg.Log = log; if ((int)ResponseType.Ok == dlg.Run ()) { log = dlg.Log; ProcessOfflineLog (CacheList.SelectedCache, log, dlg.FTF); dlg.Hide (); } dlg.Hide (); HandleCacheListSelectionChanged(this, new CacheEventArgs(CacheList.SelectedCache)); }
private void GenerateFindLog(MarkFoundDialog dlg, Geocache cache, bool isDNF) { m_app.LoggingDate = dlg.LogDate; CacheLog log = new CacheLog (); log.FinderID = m_app.OwnerIDs[0]; log.LogDate = dlg.LogDate; log.LoggedBy = "OCM"; if (isDNF) log.LogStatus = "Didn't find it"; else log.LogStatus = "Found it"; log.LogMessage = "AUTO LOG: OCM"; log.LogKey = cache.Name + log.LogDate.ToFileTime ().ToString (); m_app.CacheStore.AddLog (cache.Name, log); }
public abstract void AddLog(string parent, CacheLog log);
public void AddLogAtomic(String cachename, CacheLog log) { IDbTransaction trans = StartUpdate(); AddLog(cachename, log); EndUpdate(trans); }
/// <summary> /// Updates all info panes with the current cache information /// </summary> /// <param name="val"> /// A geocache object <see cref="CacheLog"/> /// </param> private void UpdateCacheInfo(CacheLog val) { Geocache cache = m_caches[val.CacheCode]; StringBuilder builder = new StringBuilder(); builder.Append("<b>"); builder.Append(cache.Name); builder.Append(":"); builder.Append(cache.CacheName); if (!String.IsNullOrEmpty(cache.PlacedBy)) { builder.Append(Catalog.GetString(" by ")); builder.Append(cache.PlacedBy); } builder.Append("</b><br/>"); builder.Append(Geocache.GetCTypeString(cache.TypeOfCache)); builder.Append("<br/><br/>"); builder.Append(cache.ShortDesc); builder.Append("<br/><br/>"); builder.Append(cache.LongDesc); cacheDesc.HTML = builder.ToString(); List<CacheLog> logs = m_Win.App.CacheStore.GetCacheLogs(cache.Name); builder = new StringBuilder(); foreach(CacheLog log in logs) { builder.Append(log.toHTML()); } cacheLog.HTML = builder.ToString(); mapView.ClearCaches(); mapView.AddMarker(cache, false); List<Waypoint> children = m_Win.App.CacheStore.GetChildWaypoints(new string[]{cache.Name}); ListStore cmodel = waypointCombo.Model as ListStore; m_waypoints.Clear(); cmodel.Clear(); waypointCombo.AppendText(cache.Name); cacheNotes.SetCache(cache); firstToFindCheck.Toggled -= OnFTFCheck; firstToFindCheck.Active = cache.FTF; firstToFindCheck.Toggled += OnFTFCheck; if (val.LogStatus == "Found it") firstToFindCheck.Sensitive = true; else firstToFindCheck.Sensitive = false; logChoice.Changed -= OnLogTypeChange; SetLogChoice(); logChoice.Changed += OnLogTypeChange; m_waypoints.Add(cache.Name, cache); foreach(Waypoint pt in children) { waypointCombo.AppendText(pt.Name); m_waypoints.Add(pt.Name, pt); } waypointCombo.Active = 0; }
protected virtual void OnCloseClick(object sender, System.EventArgs e) { if (hasUnsaved) { MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, Catalog.GetString("You have unsaved changes that will be lost. Do you wish to save?\n")); if ((int) (ResponseType.Yes) == dlg.Run()) { SaveLogChanges(); } dlg.Hide(); } m_currLog = null; m_caches = null; this.Hide(); if (needsRefresh) m_Win.RefreshCacheList(); }
private void ParseCacheLog(ref Geocache cache, XmlReader reader, ref bool logsChecked) { CacheLog log = new CacheLog(); log.LogID = reader.GetAttribute("id"); log.LogKey = cache.Name + log.LogID; bool breakLoop = false; while (!breakLoop && reader.Read()) { if ((reader.LocalName == "date" || reader.LocalName == "time")) { string date = reader.ReadString(); if (date.Contains("/")) log.LogDate = DateTime.ParseExact(date, "MM/dd/yyyy'T'HH:mm:ss",CultureInfo.InvariantCulture); else log.LogDate = DateTime.Parse(date); } else if (reader.LocalName == "type") { log.LogStatus = reader.ReadString(); if (log.FinderID == m_ownid && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; } else if (log.LoggedBy == m_ownid && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; } } else if ((reader.LocalName == "finder" || reader.LocalName == "geocacher")) { log.FinderID = reader.GetAttribute("id"); log.LoggedBy = reader.ReadString(); } else if (reader.LocalName == "text" && reader.IsStartElement()) { if (reader.GetAttribute("encoded") != null) log.Encoded = Boolean.Parse(reader.GetAttribute("encoded")); else log.Encoded = false; log.LogMessage = reader.ReadString(); } else if (reader.LocalName == "log") { breakLoop = true; } } if (log.LoggedBy == "GSAK" && log.LogStatus == "Other") { if (log.LogMessage.Trim() == "Notes:") { // Empty note, ignore return; } // Convert GSAK notes into OCM notes cache.Notes += log.LogMessage; cache.Notes += "----------\n"; return; } System.Console.WriteLine("Adding log:" + log.LogKey); m_store.AddLog(cache.Name, log); if (!logsChecked) { if (log.LogStatus=="Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find") { cache.CheckNotes = true; logsChecked = true; } else if (log.LogStatus != "Write Note" && log.LogStatus != "Note") { cache.CheckNotes = false; logsChecked = true; } } }
public static List <CacheLog> GetLogs(String fnFile, String OwnerId) { FieldState fieldState = FieldState.Code; MessageState messageState = MessageState.Start; List <CacheLog> logs = new List <CacheLog>(); StringBuilder code = new StringBuilder(); StringBuilder logDate = new StringBuilder(); StringBuilder logStatus = new StringBuilder(); StringBuilder logMessage = new StringBuilder(); FileStream fstream = File.OpenRead(fnFile); TextReader reader = new StreamReader(fnFile, Encoding.Unicode); while (reader.Peek() > 0) { int c = reader.Read(); switch (fieldState) { case FieldState.Code: if (c == ',') { fieldState = FieldState.Date; } else if (c == '\n' || c == '\r') { code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } else { code.Append((char)c); } break; case FieldState.Date: if (c == ',') { fieldState = FieldState.Type; } else if (c == '\n' || c == '\r') { code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } else { logDate.Append((char)c); } break; case FieldState.Type: if (c == ',') { fieldState = FieldState.Comment; messageState = MessageState.Start; } else if (c == '\n' || c == '\r') { code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } else { logStatus.Append((char)c); } break; case FieldState.Comment: switch (messageState) { case MessageState.Start: if (c == '"') { messageState = MessageState.InQuotes; } else { reader.ReadLine(); code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } break; case MessageState.InQuotes: if (c == '"') { messageState = MessageState.OutQuotes; } else if (c != '\r') { logMessage.Append((char)c); } break; case MessageState.OutQuotes: if (c == '"') { logMessage.Append((char)c); messageState = MessageState.InQuotes; } else if (c == '\n' || c == '\r') { CacheLog log = new CacheLog(); log.CacheCode = code.ToString(); log.LogDate = DateTime.Parse(logDate.ToString()); log.LogStatus = logStatus.ToString(); log.LogMessage = logMessage.ToString(); log.LogKey = log.CacheCode + log.LogDate.ToFileTime().ToString(); log.LoggedBy = "OCM"; log.FinderID = OwnerId; logs.Add(log); code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } else { code.Length = 0; logDate.Length = 0; logStatus.Length = 0; logMessage.Length = 0; fieldState = FieldState.Code; } break; } break; } } reader.Close(); fstream.Close(); return(logs); }
/// <summary> /// Updates Cache Status /// </summary> /// <param name="cache"> /// A <see cref="Geocache"/> /// </param> /// <param name="log"> /// A <see cref="CacheLog"/> /// </param> public void UpdateCache(Geocache cache, CacheLog log) { if (cache == null) return; m_Win.App.CacheStore.AddLog (log.CacheCode, log); if (log.LogStatus == "Found it") { cache.DNF = false; cache.FTF = false; cache.Symbol = "Geocache Found"; m_Win.App.CacheStore.AddWaypointOrCache (cache, false, false); } else if (log.LogStatus == "Didn't find it") { cache.DNF = true; cache.FTF = false; cache.Symbol = "Geocache"; m_Win.App.CacheStore.AddWaypointOrCache (cache, false, false); } else if (log.LogStatus == "Needs Maintenance") { cache.CheckNotes = true; } }
public CacheLog GetLastFindLogByYou(Geocache cache, String ownerID) { IDbConnection conn = OpenConnection(); IDbCommand command = conn.CreateCommand(); command.CommandText = String.Format(LAST_FIND_BY_YOU, cache.Name, ownerID); IDataReader rdr = command.ExecuteReader(); CacheLog log = new CacheLog(); while (rdr.Read()) { log.LogDate = DateTime.Parse(rdr.GetString(0)); log.LoggedBy = rdr.GetString(1); log.LogMessage = rdr.GetString(2); log.LogStatus = rdr.GetString(3); log.FinderID = rdr.GetString(4); String encoded = rdr.GetString(5); log.Encoded = Boolean.Parse(encoded); log.LogID = rdr.GetString(6); log.LogKey = rdr.GetString(7); } CloseConnection(ref rdr, ref command, ref conn); return log; }
public List<CacheLog> GetCacheLogs(String cachename) { List<CacheLog> logs = new List<CacheLog>(); IDbConnection conn = OpenConnection(); IDbCommand cmd = conn.CreateCommand(); cmd.CommandText = String.Format(GET_LOGS, cachename); IDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { CacheLog log = new CacheLog(); log.LogDate = DateTime.Parse(rdr.GetString(0)); log.LoggedBy = rdr.GetString(1); log.LogMessage = rdr.GetString(2); log.LogStatus = rdr.GetString(3); log.FinderID = rdr.GetString(4); String encoded = rdr.GetString(5); log.Encoded = Boolean.Parse(encoded); log.LogID = rdr.GetString(6); log.LogKey = rdr.GetString(7); logs.Add(log); } CloseConnection(ref rdr, ref cmd, ref conn); return logs; }
private void ParseTerraLog(ref Geocache cache, XmlReader reader,ref bool logsChecked) { CacheLog log = new CacheLog(); bool breakLoop = false; log.LogID = reader.GetAttribute("id"); log.LogKey = cache.Name + log.LogID; while (!breakLoop && reader.Read()) { if (reader.LocalName == "date") { log.LogDate = reader.ReadElementContentAsDateTime(); } else if (reader.LocalName == "type") { log.LogStatus = reader.ReadElementContentAsString(); } else if (reader.LocalName == "user") { log.FinderID = reader.GetAttribute("id"); log.LoggedBy = reader.ReadElementContentAsString(); if (log.FinderID == m_ownid && log.LogStatus == "find") { cache.Symbol = "Geocache Found"; } else if (log.LoggedBy == m_ownid && log.LogStatus == "find") { cache.Symbol = "Geocache Found"; } } else if (reader.LocalName == "entry") { log.Encoded = false; log.LogMessage = reader.ReadElementContentAsString(); log.LogMessage = log.LogMessage.Replace(">", ">"); log.LogMessage = log.LogMessage.Replace("<", "<"); log.LogMessage = log.LogMessage.Replace("&", "&"); } else if (reader.LocalName == "log") { breakLoop = true; } } if (!logsChecked) { if (log.LogStatus=="Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find") { cache.CheckNotes = true; logsChecked = true; } else if (log.LogStatus != "Write Note" && log.LogStatus != "Note") { cache.CheckNotes = false; logsChecked = true; } } m_store.AddLog(cache.Name, log); }
private void ParseCacheLog(ref Geocache cache, XmlReader reader, ref bool logsChecked) { CacheLog log = new CacheLog(); log.LogID = reader.GetAttribute("id"); log.LogKey = cache.Name + log.LogID; bool breakLoop = false; while (!breakLoop && reader.Read()) { if ((reader.LocalName == "date" || reader.LocalName == "time")) { string date = reader.ReadString(); if (date.Contains("/")) { log.LogDate = DateTime.ParseExact(date, "MM/dd/yyyy'T'HH:mm:ss", CultureInfo.InvariantCulture); } else { log.LogDate = DateTime.Parse(date); } } else if (reader.LocalName == "type") { log.LogStatus = reader.ReadString(); if (m_ownid.Contains(log.FinderID) && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; cache.DNF = false; } else if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; cache.DNF = false; } else if (m_ownid.Contains(log.FinderID) && (log.LogStatus == "Didn't find it" || log.LogStatus == "no_find") && !cache.Found) { cache.DNF = true; } else if (m_ownid.Contains(log.LoggedBy) && (log.LogStatus == "Didn't find it" || log.LogStatus == "no_find") && !cache.Found) { cache.DNF = true; } } else if ((reader.LocalName == "finder" || reader.LocalName == "geocacher")) { log.FinderID = reader.GetAttribute("id"); log.LoggedBy = reader.ReadString(); if (m_ownid.Contains(log.LoggedBy) && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; cache.DNF = false; } else if (m_ownid.Contains(log.FinderID) && log.LogStatus == "Found it") { cache.Symbol = "Geocache Found"; cache.DNF = false; } else if (m_ownid.Contains(log.LoggedBy) && (log.LogStatus == "Didn't find it") && !cache.Found) { cache.DNF = true; } else if (m_ownid.Contains(log.FinderID) && (log.LogStatus == "Didn't find it") && !cache.Found) { cache.DNF = true; } } else if (reader.LocalName == "text" && reader.IsStartElement()) { if (reader.GetAttribute("encoded") != null) { log.Encoded = Boolean.Parse(reader.GetAttribute("encoded")); } else { log.Encoded = false; } if (log.LogMessage == "Unknown") { log.LogMessage = reader.ReadString(); } else { log.LogMessage += reader.ReadString(); } } else if (reader.LocalName == "log_wpt") { double lat = double.Parse(reader.GetAttribute("lat"), CultureInfo.InvariantCulture); double lon = double.Parse(reader.GetAttribute("lon"), CultureInfo.InvariantCulture); if (log.LogMessage == "Unknown") { log.LogMessage = Utilities.getCoordString(lat, lon) + "\n"; } else { log.LogMessage = Utilities.getCoordString(lat, lon) + "\n" + log.LogMessage; } } else if (reader.LocalName == "log") { breakLoop = true; } } if (log.LoggedBy == "GSAK" && log.LogStatus == "Other") { if (log.LogMessage.Trim() == "Notes:") { // Empty note, ignore return; } // Convert GSAK notes into OCM notes cache.Notes += log.LogMessage; cache.Notes += "----------\n"; return; } m_store.AddLog(cache.Name, log); if (!logsChecked) { if (log.LogStatus == "Didn't find it" || log.LogStatus == "Needs Maintenance" || log.LogStatus == "no_find") { cache.CheckNotes = true; logsChecked = true; } else if (log.LogStatus != "Write Note" && log.LogStatus != "Note") { cache.CheckNotes = false; logsChecked = true; } } }
public static void WriteToFile(CacheLog log, String fnFile) { List<CacheLog> logs = new List<CacheLog>(); logs.Add(log); WriteToFile(logs, fnFile); }
void HandleLogViewSelectionChanged(object sender, EventArgs e) { TreeIter iter; TreeModel model; if (((TreeSelection)sender).GetSelected (out model, out iter)) { CacheLog val = (CacheLog)model.GetValue (iter, 0); if (hasUnsaved) HandleUnsavedChanges (); if (val == null) { fieldNotesDescPane.Sensitive = false; viewCacheButton.Sensitive = false; deleteButton.Sensitive = false; return; } fieldNotesDescPane.Sensitive = true; viewCacheButton.Sensitive = true; deleteButton.Sensitive = true; m_currLog = val; if (m_caches.ContainsKey(val.CacheCode)) { UpdateCacheInfo (val); } else { cacheDesc.HTML = Catalog.GetString("<b>Information Unavailable. This cache is not in your OCM database.</b>"); mapView.ClearCaches(); firstToFindCheck.Sensitive = false; } logEntry.Buffer.Changed -= HandleLogEntryBufferChanged; logEntry.Buffer.Text = val.LogMessage; logEntry.Buffer.Changed += HandleLogEntryBufferChanged; deleteButton.Sensitive = true; viewCacheButton.Sensitive = true; logPane.Sensitive = true; saveButton.Sensitive = false; } else { deleteButton.Sensitive = false; viewCacheButton.Sensitive = false; fieldNotesDescPane.Sensitive = false; } }
internal override void WriteWPTDetails(XmlWriter writer, GPXWriter gpx) { base.WriteWPTDetails(writer, gpx); if (!gpx.IncludeGroundSpeakExtensions) { return; } writer.WriteStartElement(CACHE_PREFIX, "cache", GPXWriter.NS_CACHE); if (String.IsNullOrEmpty(CacheID)) { writer.WriteAttributeString("id", gpx.GetNextGUID().ToString()); } else { writer.WriteAttributeString("id", CacheID); } writer.WriteAttributeString("available", Available.ToString()); writer.WriteAttributeString("archived", Archived.ToString()); // Temp until smart-tag like support if (HasCorrected) { writer.WriteElementString(CACHE_PREFIX, "name", GPXWriter.NS_CACHE, "(*) " + CacheName); } else { writer.WriteElementString(CACHE_PREFIX, "name", GPXWriter.NS_CACHE, CacheName); } writer.WriteElementString(CACHE_PREFIX, "placed_by", GPXWriter.NS_CACHE, PlacedBy); writer.WriteStartElement(CACHE_PREFIX, "owner", GPXWriter.NS_CACHE); writer.WriteAttributeString("id", OwnerID); writer.WriteString(CacheOwner); writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX, "type", GPXWriter.NS_CACHE, GetCTypeString(TypeOfCache)); writer.WriteElementString(CACHE_PREFIX, "container", GPXWriter.NS_CACHE, Container); List <CacheAttribute> attrs = gpx.GetAttributes(this.Name); writer.WriteStartElement(CACHE_PREFIX, "attributes", GPXWriter.NS_CACHE); foreach (CacheAttribute curr in attrs) { writer.WriteStartElement(CACHE_PREFIX, "attribute", GPXWriter.NS_CACHE); if (!String.IsNullOrEmpty(curr.ID)) { writer.WriteAttributeString("id", curr.ID); } if (curr.Include) { writer.WriteAttributeString("inc", "1"); } else { writer.WriteAttributeString("inc", "0"); } writer.WriteString(curr.AttrValue); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX, "difficulty", GPXWriter.NS_CACHE, Difficulty.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX, "terrain", GPXWriter.NS_CACHE, Terrain.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX, "country", GPXWriter.NS_CACHE, Country); writer.WriteElementString(CACHE_PREFIX, "state", GPXWriter.NS_CACHE, State); StringBuilder shortDescription = new StringBuilder(); if (HasCorrected) { shortDescription.Append(Catalog.GetString("Original Coordinate:")); shortDescription.Append(Utilities.getCoordString(OrigLat, OrigLon)); shortDescription.Append("<br/>"); } if (gpx.WriteAttributes) { attrs = gpx.GetAttributes(this.Name); foreach (CacheAttribute curr in attrs) { if (curr.Include) { shortDescription.Append(Catalog.GetString("Y:")); } else { shortDescription.Append(Catalog.GetString("N:")); } shortDescription.Append(curr.AttrValue); shortDescription.Append("<br/>"); } if (attrs.Count > 0) { shortDescription.Append("<hr noshade/>"); } } if (!String.IsNullOrEmpty(Notes)) { shortDescription.Append(Notes); shortDescription.Append("<hr noshade/>"); } shortDescription.Append(ShortDesc); writer.WriteStartElement(CACHE_PREFIX, "short_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) { writer.WriteCData(Utilities.HTMLtoGarmin(shortDescription.ToString())); } else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(shortDescription.ToString())); } else { writer.WriteCData(shortDescription.ToString()); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "long_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) { writer.WriteCData(Utilities.HTMLtoGarmin(LongDesc)); } else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(LongDesc)); } else { writer.WriteCData(LongDesc); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "encoded_hints", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN || gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(Hint)); } else { writer.WriteCData(Hint); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "logs", GPXWriter.NS_CACHE); if (gpx.IsMyFinds) { CacheLog log = gpx.CacheStore.GetLastFindLogBy(this.Name, gpx.MyFindsOwner); if (log.LogStatus == "find") { log.LogStatus = "Found it"; } log.WriteToGPX(writer); } else { List <CacheLog> logs = gpx.GetCacheLogs(this.Name); int iCount = 0; foreach (CacheLog log in logs) { if ((iCount >= gpx.LogLimit) && (gpx.LogLimit != -1)) { break; } else { log.WriteToGPX(writer); } iCount++; } } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "travelbugs", GPXWriter.NS_CACHE); List <TravelBug> bugs = gpx.GetTravelBugs(this.Name); foreach (TravelBug bug in bugs) { bug.WriteToGPX(writer); } writer.WriteEndElement(); writer.WriteEndElement(); }
public void AddLog(String cachename, CacheLog log) { if (m_conn == null) throw new Exception("DB NOT OPEN"); IDbCommand cmd = m_conn.CreateCommand(); String insert = String.Format(ADD_LOG, cachename, log.LogDate.ToString("o"), SQLEscape(log.LoggedBy), SQLEscape(log.LogMessage), SQLEscape(log.LogStatus), log.FinderID, log.Encoded.ToString(), log.LogID, log.LogKey); String update = String.Format(UPDATE_LOG, cachename, log.LogDate.ToString("o"), SQLEscape(log.LoggedBy), SQLEscape(log.LogMessage), SQLEscape(log.LogStatus), log.FinderID, log.Encoded.ToString(), log.LogID, log.LogKey); InsertOrUpdate(update, insert, cmd); }