Ejemplo n.º 1
0
 private static void ApplyComment(HtmlNode dayNoteDiv, DayNote dayNote)
 {
     var commentNode = dayNoteDiv.Element("span");
     dayNote.Comment = commentNode != null
         ? HttpUtility.HtmlDecode(commentNode.InnerText)
         : null;
 }
Ejemplo n.º 2
0
        private void ApplyNumbers(HtmlNode dayNoteDiv, DayNote dayNote)
        {
            var dayNoteNumbersNode = dayNoteDiv.Descendants()
                .WithClassEqualTo("b-calendar-daynote-numbers")
                .SingleOrDefault();
            if (dayNoteNumbersNode != null)
            {
                var dayNoteLines =
                    dayNoteNumbersNode.ChildNodes.Where(o => o.NodeType == HtmlNodeType.Text)
                        .Select(o => o.InnerText)
                        .ToList();

                dayNoteLines.ForEach(s => ApplyDayNoteNumberLine(dayNote, s));
            }
        }
Ejemplo n.º 3
0
 protected bool Equals(DayNote other)
 {
     return Date.Equals(other.Date);
 }
Ejemplo n.º 4
0
        private DayNote ParseDayNoteDiv(HtmlNode dayNoteDiv)
        {
            var dayNote = new DayNote();

            ApplyDate(dayNoteDiv, dayNote);
            ApplyComment(dayNoteDiv, dayNote);
            ApplyNumbers(dayNoteDiv, dayNote);

            return dayNote;
        }
Ejemplo n.º 5
0
 private void ApplyDayNoteNumberLine(DayNote dayNote, string line)
 {
     ParseWeight(dayNote, line);
     ParseRestingHeartRate(dayNote, line);
     ParseCalories(dayNote, line);
 }
Ejemplo n.º 6
0
 private static void ParseWeight(DayNote dayNote, string line)
 {
     var match = Regex.Match(line, @"Vikt[:\s]*(\d+(?:[,\.]\d)?)");
     if (match.Success)
         dayNote.Weight = NumberParser.TryParseDecimal(match.Groups[1].Value);
 }
Ejemplo n.º 7
0
 private static void ParseRestingHeartRate(DayNote dayNote, string line)
 {
     var match = Regex.Match(line, @"Vilopuls[:\s]*(\d+)");
     if (match.Success)
         dayNote.RestingHeartRate = NumberParser.TryParseInt(match.Groups[1].Value);
 }
Ejemplo n.º 8
0
 private static void ParseCalories(DayNote dayNote, string line)
 {
     var match = Regex.Match(line, @"kcal[:\s]*(\d+)");
     if (match.Success)
         dayNote.KCal = NumberParser.TryParseInt(match.Groups[1].Value);
 }
Ejemplo n.º 9
0
 private static void ApplyDate(HtmlNode dayNoteDiv, DayNote dayNote)
 {
     var dateLink = dayNoteDiv.FirstParent(n => n.Name == "table").Descendants("a").First();
     var match = Regex.Match(dateLink.GetAttributeValue("href", ""), @"StartDateTime=(\d{4}-\d\d-\d\d)");
     dayNote.Date = DateTime.Parse(match.Groups[1].Value);
 }