예제 #1
0
        /// <summary>
        /// Creates new contact
        /// </summary>
        /// <param name="newEntry">New contact item.</param>
        /// <param name="creds">credentials with valid token/refresh token</param>
        /// <returns>The new contact, null is returned if error occured</returns>
        public static Contact CreateNewContact(Contact newEntry, UserCredential creds)
        {
            RefreshToken(creds, out bool success);

            if (!success)
            {
                logger.Warn("Refresh of Token failed, no contact created.");
                return(null);
            }

            newEntry = CheckGroupMembership(newEntry, creds);

            var cr = BuildContactsRequest(creds);

            // Insert the contact.
            Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));

            if (newEntry.Name != null)
            {
                logger.Info("Creating contact: " + newEntry.Name.FullName);
            }
            Contact createdEntry = cr.Insert(feedUri, newEntry);

            if (createdEntry != null)
            {
                logger.Debug("Got Google ID back: " + createdEntry.Id);
            }
            else
            {
                logger.Error("could not create contact (no ID returned)");
            }


            return(createdEntry);
        }
예제 #2
0
        public IList <GoogleContactSyncData> GetSyncDataList()
        {
            var contactRequest = _externalServiceProvider.GetGoogleContactRequest(_token);

            contactRequest.Settings.AutoPaging = false;
            contactRequest.Settings.Maximum    = GoogleSyncSettings.DefaultMaxContactCount;

            var isDefaultContactGroupExist = false;
            var defaultContactGroup        = GetDefaultContactGroup(_token, out isDefaultContactGroupExist);
            var contactsQuery = new ContactsQuery(GoogleSyncSettings.ContactScope)
            {
                Group = defaultContactGroup.Id
            };

            List <GoogleContactSyncData> items = new List <GoogleContactSyncData>();

            foreach (Contact contact in contactRequest.Get <Contact>(contactsQuery).Entries)
            {
                if (!contact.Deleted)
                {
                    items.Add(new GoogleContactSyncData(contact));
                }
            }

            return(items);
        }
        //Create Shared Contact
        public static Contact CreateContacttest(ContactsRequest cr)
        {
            Contact newEntry = new Contact();

            // Set the contact's name.
            newEntry.Name = new Name()
            {
                FullName   = "Ice Cold005",
                GivenName  = "Ice",
                FamilyName = "Cold005"
            };
            newEntry.Content = "Notes";
            // Set the contact's e-mail addresses.
            newEntry.Emails.Add(new EMail()
            {
                Primary = true,
                Rel     = ContactsRelationships.IsWork,
                Address = "*****@*****.**"
            });
            //Insert the contact
            Uri     feedUri      = new Uri(ContactsQuery.CreateContactsUri("test.com"));
            Contact createdEntry = cr.Insert(feedUri, newEntry);

            Console.WriteLine("New Contact created successfully with ContactID = " + createdEntry.Id);
            return(createdEntry);
        }
        public void PrintDateMinQueryResults(ContactsRequest cr)
        {
            Service service = new ContactsService("EventManagement");

            service.setUserCredentials("*****@*****.**", "Vandematram@123");
            var token = service.QueryClientLoginToken();

            service.SetAuthenticationToken(token);

            GAuthSubRequestFactory authFactory =
                new GAuthSubRequestFactory("cl", "EventManagement");

            authFactory.Token = (String)token;
            //  CalendarService service2 = new CalendarService(authFactory.ApplicationName);
            service.RequestFactory = authFactory;

            ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
            // query.StartDate = new DateTime(2008, 1, 1);
            Feed <Contact> feed = cr.Get <Contact>(query);

            foreach (Contact contact in feed.Entries)
            {
                Console.WriteLine(contact.Name.FullName);
                Console.WriteLine("Updated on: " + contact.Updated.ToString());
            }
        }
