Exemplo n.º 1
0
        /// <summary>
        /// 获取联系人
        /// </summary>
        private async void GetContacts()
        {
            //创建联系人存储
            conStore = await ContactStore.CreateOrOpenAsync();

            //联系人查询的结果
            conQueryResult = conStore.CreateContactQuery();
            //联系人集合
            conList = await conQueryResult.GetContactsAsync();

            //显示联系人的集合

            List <Item> list = new List <Item>();

            foreach (StoredContact storCon in conList)
            {
                var properties = await storCon.GetPropertiesAsync();

                list.Add(new Item
                {
                    Name = storCon.GivenName,
                    Id   = storCon.Id
                });
            }
            conListBox.ItemsSource = list;
        }
Exemplo n.º 2
0
        private async void  GetContact(string p)
        {
            //创建联系人存储
            conStore = await ContactStore.CreateOrOpenAsync();

            //联系人查询结果
            ContactQueryResult conQueryResult = conStore.CreateContactQuery();
            //查询联系人
            IReadOnlyList <StoredContact> conList = await conQueryResult.GetContactsAsync();

            List <Item> list = new List <Item>();

            foreach (StoredContact strCon in conList)
            {
                if (strCon.GivenName.Contains(p))
                {
                    list.Add(new Item
                    {
                        Name = strCon.GivenName,
                        Id   = strCon.Id,
                    });
                }
            }
            conListBox.ItemsSource = list;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieve list of contacts from the store
        /// </summary>
        /// <param name="parameters"></param>
        async public void GetContactsFromStore(string parameters)
        {
            store = await ContactStore.CreateOrOpenAsync(ContactStoreSystemAccessMode.ReadWrite, ContactStoreApplicationAccessMode.ReadOnly);

            ContactQueryOptions options = new ContactQueryOptions();

            options.DesiredFields.Add(KnownContactProperties.Email);
            options.DesiredFields.Add(KnownContactProperties.Address);
            options.DesiredFields.Add(KnownContactProperties.Telephone);

            ContactQueryResult result = store.CreateContactQuery(options);

            IReadOnlyList <StoredContact> contacts = await result.GetContactsAsync();

            string jsContacts = "AppMobi.people = [";

            foreach (StoredContact con in contacts)
            {
                IDictionary <string, object> temps = await con.GetPropertiesAsync();

                string displayName = "";
                Windows.Phone.PersonalInformation.ContactAddress address;
                string familyName = "";
                string givenName  = "";
                string email      = "";
                string telephone  = "";

                if (temps.ContainsKey("DisplayName"))
                {
                    displayName = (string)temps["DisplayName"];
                }

                if (temps.ContainsKey("Address"))
                {
                    address = (Windows.Phone.PersonalInformation.ContactAddress)temps["Address"];
                }

                if (temps.ContainsKey("FamilyName"))
                {
                    familyName = (string)temps["FamilyName"];
                }

                if (temps.ContainsKey("GivenName"))
                {
                    givenName = (string)temps["GivenName"];
                }

                if (temps.ContainsKey("Email"))
                {
                    email = (string)temps["Email"];
                }

                if (temps.ContainsKey("Telephone"))
                {
                    telephone = (string)temps["Telephone"];
                }
            }

            jsContacts += "];";
        }
        private async void FindAndLoadContact(string givenName, string familyName)
        {
            ContactQueryOptions options = new ContactQueryOptions();

            options.OrderBy = ContactQueryResultOrdering.GivenNameFamilyName;
            options.DesiredFields.Clear();
            options.DesiredFields.Add(KnownContactProperties.GivenName);
            options.DesiredFields.Add(KnownContactProperties.FamilyName);
            options.DesiredFields.Add(KnownContactProperties.Email);
            options.DesiredFields.Add(KnownContactProperties.Telephone);

            ContactQueryResult            query    = store.CreateContactQuery(options);
            IReadOnlyList <StoredContact> contacts = await query.GetContactsAsync();

            contact = contacts.First(item =>
                                     item.GivenName == givenName && item.FamilyName == familyName);

            IDictionary <string, object> props = await contact.GetPropertiesAsync();

            firstNameInput.Text = contact.GivenName;
            lastNameInput.Text  = contact.FamilyName;
            if (props.ContainsKey(KnownContactProperties.Email))
            {
                emailInput.Text = (string)props[KnownContactProperties.Email];
            }
            if (props.ContainsKey(KnownContactProperties.Telephone))
            {
                phoneInput.Text = (string)props[KnownContactProperties.Telephone];
            }
        }
Exemplo n.º 5
0
        public async Task <string> GetUserIdsMd5InStore()
        {
            logger.debug("Loading saved user ids...");
            ContactStore store = await ContactStore.CreateOrOpenAsync();

            ContactQueryResult            result   = store.CreateContactQuery();
            IReadOnlyList <StoredContact> contacts = await result.GetContactsAsync();

            List <int> userIds = new List <int>();

            foreach (var storedContact in contacts)
            {
                userIds.Add(int.Parse(storedContact.RemoteId));
            }

            userIds.Sort();
            string sortedStr = userIds.Aggregate("", (current, userId) => current + (userId + ","));

            if (sortedStr != "")
            {
                sortedStr = sortedStr.Substring(0, sortedStr.Length - 1);
                logger.debug("sorted str is {0}", sortedStr);
                return(MD5.GetMd5String(sortedStr));
            }

            return("");
        }
        internal static CfContactQueryResult FromContactQueryResult(ContactQueryResult source)
        {
            if (source == null)
            {
                return(null);
            }

            var contact = source.Contact == null ? null : source.Contact.Select(ContactMapper.FromContact).ToArray();

            return(new CfContactQueryResult(source.TotalResults, contact));
        }
Exemplo n.º 7
0
        private static async void CleanContacts()
        {
            ContactStore store = await ContactStore.CreateOrOpenAsync();

            ContactQueryResult            result   = store.CreateContactQuery();
            IReadOnlyList <StoredContact> contacts = await result.GetContactsAsync();

            foreach (var contact in contacts)
            {
                await store.DeleteContactAsync(contact.Id);
            }
        }
Exemplo n.º 8
0
        public static async Task <IReadOnlyList <StoredContact> > GetContactsFromPhoneAsync(CancellationToken token)
        {
            token.ThrowIfCancellationRequested();
            ContactStore store = await ContactStore.CreateOrOpenAsync();

            token.ThrowIfCancellationRequested();
            ContactQueryResult result = store.CreateContactQuery();

            token.ThrowIfCancellationRequested();
            IReadOnlyList <StoredContact> contacts = await result.GetContactsAsync();

            token.ThrowIfCancellationRequested();
            return(contacts);
        }
        private async void GetFriends()
        {
            ContactStore store = await ContactStore.CreateOrOpenAsync();

            ContactQueryResult result = store.CreateContactQuery();



            IReadOnlyList <StoredContact> contacts = await result.GetContactsAsync();

            friendList.Clear();

            foreach (var storedContact in contacts)
            {
                UserModel user = TelegramSession.Instance.GetUser(int.Parse(storedContact.RemoteId));
                friendList.Add(user);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 获取联系人
 /// </summary>
 private async void GetContacts()
 {
     //创建联系人存储
     conStore = await ContactStore.CreateOrOpenAsync();
     //联系人查询的结果
     conQueryResult = conStore.CreateContactQuery();
     //联系人集合
     conList = await conQueryResult.GetContactsAsync();
     //显示联系人的集合
    
     List<Item> list = new List<Item>();
     foreach (StoredContact storCon in conList)
     {
         var properties = await storCon.GetPropertiesAsync();
         list.Add(new Item
             {
                 Name = storCon.GivenName,
                 Id =storCon .Id 
             });
     }
     conListBox.ItemsSource = list;
 }    
Exemplo n.º 11
0
        /// <summary>
        /// 获取联系人列表
        /// </summary>
        private async void GetContacts()
        {
            conStore = await ContactStore.CreateOrOpenAsync();

            ContactQueryResult conQueryResult = conStore.CreateContactQuery();
            //查询联系人
            IReadOnlyList <StoredContact> conList = await conQueryResult.GetContactsAsync();

            List <Item> list = new List <Item>();

            foreach (StoredContact storCon in conList)
            {
                var properties = await storCon.GetPropertiesAsync();

                list.Add(new Item
                {
                    Name = storCon.GivenName,
                    Id   = storCon.Id,
                });
            }
            conListBox.ItemsSource = list;
        }