Пример #1
0
 public void SaveTrack(Track t)
 {
     t.Data = (from trk in tracks where trk.TrackID == t.TrackID select trk.Data).First();
     try
     {
         tracks.Attach(t);
         tracks.Context.Refresh(RefreshMode.KeepCurrentValues, t);
     }
     catch { }
     tracks.Context.SubmitChanges();
 }
Пример #2
0
 public void SaveTrimTrack(Track t)
 {
     t.Data = (from trk in tracks where trk.TrackID == t.TrackID select trk.Data).First();
     t.TrimPoints(t.TrimStart, t.TrimEnd);
     t.GenerateMetadata();
     try
     {
         tracks.Attach(t);
         tracks.Context.Refresh(RefreshMode.KeepCurrentValues, t);
     }
     catch { }
     tracks.Context.SubmitChanges();
 }
Пример #3
0
 public ActionResult Edit(Track t, string trim)
 {
     if (ModelState.IsValid)
     {
         if (trim != null)
             _tracksRepository.SaveTrimTrack(t);
         else
             _tracksRepository.SaveTrack(t);
         TempData["message"] = t.Name + " has been saved.";
         return RedirectToAction("List");
     }
     return View(t);
 }
 public void SaveTrimTrack(Track t)
 {
     throw new NotImplementedException();
 }
 public void AddTrack(Track t)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public static List<Track> ParseGpx(string filename, Stream data)
 {
     var doc = XDocument.Load(data);
     var xn = doc.Root.Name.Namespace;
     List<Track> tracks = new List<Track>();
     // Read 'trk' elements.  Could also read 'wpt' and 'rte'
     foreach (var trk in doc.Root.Elements(xn + "trk"))
     {
         var newDoc = new XDocument(doc);
         newDoc.Declaration = new XDeclaration(doc.Declaration);
         newDoc.Root.ReplaceNodes(new XElement(trk));
         var newTrack = new Track { SourceFile = filename, Data = newDoc.ToString(), Name = trk.Element(xn + "name").Value };
         var points = newTrack.GetPoints();
         if (points.Length > 10)
             tracks.Add(newTrack);
     }
     return tracks;
 }
Пример #7
0
 public void AddTrack(Track t)
 {
     tracks.InsertOnSubmit(t);
     tracks.Context.SubmitChanges();
 }
 public string GetData(Track t)
 {
     if (!File.Exists(GetTrackFilename(t)))
         return null;
     return File.ReadAllText(GetTrackFilename(t));
 }
 private void SaveData(Track t)
 {
     using (var fs = File.Open(Path.Combine(_filePath, "TrackData.xml"), FileMode.Create, FileAccess.Write))
     {
         var xSer = new XmlSerializer(typeof(TrackCollection));
         xSer.Serialize(fs, new TrackCollection { Tracks = _tracks });
         fs.Close();
     }
 }
 private string GetTrackFilename(Track t)
 {
     return Path.Combine(_filePath, String.Format("{0:yyyyMMdd}-{1}.gpx", t.TrackDate, String.Join("-", t.Name.Split(Path.GetInvalidFileNameChars()))));
 }
 private void DeleteFile(Track t)
 {
     File.Delete(GetTrackFilename(t));
 }