예제 #5
0
        public bool AreContactsModifiedToday()
        {
            bool areContactsModifiedToday = false;

            try
            {
                RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord);
                // AutoPaging results in automatic paging in order to retrieve all contacts
                rs.AutoPaging = true;
                ContactsRequest cr = new ContactsRequest(rs);

                ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                //query.StartDate = new DateTime(2000, 1, 1);
                query.NumberToRetrieve = int.MaxValue;
                //query.OrderBy =

                query.StartDate = DateTime.Now.AddDays(-1);

                List <ConciseContact> ccList = new List <ConciseContact>();
                DateTime today = DateTime.Now.Date;

                Feed <Contact> feed = cr.Get <Contact>(query);

                if (feed.TotalResults > 0)
                {
                    areContactsModifiedToday = true;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(areContactsModifiedToday);
        }
예제 #6
0
        private void CreateContact(ContactsRequest cr, Contact contact)
        {
            var newEntry = new global::Google.Contacts.Contact
            {
                Name = new Name()
                {
                    FullName   = contact.FirstName + contact.LastName,
                    GivenName  = contact.FirstName,
                    FamilyName = contact.LastName,
                }
            };

            // Set the contact's name.

            // Set the contact's e-mail addresses.
            newEntry.Emails.Add(new EMail()
            {
                Primary = true,
                Rel     = ContactsRelationships.IsHome,
                Address = contact.EmailAddress
            });
            // Set the contact's phone numbers.
            newEntry.Phonenumbers.Add(new PhoneNumber()
            {
                Primary = true,
                Rel     = ContactsRelationships.IsWork,
                Value   = contact.PhoneNumber
            });
            // Insert the contact.
            Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));

            global::Google.Contacts.Contact createdEntry = cr.Insert(feedUri, newEntry);
            //return createdEntry;
        }
        public override async Task <ChakadQueryResult <ContactQueryResult> > Execute(ContactsQuery message)
        {
            var contacts = ContactRepository.LoadAll();

            if (!string.IsNullOrEmpty(message.SearchText))
            {
                contacts = contacts.Where(contact => contact.LastName.ToLower().Contains(message.SearchText) ||
                                          contact.LastName.ToLower().Contains(message.SearchText) ||
                                          contact.Address.ToLower().Contains(message.SearchText))
                           .ToList();
            }

            var contactQueryResult = new ChakadQueryResult <ContactQueryResult>
            {
                TotalCount = contacts.Count,
                Entities   = contacts.Select(contact => new ContactQueryResult
                {
                    Id        = contact.Id,
                    FirstName = contact.FirstName,
                    LastName  = contact.LastName,
                    Address   = contact.Address
                }).ToList()
            };


            return(contactQueryResult);
        }
        public static async Task <ContactsRequest> LoginToContactsService(string user, IWebProxy proxyOrNull)
        {
            var clientSecrets = CreateClientSecrets();
            var credential    = await LoginToGoogle(user, proxyOrNull);

            var parameters      = CreateOAuth2Parameters(clientSecrets, credential);
            var contactsRequest = new ContactsRequest(CreateRequestSettings(parameters));

            ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

            query.NumberToRetrieve = 1;
            try
            {
                var feed = contactsRequest.Service.Query(query);
            }
            catch (GDataRequestException x)
            {
                s_logger.Error("Trying to access google contacts API failed. Revoking  token and reauthorizing.", x);

                await credential.RevokeTokenAsync(CancellationToken.None);

                await GoogleWebAuthorizationBroker.ReauthorizeAsync(credential, CancellationToken.None);

                parameters      = CreateOAuth2Parameters(clientSecrets, credential);
                contactsRequest = new ContactsRequest(CreateRequestSettings(parameters));
            }

            if (proxyOrNull != null)
            {
                contactsRequest.Proxy = proxyOrNull;
            }

            return(contactsRequest);
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void ContactsAuthenticationTest()
        {
            Tracing.TraceMsg("Entering ContactsAuthenticationTest");

            ContactsQuery   query   = new ContactsQuery(ContactsQuery.CreateContactsUri(this.userName + "@googlemail.com"));
            ContactsService service = new ContactsService("unittests");

            if (this.userName != null)
            {
                service.Credentials = new GDataCredentials(this.userName, this.passWord);
            }

            ContactsFeed feed = service.Query(query);

            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("ContactsAuthTest"));

            if (feed != null && feed.Entries.Count > 0)
            {
                Tracing.TraceMsg("Found a Feed " + feed.ToString());

                foreach (ContactEntry entry in feed.Entries)
                {
                    Assert.IsTrue(entry.Etag != null, "contact entries should have etags");
                }
            }
        }
예제 #10
0
        public void SaveGoogleContact(ContactEntry googleContact)
        {
            //check if this contact was not yet inserted on google.
            if (googleContact.Id.Uri == null)
            {
                //insert contact.
                Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));

                try
                {
                    ContactEntry createdEntry = (ContactEntry)_googleService.Insert(feedUri, googleContact);
                }
                catch (Exception ex)
                {
                    //TODO: save google contact xml for diagnistics
                    throw;
                }
            }
            else
            {
                try
                {
                    //contact already present in google. just update
                    //TODO: this will fail if original contact had an empty name or rpimary email address.
                    ContactEntry updatedEntry = googleContact.Update() as ContactEntry;
                }
                catch (Exception ex)
                {
                    //TODO: save google contact xml for diagnistics
                    throw;
                }
            }
        }
예제 #11
0
        public async Task <bool> SynchContact(ContactsRequest cr, string Name, string Email)
        {
            try
            {
                Contact newEntry = new Contact();
                newEntry.Name = new Name()
                {
                    FullName = Name
                };

                newEntry.Emails.Add(new EMail()
                {
                    Primary = true,
                    Rel     = ContactsRelationships.IsWork,
                    Address = Email
                });

                newEntry.IMs.Add(new IMAddress()
                {
                    Primary  = true,
                    Rel      = ContactsRelationships.IsWork,
                    Protocol = ContactsProtocols.IsGoogleTalk,
                });

                Uri     feedUri      = new Uri(ContactsQuery.CreateContactsUri("default"));
                Contact createdEntry = cr.Insert(feedUri, newEntry);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public void ModelTestETagQuery()
        {
            Tracing.TraceMsg("Entering ModelTestETagQuery");

            RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord);

            rs.AutoPaging = true;

            ContactsRequest cr = new ContactsRequest(rs);

            Feed <Contact> f = cr.GetContacts();

            ContactsQuery q = new ContactsQuery(ContactsQuery.CreateContactsUri(null));

            q.Etag = ((ISupportsEtag)f.AtomFeed).Etag;

            try
            {
                f = cr.Get <Contact>(q);
                foreach (Contact c in f.Entries)
                {
                }
            }
            catch (GDataNotModifiedException g)
            {
                Assert.IsTrue(g != null);
            }
        }
예제 #13
0
        /// <summary>
        /// 命令执行
        /// </summary>
        /// <param name="context"></param>
        public override void Execute(DataContext context)
        {
            byte[] cmdData = context.CmdData;
            if (cmdData.Length == 0)
            {
                context.Flush(RespondCode.CmdDataLack);
                return;
            }

            ContactsQuery query = cmdData.ProtoBufDeserialize <ContactsQuery>();

            if (Compiled.Debug)
            {
                query.Debug("=== Social.GroupMembers 上行数据===");
            }

            PageResult <UserCacheInfo> pageResult = SocialBiz.GetGroupMembers(query.TargetId, query.QueryIndex, query.QuerySize);
            ContactsList result = new ContactsList
            {
                RecordCount = pageResult.RecordCount,
                QueryIndex  = pageResult.PageIndex,
                QuerySize   = pageResult.PageSize,
                IndexCount  = pageResult.PageCount,
                DataList    = pageResult.Data.Select(u => u.ToUserBase()).ToList()
            };

            context.Flush <ContactsList>(result);
        }
예제 #14
0
        /// <summary>
        /// 命令执行
        /// </summary>
        /// <param name="context"></param>
        public override void Execute(DataContext context)
        {
            byte[] cmdData = context.CmdData;
            if (cmdData.Length == 0)
            {
                context.Flush(RespondCode.CmdDataLack);
                return;
            }

            ContactsQuery query = cmdData.ProtoBufDeserialize <ContactsQuery>();

            if (Compiled.Debug)
            {
                query.Debug("=== Social.QueryFans 上行数据===");
            }

            int userId = query.TargetId == 0 ? context.UserId : query.TargetId;
            PageResult <UserFollowed> pageResult = SocialBiz.GetFollowedUserPageData(userId, query.QueryIndex, query.QuerySize);
            ContactsList result = new ContactsList
            {
                RecordCount = pageResult.RecordCount,
                QueryIndex  = pageResult.PageIndex,
                QuerySize   = pageResult.PageSize,
                IndexCount  = pageResult.PageCount,
                DataList    = pageResult.Data.Select(f => UserBiz.ReadUserCacheInfo(f.UserId).ToUserBase()).ToList()
            };

            context.Flush <ContactsList>(result);
        }
예제 #15
0
        public static ContactList GetAddressListFromGoogle(string username, string password)
        {
            ContactList list = new ContactList();

            list.Username = username;

            string          appName = "adrianj-GoogleContactsMap-1";
            ContactsService service = CreateService(username, password, appName);

            int           contactsPerQuery = 50;
            int           maxTotal         = 32000;
            ContactsQuery query            = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

            query.NumberToRetrieve = contactsPerQuery;

            for (int index = 0; index < maxTotal; index += contactsPerQuery)
            {
                query.StartIndex = index;
                ContactsFeed feed = GetContactsFeed(query, service);
                list.ValidCredentials = true;
                list.AddFromFeed(feed);
                if (feed.Entries.Count < contactsPerQuery)
                {
                    break;
                }
            }

            return(list);
        }
예제 #16
0
        /// <summary>
        /// Read all contact from google witch change after LastCacheTime
        /// </summary>
        /// <param name="LastCacheTime"></param>
        /// <returns></returns>
        public Feed <Google.Contacts.Contact> ContactItemsChangedAfter(DateTime LastCacheTime)
        {
            ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

            query.StartDate   = LastCacheTime;
            query.ShowDeleted = true;
            return(cr.Get <Google.Contacts.Contact>(query));
        }
예제 #17
0
        public ContactControllerTest()
        {
            _saveContactCommand   = A.Fake <SaveContactCommand>();
            _contactsQuery        = A.Fake <ContactsQuery>();
            _deleteContactCommand = A.Fake <DeleteContactCommand>();

            _contactController = new ContactController(_contactsQuery, _saveContactCommand, _deleteContactCommand);
        }
예제 #18
0
 public ContactController(ContactsQuery contactsQuery,
                          SaveContactCommand saveContactCommand,
                          DeleteContactCommand deleteContactCommand)
 {
     _contactsQuery        = contactsQuery;
     _saveContactCommand   = saveContactCommand;
     _deleteContactCommand = deleteContactCommand;
 }
예제 #19
0
        public void CreateNewContact()
        {
            try
            {
                ContactsService service = new ContactsService("WebGear.GoogleContactsSync");
                service.setUserCredentials(ConfigurationManager.AppSettings["Gmail.Username"],
                                           ConfigurationManager.AppSettings["Gmail.Password"]);

                #region Delete previously created test contact.
                ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                query.NumberToRetrieve = 500;

                ContactsFeed feed = service.Query(query);

                foreach (ContactEntry entry in feed.Entries)
                {
                    if (entry.PrimaryEmail != null && entry.PrimaryEmail.Address == "*****@*****.**")
                    {
                        entry.Delete();
                        break;
                    }
                }
                #endregion

                ContactEntry newEntry = new ContactEntry();
                newEntry.Title.Text = "John Doe";

                EMail primaryEmail = new EMail("*****@*****.**");
                primaryEmail.Primary = true;
                primaryEmail.Rel     = ContactsRelationships.IsWork;
                newEntry.Emails.Add(primaryEmail);

                PhoneNumber phoneNumber = new PhoneNumber("555-555-5551");
                phoneNumber.Primary = true;
                phoneNumber.Rel     = ContactsRelationships.IsMobile;
                newEntry.Phonenumbers.Add(phoneNumber);

                PostalAddress postalAddress = new PostalAddress();
                postalAddress.Value   = "123 somewhere lane";
                postalAddress.Primary = true;
                postalAddress.Rel     = ContactsRelationships.IsHome;
                newEntry.PostalAddresses.Add(postalAddress);

                newEntry.Content.Content = "Who is this guy?";

                Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));

                ContactEntry createdEntry = (ContactEntry)service.Insert(feedUri, newEntry);

                Assert.IsNotNull(createdEntry.Id.Uri);

                //delete this temp contact
                createdEntry.Delete();
            }
            catch (Exception ex)
            {
            }
        }
