Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ABPerson">
        /// A <see cref="ABPerson"/>
        /// </param>
        /// <returns>
        /// A <see cref="ContactLite"/>
        /// </returns>
        protected ContactLite ABPersonToContactLite(ABPerson person)
        {
            ContactLite contact = new ContactLite ();

            // Basic Info
            contact.ID = "" + person.Id;
            contact.Name = person.FirstName;
            contact.Firstname = person.MiddleName;
            contact.Lastname = person.LastName;
            contact.DisplayName = person.Nickname;

            // TODO how to get the group(s) this person belongs to
            contact.Group = person.Organization;

            // Phones
            contact.Phones = this.GetContactPhones (person);

            // Emails
            contact.Emails = this.GetContactEmails (person);

            return contact;
        }
Пример #2
0
        public override async Task GetContact(string id)
        {
            //TODO: Buscar forma alternativa de ID
            if (String.IsNullOrWhiteSpace(id)) return;
            var contactIDSegments = id.Split(new[] { "--" }, StringSplitOptions.RemoveEmptyEntries);
            var contactID = String.Concat("{", contactIDSegments[0], ".", contactIDSegments[1], ".", "}");

            try
            {
                var agenda = await ContactManager.RequestStoreAsync();
                var contact = await agenda.GetContactAsync(contactID);
                if (contact == null) return;
                var returnContact = new ContactLite
                {
                    ID = id,
                    DisplayName = contact.DisplayName,
                    Name = contact.FirstName,
                    Firstname = contact.MiddleName,
                    Lastname = contact.LastName,
                    Phones = GetContactPhonesArray(contact),
                    Emails = GetContactEmailArray(contact)
                };
                WindowsPhoneUtils.InvokeCallback(GetContactCallback, WindowsPhoneUtils.CALLBACKID, JsonConvert.SerializeObject(returnContact));

            }
            catch (UnauthorizedAccessException)
            {
                WindowsPhoneUtils.Log("Not enough privileges to access Contacts");
                WindowsPhoneUtils.InvokeCallback(AccessDeniedContactsCallback, WindowsPhoneUtils.CALLBACKID, null);
            }
            catch (Exception ex)
            {
                WindowsPhoneUtils.Log("Unhandled error recovering contacts:" + ex.Message);
            }

        }