Пример #1
0
        /// <summary>
        /// Creates Google Contacts one by one
        /// </summary>
        /// <param name="auth">a valid Google token or refresh token</param>
        /// <param name="contacts">contacts to be created</param>
        private void CreateContacts(UserCredential auth, Dictionary <string, VPContact> contacts)
        {
            try
            {
                foreach (KeyValuePair <string, VPContact> item in contacts)
                {
                    Contact newContact = item.Value.GetGoogleContact();

                    newContact = GConnect.CreateNewContact(newContact, auth);

                    //HACK! - dotnet lib does not support to set "nickname" while creating object ;-(
                    newContact.ContactEntry.Nickname = item.Value.Initials;
                    GConnect.UpdateContact(auth, newContact);

                    //update photo
                    GConnect.UpdatePhoto(auth, newContact, item.Value.Picture);

                    //Console.WriteLine("Created Contact: " + item.Key);
                    _status.ToBeCreated--;
                    _status.GoogleContacts++;
                    ProgressUpdate(_status);
                    //System.Threading.Thread.Sleep(3000);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// Updates Google Contacts one by one.
        /// </summary>
        /// <param name="auth">a valid Google token or refresh token</param>
        /// <param name="toBeUpdated"></param>
        private void UpdateContacts(UserCredential auth, Dictionary <string, VPContact> toBeUpdated)
        {
            try
            {
                foreach (var item in toBeUpdated)
                {
                    Contact gContact = item.Value.GetGoogleContact();

                    GConnect.UpdateContact(auth, gContact);
                    GConnect.UpdatePhoto(auth, gContact, item.Value.Picture);
                    //System.Threading.Thread.Sleep(3000);
                    _status.ToBeUpdated--;
                    ProgressUpdate(_status);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }