Example #1
0
        internal static IRun mapRun(XmlDocument xml)
        {
            IRun run = new Run();
            run.TemplateName = xml.SelectSingleNode("//templateName").InnerText;
            run.Weight = float.Parse(xml.SelectSingleNode("//weight").InnerText);
            run.Device = xml.SelectSingleNode("//device").InnerText;
            run.EmpedID = xml.SelectSingleNode("//empedID").InnerText;
            run.StartTime = DateTime.Parse(xml.SelectSingleNode("//startTime").InnerText);
            run.Description = xml.SelectSingleNode("//description").InnerText;
            run.Calories = long.Parse(xml.SelectSingleNode("//calories").InnerText);
            run.Duration = long.Parse(xml.SelectSingleNode("//duration").InnerText);
            run.Distance = float.Parse(xml.SelectSingleNode("//distance").InnerText);
            run.BestComparableRun = xml.SelectSingleNode("//bestComparableRun").InnerText;

            //powersong
            run.PowerSong.Artist = xml.SelectSingleNode("//powerSong/artist").InnerText;
            run.PowerSong.Title = xml.SelectSingleNode("//powerSong/title").InnerText;
            run.PowerSong.Album = xml.SelectSingleNode("//powerSong/album").InnerText;



            //userClick snapshot
            foreach (XmlNode node in xml.SelectNodes("//snapShotList[@snapShotType='userClick']/snapShot"))
            {
                ISnapShot shot = new Snapshot();
                shot.Distance = float.Parse(node.SelectSingleNode("distance").InnerText);
                shot.Duration = long.Parse(node.SelectSingleNode("duration").InnerText);
                shot.Pace = long.Parse(node.SelectSingleNode("pace").InnerText);
                shot.ID = node.SelectSingleNode("@id").InnerText;
                shot.Event = node.SelectSingleNode("@event").InnerText;
            }

            //kmSplit snapshot
            foreach (XmlNode node in xml.SelectNodes("//snapShotList[@snapShotType='kmSplit']/snapShot"))
            {
                ISnapShot shot = new Snapshot();
                shot.Distance = float.Parse(node.SelectSingleNode("distance").InnerText);
                shot.Duration = long.Parse(node.SelectSingleNode("duration").InnerText);
                shot.Pace = long.Parse(node.SelectSingleNode("pace").InnerText);
                shot.ID = node.SelectSingleNode("@id").InnerText;
                shot.Event = node.SelectSingleNode("@event").InnerText;
            }

            //mileSplit snapshot
            foreach (XmlNode node in xml.SelectNodes("//snapShotList[@snapShotType='mileSplit']/snapShot"))
            {
                ISnapShot shot = new Snapshot();
                shot.Distance = float.Parse(node.SelectSingleNode("distance").InnerText);
                shot.Duration = long.Parse(node.SelectSingleNode("duration").InnerText);
                shot.Pace = long.Parse(node.SelectSingleNode("pace").InnerText);
                shot.ID = node.SelectSingleNode("@id").InnerText;
                shot.Event = node.SelectSingleNode("@event").InnerText;
            }


            return run;
        }
Example #2
0
        internal static List<IRun> mapRuns(XmlDocument xml)
        {
            List<IRun> runs = new List<IRun>();

            foreach (XmlNode node in xml.SelectNodes("//run") )
            {
                IRun newRun = new Run();
                newRun.ID = node.SelectSingleNode("@id").InnerText;
                newRun.StartTime = DateTime.Parse(node.SelectSingleNode("startTime").InnerText);
                newRun.SyncTime = DateTime.Parse(node.SelectSingleNode("syncTime").InnerText);
                newRun.Name = node.SelectSingleNode("name").InnerText;
                newRun.Description = node.SelectSingleNode("description").InnerText;

                newRun.Calories = float.Parse(node.SelectSingleNode("calories").InnerText);
                newRun.Duration = long.Parse(node.SelectSingleNode("duration").InnerText);
                newRun.Distance = float.Parse(node.SelectSingleNode("distance").InnerText);

                runs.Add(newRun);
            }

            return runs;
        }