private GpxType GetGpxType(GPXEntry gpxEntry) { string gpxFile = gpxEntry.Data; //Ugly hack but use it for now to deal with 1.0 versions if (gpxFile.Contains(@"xmlns=""http://www.topografix.com/GPX/1/0""")) { gpxFile = gpxFile.Replace("<trk>", "<trk>\n\t<name>RunningFree</name>").Replace(@"http://www.topografix.com/GPX/1/0", "http://www.topografix.com/GPX/1/1"); File.WriteAllText(@"C:\testRunningFree.gpx", gpxFile); } GpxType gpxActivity = null; XmlSerializer mySerial = new XmlSerializer(typeof(GpxType)); using (TextReader reader = new StringReader(gpxFile)) { try { return gpxActivity = (GpxType)mySerial.Deserialize(reader); } catch (Exception ex) { throw new Exception("GPXObj is null"); } } }
public void SaveSettings(GPXEntry gpxEntry) { GPXEntry dbEntry = gpxContext.RunKeepers.Find(gpxEntry.Id); if (dbEntry != null) { gpxContext.Entry(dbEntry).CurrentValues.SetValues(gpxEntry); } gpxContext.SaveChanges(); }
public RouteInfo ProcessRow(GPXEntry row) { try { GpxType gpxObj = GetGpxType(row); string activityName = GetActivityName(gpxObj); List<TrackPoint> wayPoints = GetWayPoints(gpxObj); AFElement element = GetElementFromGuid(row.UserId); RouteInfo routeInfo = GetRouteInfo(element, wayPoints, activityName); return routeInfo; } catch (Exception ex) { PIFitnessLog.Write(TraceEventType.Information, 0, ex.Message + " RowID: " + row.Id); return null; } }
private void SetRowProcessed(GPXEntry row) { row.Processed = true; _writer.UpdateRow(row); }
private RouteInfo ProcessRow(GPXEntry row) { PIFitnessLog.Write(TraceEventType.Verbose, 0, string.Format("Processing GPX for user {0}", row.UserName)); RouteInfo tableRowInfo = _rowProcessor.ProcessRow(row); return tableRowInfo; }