예제 #20
0
        /// <summary>
        /// retrieve all profiles for the domain
        /// </summary>
        public void GetAllProfiles()
        {
            ContactsQuery query =
                new ContactsQuery("https://www.google.com/m8/feeds/profiles/domain/" + this.domain + "/full");

            Feed <Contact> f = cr.Get <Contact>(query);

            this.profiles = new List <Contact>(f.Entries);
        }
예제 #21
0
        /// <summary>
        /// Get all contacts that contains the group label used. (see Constants class)
        /// </summary>
        /// <param name="creds">credentials with valid token/refresh token</param>
        /// <returns>Contacts found, null is error occured</returns>
        public static Feed <Contact> GetGroupContacts(UserCredential creds)
        {
            string groupId;

            try
            {
                groupId = GetGroupId(creds);

                if (string.IsNullOrEmpty(groupId))
                {
                    logger.Warn("GroupID is empty, it must not exist.. Creating label/group: " + Constants.GroupName);

                    groupId = CreateContactGroup(creds);
                    if (string.IsNullOrEmpty(groupId))
                    {
                        logger.Error("Could not create group/label, exiting..");
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Fatal(ex, "Error getting/creating group id");
                return(null);
            }


            var cr = BuildContactsRequest(creds);

            try
            {
                RefreshToken(creds, out bool success);
                if (!success)
                {
                    return(null);
                }

                ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                if (string.IsNullOrEmpty(groupId))
                {
                    return(null);                               //safe guard, as not setting a groupid returns all..
                }
                query.Group = groupId;

                Feed <Contact> feed = cr.Get <Contact>(query);
                feed.AutoPaging = true;
                logger.Info("Google contacts returned: " + feed.TotalResults);
                return(feed);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Could not get contacts from Google");
                return(null);
            }
        }
예제 #22
0
        private Contact LoadGoogleContacts(AtomId id)
        {
            string message = "Error Loading Google Contacts. Cannot connect to Google.\r\nPlease ensure you are connected to the internet. If you are behind a proxy, change your proxy configuration!";

            Contact ret = null;

            try
            {
                GoogleContacts = new Collection <Contact>();

                ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                query.NumberToRetrieve = 256;
                query.StartIndex       = 0;

                //Group group = GetGoogleGroupByName(myContactsGroup);
                //if (group != null)
                //    query.Group = group.Id;

                //query.ShowDeleted = false;
                //query.OrderBy = "lastmodified";

                Feed <Contact> feed = ContactsRequest.Get <Contact>(query);

                while (feed != null)
                {
                    foreach (Contact a in feed.Entries)
                    {
                        GoogleContacts.Add(a);
                        if (id != null && id.Equals(a.ContactEntry.Id))
                        {
                            ret = a;
                        }
                    }
                    query.StartIndex += query.NumberToRetrieve;
                    feed              = ContactsRequest.Get <Contact>(feed, FeedRequestType.Next);
                }

                Logger.Log(UserName + " : " + GoogleContacts.Count + " contact(s)", EventType.Debug);
            }
            catch (System.Net.WebException ex)
            {
                Logger.Log(ex.Message, EventType.Error);

                //throw new GDataRequestException(message, ex);
            }
            catch (System.NullReferenceException ex)
            {
                Logger.Log(ex.Message, EventType.Error);

                //Logger.Log(message, EventType.Error);
                //throw new GDataRequestException(message, new System.Net.WebException("Error accessing feed", ex));
            }

            return(ret);
        }
예제 #23
0
        /// <summary>
        /// Import all Google contacts
        /// </summary>
        public void ImportGmail()
        {
            string MyContactID = GetGroups();

            Contact = new List <contacts>();

            ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

            query.StartIndex  = 1;
            query.ShowDeleted = false;
            if (MyContactID != "")
            {
                query.Group = MyContactID;
            }

            Feed <Google.Contacts.Contact> f = cr.Get <Google.Contacts.Contact>(query);
            int contactsCount = f.Entries.Count();

            while (contactsCount > 0)
            {
                foreach (Google.Contacts.Contact entry in f.Entries)
                {
                    contacts contact;
                    if (ConvertContact(entry, out contact))
                    {
                        Contact.Add(contact);
                    }
                }

                query.StartIndex += contactsCount;
                f             = cr.Get <Google.Contacts.Contact>(query);
                contactsCount = f.Entries.Count();
            }


            /*for (int i = 0; i < Contact.Count; i++)
             * {
             *
             *  var item = Contact[i];
             *  if (item.AvatarUri != null)
             *  {
             *      try
             *      {
             *          item.Avatar = cr.Service.Query(item.AvatarUri);
             *      }
             *      catch (Exception err)
             *      {
             *
             *      }
             *      Contact.RemoveAt(i);
             *      Contact.Insert(i, item);
             *  }
             * }*/
        }
예제 #24
0
        public void SaveGoogleContact(ContactMatch match)
        {
            //check if this contact was not yet inserted on google.
            if (match.GoogleContact.Id.Uri == null)
            {
                //insert contact.
                Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));

                try
                {
                    ContactPropertiesUtils.SetGoogleOutlookContactId(SyncProfile, match.GoogleContact, match.OutlookContact);

                    ContactEntry createdEntry = (ContactEntry)_googleService.Insert(feedUri, match.GoogleContact);
                    match.GoogleContact = createdEntry;

                    ContactPropertiesUtils.SetOutlookGoogleContactId(this, match.OutlookContact, match.GoogleContact);
                    match.OutlookContact.Save();
                }
                catch (Exception ex)
                {
                    MemoryStream ms = new MemoryStream();
                    match.GoogleContact.SaveToXml(ms);

                    StreamReader sr = new StreamReader(ms);

                    ms.Seek(0, SeekOrigin.Begin);
                    Debug.WriteLine(String.Format("Error saving google contact: {0}", ex.Message));
                    Debug.WriteLine(sr.ReadToEnd());
                    //TODO: save google contact xml for diagnistics
                    throw;
                }
            }
            else
            {
                try
                {
                    //contact already present in google. just update
                    ContactPropertiesUtils.SetGoogleOutlookContactId(SyncProfile, match.GoogleContact, match.OutlookContact);

                    //TODO: this will fail if original contact had an empty name or rpimary email address.
                    ContactEntry updatedEntry = match.GoogleContact.Update() as ContactEntry;
                    match.GoogleContact = updatedEntry;

                    ContactPropertiesUtils.SetOutlookGoogleContactId(this, match.OutlookContact, match.GoogleContact);
                    match.OutlookContact.Save();
                }
                catch (Exception ex)
                {
                    //TODO: save google contact xml for diagnistics
                    throw;
                }
            }
        }
