private void Call(TelefoneNumber telefoneNumber)
        {
            var uri    = Uri.Parse($"tel:{telefoneNumber.Number}");
            var intent = new Intent(Intent.ActionDial, uri);

            App.Instance.StartActivity(intent);
        }
        private TextCell GetTextCellFromTelefoneNumber(TelefoneNumber telefoneNumber)
        {
            var textCell = new TextCell {
                Detail = telefoneNumber.Number, DetailColor = Color.Blue, Text = LanguageFile.TranslateContactType(telefoneNumber.Type)
            };

            if (telefoneNumber.Type == TelefoneNumber.TelefoneNumberType.Fax)
            {
                textCell.DetailColor = BlueGray;
            }

            textCell.Tapped += (o, e) => OpenTelefoneNumber(telefoneNumber);

            return(textCell);
        }
Beispiel #3
0
        public static (long startTime, long endTime, TelefoneNumber number) GetNextReachableTime(this Therapist therapist)
        {
            var now = DateTime.Now;

            var nowMillies   = (int)now.DayOfWeek * TimeSpan.TicksPerDay + now.TimeOfDay.Ticks;
            var contactTimes = therapist.Offices.SelectMany(o => o.ContactTimes).ToList();

            if (therapist.Offices.All(o => o.TelefoneNumbers.Any(t => t.Type == TelefoneNumber.TelefoneNumberType.Mobil || t.Type == TelefoneNumber.TelefoneNumberType.Telefon)))
            {
                contactTimes.AddRange(therapist.Offices.Select(o => new ContactTime {
                    OfficeHours = o.OfficeHours, TelefoneNumber = o.TelefoneNumbers.FirstOrDefault(t => t.Type == TelefoneNumber.TelefoneNumberType.Mobil || t.Type == TelefoneNumber.TelefoneNumberType.Telefon)
                }).ToList());
            }

            var            minMillies      = long.MaxValue;
            var            nextDateTime    = 0L;
            var            nextDateTimeEnd = 0L;
            TelefoneNumber number          = default(TelefoneNumber);

            foreach (var contactTime in contactTimes)
            {
                foreach (var officeHour in contactTime.OfficeHours)
                {
                    var fromTimeOfDay = officeHour.From.TimeOfDay;
                    int dayOfWeek     = (int)officeHour.DayOfWeek;
                    if (dayOfWeek < (int)now.DayOfWeek)
                    {
                        dayOfWeek += 7;
                    }
                    if (dayOfWeek == (int)now.DayOfWeek && officeHour.To.TimeOfDay < now.TimeOfDay)
                    {
                        dayOfWeek += 7;
                    }
                    var contactMillies = dayOfWeek * TimeSpan.TicksPerDay + fromTimeOfDay.Ticks;
                    contactMillies -= nowMillies;
                    if (contactMillies < minMillies)
                    {
                        number          = contactTime.TelefoneNumber;
                        minMillies      = contactMillies;
                        nextDateTime    = now.Ticks + contactMillies;
                        nextDateTimeEnd = nextDateTime + (officeHour.To - officeHour.From).Ticks;
                    }
                }
            }

            return(nextDateTime, nextDateTimeEnd, number);
        }
Beispiel #4
0
        private void ParseContact(Office office, HtmlNode officeContactNode)
        {
            var children = officeContactNode.ChildNodes.Where(n => n.HasInnerText()).ToArray();

            foreach (var child in children)
            {
                var entry = child.Descendants("span").Select(n => n.GetDecodedInnerText().TrimWhiteSpace()).ToArray();
                Assert(entry.Length >= 2);
                TelefoneNumber.TelefoneNumberType type = GetContactType(entry[0]);
                foreach (var contactRow in entry.Skip(1))
                {
                    var telefoneNumber = new TelefoneNumber
                    {
                        Number = contactRow,
                        Type   = type
                    };
                    office.TelefoneNumbers.Add(telefoneNumber);
                }
            }
        }
        private void OpenTelefoneNumber(TelefoneNumber telefoneNumber)
        {
            switch (telefoneNumber.Type)
            {
            case TelefoneNumber.TelefoneNumberType.Mobil:
                Call(telefoneNumber);
                break;

            case TelefoneNumber.TelefoneNumberType.Fax:
                break;

            case TelefoneNumber.TelefoneNumberType.Telefon:
                Call(telefoneNumber);
                break;

            case TelefoneNumber.TelefoneNumberType.Webseite:
                LaunchWebsite(telefoneNumber.Number);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void ParseContactAndLanguages(Therapist therapist, HtmlNode infoNode)
        {
            string text = "";
            {
                var before = infoNode.GetDecodedInnerText().Replace("\t", "");
                do
                {
                    text = before.Replace("\r", "\t").Replace("\n", "\t").Replace("\t\t", "\t").Replace("\t ", "\t").Replace(" \t", "\t").Replace(" ", "");
                    if (text == before)
                    {
                        break;
                    }
                    before = text;
                }while (true);
            }
            var rows = text.Split('\t').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();

            if (rows.Any())
            {
                Assert(rows.Length > 1);

                TelefoneNumber.TelefoneNumberType?currentType = null;
                foreach (var row in rows)
                {
                    if (string.Equals(row, "Fremdsprachen:", StringComparison.InvariantCultureIgnoreCase))
                    {
                        currentType = null;
                    }
                    else if (string.Equals(row, "Fax:", StringComparison.InvariantCultureIgnoreCase))
                    {
                        currentType = TelefoneNumber.TelefoneNumberType.Fax;
                    }
                    else if (string.Equals(row, "Telefon:", StringComparison.InvariantCultureIgnoreCase))
                    {
                        currentType = TelefoneNumber.TelefoneNumberType.Telefon;
                    }
                    else if (string.Equals(row, "Webseite:", StringComparison.InvariantCultureIgnoreCase))
                    {
                        currentType = TelefoneNumber.TelefoneNumberType.Webseite;
                    }
                    else if (string.Equals(row, "Mobil:", StringComparison.InvariantCultureIgnoreCase) || string.Equals(row, "Mobiltelefon:", StringComparison.InvariantCultureIgnoreCase))
                    {
                        currentType = TelefoneNumber.TelefoneNumberType.Mobil;
                    }
                    else
                    {
                        if (currentType.HasValue)
                        {
                            var telefoneNumber = new TelefoneNumber {
                                Number = row, Type = currentType.Value
                            };
                            therapist.TelefoneNumbers.Add(telefoneNumber);
                        }
                        else
                        {
                            therapist.Languages.Add(row);
                        }
                    }
                }
            }
        }
Beispiel #7
0
 protected bool Equals(TelefoneNumber other)
 {
     return(string.Equals(Number, other.Number) && Type == other.Type);
 }