예제 #25
0
        public List <Contact> ContactsChangedSince(DateTime d)
        {
            List <Contact>  result = new List <Contact>();
            ContactsRequest cr     = new ContactsRequest(rs);
            ContactsQuery   q      = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));

            q.StartDate = d;
            Feed <Contact> feed = cr.Get <Contact>(q);

            foreach (Contact c in feed.Entries)
            {
                result.Add(c);
            }
            return(result);
        }
예제 #26
0
        public static AtomEntryCollection GetContacts(AtomEntry group = null)
        {
            var query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"))
            {
                NumberToRetrieve = 1000
            };

            if (group != null)
            {
                query.Group = group.Id.AbsoluteUri;
            }
            var feed     = service.Query(query);
            var contacts = feed.Entries;

            return(contacts);
        }
예제 #27
0
        public void TestCreatingGoogeAccountThatFailed3()
        {
            Outlook.ContactItem outlookContact = sync.OutlookContacts.Find(
                string.Format("[FirstName]='{0}' AND [LastName]='{1}'",
                              ConfigurationManager.AppSettings["Test.FirstName"],
                              ConfigurationManager.AppSettings["Test.LastName"])) as Outlook.ContactItem;

            ContactMatch match = FindMatch(outlookContact);

            Assert.IsNotNull(match);
            Assert.IsNull(match.GoogleContact);

            ContactEntry googleContact = new ContactEntry();

            //ContactSync.UpdateContact(outlookContact, googleContact);

            googleContact.Title.Text = outlookContact.FileAs;

            if (googleContact.Title.Text == null)
            {
                googleContact.Title.Text = outlookContact.FullName;
            }

            if (googleContact.Title.Text == null)
            {
                googleContact.Title.Text = outlookContact.CompanyName;
            }

            //SetEmails(outlookContact, googleContact);

            ContactSync.SetPhoneNumbers(outlookContact, googleContact);

            //SetAddresses(outlookContact, googleContact);

            //SetCompanies(outlookContact, googleContact);

            //SetIMs(outlookContact, googleContact);

            //googleContact.Content.Content = outlookContact.Body;

            Uri          feedUri      = new Uri(ContactsQuery.CreateContactsUri("default"));
            ContactEntry createdEntry = (ContactEntry)sync.GoogleService.Insert(feedUri, googleContact);

            ContactPropertiesUtils.SetOutlookGoogleContactId(sync, match.OutlookContact, createdEntry);
            match.GoogleContact = createdEntry;
            match.OutlookContact.Save();
        }
예제 #28
0
        public async Task <PagingModel <ChatUserModel> > GetContactsForInviteAsync(ContactsQuery query)
        {
            var dto = new GetPotentialChannelMembersRequest
            {
                NameFilter = query.NameFilter,
                PageNumber = query.PageNumber,
                PageSize   = query.PageSize
            };

            var request = new GetMembersForInviteRequest(_chatConfig.ApiUrl, _jsonSerializer, dto, query.ChannelId);

            var result = await _httpClient.TrySendAndDeserializeAsync <QueryResult <MemberSummaryResponse> >(request,
                                                                                                             _logger).ConfigureAwait(false);

            return(result == null
                ? null
                : Mapper.PagedDtoToPagingModel(result, Mapper.DtoToChatUser));
        }
예제 #29
0
 public void CreateContactFromOutlook(ContactItem oContact)
 {
     try
     {
         LogInfo("Creating contact from Outlook");
         Contact         gContact = new Contact();
         ContactsRequest cr       = new ContactsRequest(rs);
         Uri             feedUri  = new Uri(ContactsQuery.CreateContactsUri("default"));
         UpdateContactDataFromOutlook(oContact, gContact);
         cr.Insert(feedUri, gContact);
         LogInfo("Contact created");
     }
     catch (System.Exception ex)
     {
         LogError(ex.Message);
         LogDebug(ex.StackTrace.ToString());
     }
 }
예제 #30
0
        public IEnumerable <IContactInfo> GetContacts()
        {
            var query = new ContactsQuery("https://www.google.com/m8/feeds/contacts/default/full");

            query.NumberToRetrieve = int.MaxValue;
            query.ModifiedSince    = _lastSyncTime;

            var feed   = _googleService.Query(query);
            var result = feed.Entries.OfType <ContactEntry>()
                         .Where(x => !x.Deleted && x.Phonenumbers != null && x.Phonenumbers.Count > 0)
                         .Select(CreateContact).Where(x => x != null)
                         .ToArray();

            _lastSyncTime = DateTime.Now;
            _plugin.PluginManager.Core.SettingsManager.Set("LastSync", _lastSyncTime);

            return(result);
        }