internal static void DeleteAllContacts(RequestSettings rs) { rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); List <Contact> list = new List <Contact>(); int i = 0; foreach (Contact c in f.Entries) { c.BatchData = new GDataBatchEntryData(); c.BatchData.Id = i.ToString(); c.BatchData.Type = GDataBatchOperationType.delete; i++; list.Add(c); } cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.delete); f = cr.GetContacts(); Assert.IsTrue(f.TotalResults == 0, "Feed should be emtpy now"); }
private void DeleteAllContacts() { RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); List <Contact> list = new List <Contact>(); int i = 0; foreach (Contact c in f.Entries) { c.BatchData = new GDataBatchEntryData(); c.BatchData.Id = i.ToString(); c.BatchData.Type = GDataBatchOperationType.delete; i++; list.Add(c); } cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.insert); f = cr.GetContacts(); Assert.IsTrue(f.TotalResults == 0, "Feed should be emtpy now"); }
public void InsertExtendedPropertyContactsTest() { Tracing.TraceMsg("Entering InsertExtendedPropertyContactsTest"); DeleteAllContacts(); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; FeedQuery query = new FeedQuery(); query.Uri = new Uri(CreateUri(this.resourcePath + "contactsextendedprop.xml")); ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.Get <Contact>(query); Contact newEntry = null; foreach (Contact c in f.Entries) { ExtendedProperty e = c.ExtendedProperties[0]; Assert.IsTrue(e != null); newEntry = c; } f = cr.GetContacts(); Contact createdEntry = cr.Insert <Contact>(f, newEntry); cr.Delete(createdEntry); }
public IEnumerable <Contact> GetAll() { var contactRequest = new ContactsRequest(_settings); var googleContacts = contactRequest.GetContacts().Entries.Where(c => !c.Deleted).OrderBy(c => c.Name.FamilyName).ToList(); return(googleContacts.Select(ParseGoogleContact).Where(c => c != null).ToList()); }
public IEnumerable <Contact> GetAllInGroups(IEnumerable <string> groupIds) { var contactRequest = new ContactsRequest(_settings); var googleContacts = contactRequest.GetContacts().Entries.Where(c => !c.Deleted && groupIds.All(gid => IsInGroup(c, gid))).OrderBy(c => c.Name.FamilyName).ToList(); return(googleContacts.Select(ParseGoogleContact).Where(c => c != null).ToList()); }
public void OAuth2LeggedContactsTest() { Tracing.TraceMsg("Entering OAuth2LeggedContactsTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); // modify one foreach (Contact c in f.Entries) { c.Title = "new title"; cr.Update(c); break; } Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(1); entry.PrimaryEmail.Address = "*****@*****.**"; Contact e = cr.Insert(f, entry); cr.Delete(e); }
/// <summary> /// Fetches list of Google contacts. /// </summary> /// <returns></returns> public static Feed <Contact> GetGContactsList() { //Waiting for the service authentication to complete. _autoEvent.WaitOne(); Feed <Contact> feed = null; try { //In case an error was encountered go back. if (_parameters == null || _exception != null) { return(feed); } //Creating the request factory for the Drive service. GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, APPLICATION_NAME, _parameters); //Creating Request Settings instance RequestSettings settings = new RequestSettings(APPLICATION_NAME, _parameters); //Creating a request for fetching list of Google Contacts. ContactsRequest cr = new ContactsRequest(settings); //Fetching the list of Contacts. feed = cr.GetContacts(); } catch (Exception Ex) { _exception = Ex; } finally { //Can now signal other threads to continue accessing/refreshing services. _autoEvent.Set(); } return(feed); }
public List <GmailContacts> getall(string email, string pass) { RequestSettings reqSettings = new RequestSettings("My Application", email, pass); reqSettings.AutoPaging = true; ContactsRequest contReq = new ContactsRequest(reqSettings); var Contacts = contReq.GetContacts(); List <GmailContacts> objContacts = new List <GmailContacts>(); foreach (var objContact in Contacts.Entries) { GmailContacts objGmailContacts = new GmailContacts(); objGmailContacts.Title = objContact.Title.ToString(); foreach (EMail emailId in objContact.Emails) { objGmailContacts.EmailID = emailId.Address.ToString() + ","; } if (objGmailContacts.EmailID != null) { objGmailContacts.EmailID = objGmailContacts.EmailID.Substring(0, objGmailContacts.EmailID.Length - 1); } objContacts.Add(objGmailContacts); } return(objContacts); }
protected void Button1_Click(object sender, EventArgs e) { // Define string of list List <string> lstContacts = new List <string>(); // Below requestsetting class take 3 parameters applicationname, gmail username, gmail password. // Provide appropriate Gmail account details RequestSettings rsLoginInfo = new RequestSettings("", "MailId", "Password"); rsLoginInfo.AutoPaging = true; ContactsRequest cRequest = new ContactsRequest(rsLoginInfo); // fetch contacts list Feed <Contact> feedContacts = cRequest.GetContacts(); // looping the feedcontact entries foreach (Contact gmailAddresses in feedContacts.Entries) { // Looping to read email addresses foreach (EMail emailId in gmailAddresses.Emails) { lstContacts.Add(emailId.Address); } } // finally binding the list to gridview defined in above step GridView1.DataSource = lstContacts; GridView1.DataBind(); }
public bool Extract(NetworkCredential credential, out MailContactList list) { bool result = false; list = new MailContactList(); try { var rs = new RequestSettings("eStream-AspNetDating", credential.UserName, credential.Password) {AutoPaging = true}; var cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); foreach (Contact e in f.Entries) { foreach (var email in e.Emails) { var mailContact = new MailContact {Email = email.Address, Name = e.Title}; list.Add(mailContact); } } result = true; } catch (Exception ex) { Global.Logger.LogError(ex); } return result; }
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); } }
protected void loginButton_Click(object sender, EventArgs e) { //We will test the users credentials by attempting a data extraction from the address book. //The data extraction will be small since we set autopaging to false. This will ensure a good efficiency. RequestSettings settings = new RequestSettings("ProQuorum Messaging Module", userName.Text, password.Text); settings.AutoPaging = false; ContactsRequest cr = new ContactsRequest(settings); Feed <Contact> f = cr.GetContacts(); try { foreach (Contact entry in f.Entries) { break; } //If the application is able to reach this point then the credentials are valid. //Set the session variables so the user does not have to keep logging in. Session["username"] = userName.Text; Session["password"] = password.Text; Response.Redirect("http://localhost:1172/messaging.aspx"); } catch (Exception ex) { Output.Text = "Invalid Username and Password combination. Please try again."; } }
public List <Contact> GetGoogleContacts(bool filter = false) { if (_google == null) { return(new List <Contact>()); } var feed = _google.GetContacts(); feed.Maximum = MaxNo; var filtered = new List <Contact>(); foreach (Contact contact in feed.Entries) { if (!filter) { filtered.Add(contact); continue; } if (!HasFbKey(contact)) { filtered.Add(contact); } } filtered.Sort(ContactComparison); return(filtered); }
public void OAuth2LeggedModelContactsBatchInsertTest() { const int numberOfInserts = 10; Tracing.TraceMsg("Entering OAuth2LeggedModelContactsBatchInsertTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); ContactsTestSuite.DeleteAllContacts(rs); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); int originalCount = f.TotalResults; PhoneNumber p = null; List <Contact> inserted = new List <Contact>(); if (f != null) { Assert.IsTrue(f.Entries != null, "the contacts needs entries"); for (int i = 0; i < numberOfInserts; i++) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i); entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com"; p = entry.PrimaryPhonenumber; inserted.Add(cr.Insert(f, entry)); } } List <Contact> list = new List <Contact>(); f = cr.GetContacts(); foreach (Contact e in f.Entries) { list.Add(e); } Assert.AreEqual(numberOfInserts, inserted.Count); // now delete them again ContactsTestSuite.DeleteList(inserted, cr, new Uri(f.AtomFeed.Batch)); }
public IEnumerable <Contact> RetrieveContacts(ResourceAuthToken authParams) { RequestSettings settings = new RequestSettings("ContactsManager", authParams.AuthToken); ContactsRequest contactsProvider = new ContactsRequest(settings); var googleContactResult = contactsProvider.GetContacts(); var contactsList = CastEntriesToContacts(googleContactResult.Entries, contactsProvider); return(contactsList); }
private static void PrintAllContacts(ContactsRequest cr) { Feed<Contact> f = cr.GetContacts(); foreach (Contact entry in f.Entries) { if (entry.Name != null) { Name name = entry.Name; if (!string.IsNullOrEmpty(name.FullName)) Console.WriteLine("\t\t" + name.FullName); else Console.WriteLine("\t\t (no full name found)"); if (!string.IsNullOrEmpty(name.NamePrefix)) Console.WriteLine("\t\t" + name.NamePrefix); else Console.WriteLine("\t\t (no name prefix found)"); if (!string.IsNullOrEmpty(name.GivenName)) { string givenNameToDisplay = name.GivenName; if (!string.IsNullOrEmpty(name.GivenNamePhonetics)) givenNameToDisplay += " (" + name.GivenNamePhonetics + ")"; Console.WriteLine("\t\t" + givenNameToDisplay); } else Console.WriteLine("\t\t (no given name found)"); if (!string.IsNullOrEmpty(name.AdditionalName)) { string additionalNameToDisplay = name.AdditionalName; if (string.IsNullOrEmpty(name.AdditionalNamePhonetics)) additionalNameToDisplay += " (" + name.AdditionalNamePhonetics + ")"; Console.WriteLine("\t\t" + additionalNameToDisplay); } else Console.WriteLine("\t\t (no additional name found)"); if (!string.IsNullOrEmpty(name.FamilyName)) { string familyNameToDisplay = name.FamilyName; if (!string.IsNullOrEmpty(name.FamilyNamePhonetics)) familyNameToDisplay += " (" + name.FamilyNamePhonetics + ")"; Console.WriteLine("\t\t" + familyNameToDisplay); } else Console.WriteLine("\t\t (no family name found)"); if (!string.IsNullOrEmpty(name.NameSuffix)) Console.WriteLine("\t\t" + name.NameSuffix); else Console.WriteLine("\t\t (no name suffix found)"); } else Console.WriteLine("\t (no name found)"); foreach (EMail email in entry.Emails) { Console.WriteLine("\t" + email.Address); } } }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /// <summary>runs an basic auth test against the groups feed test</summary> ////////////////////////////////////////////////////////////////////// [Test] public void GroupsModelTest() { Tracing.TraceMsg("Entering GroupsModelTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Group> fg = cr.GetGroups(); Group newGroup = new Group(); newGroup.Title = "Private Data"; Group insertedGroup = cr.Insert(fg, newGroup); Group g2 = new Group(); g2.Title = "Another private Group"; Group insertedGroup2 = cr.Insert(fg, g2); // now insert a new contact that belongs to that group Feed <Contact> fc = cr.GetContacts(); Contact c = new Contact(); c.AtomEntry = ObjectModelHelper.CreateContactEntry(1); GroupMembership member = new GroupMembership(); member.HRef = insertedGroup.Id; GroupMembership member2 = new GroupMembership(); member2.HRef = insertedGroup2.Id; Contact insertedEntry = cr.Insert(fc, c); // now change the group membership insertedEntry.GroupMembership.Add(member); insertedEntry.GroupMembership.Add(member2); Contact currentEntry = cr.Update(insertedEntry); Assert.IsTrue(currentEntry.GroupMembership.Count == 2, "The entry should be in 2 groups"); currentEntry.GroupMembership.Clear(); currentEntry = cr.Update(currentEntry); Assert.IsTrue(currentEntry.GroupMembership.Count == 0, "The entry should not be in a group"); cr.Delete(currentEntry); cr.Delete(insertedGroup); cr.Delete(insertedGroup2); }
public static void PrintAllContacts(ContactsRequest cr) { Feed <Contact> feed = cr.GetContacts(Email); Console.WriteLine(feed.TotalResults); foreach (Contact entry in feed.Entries) { Console.WriteLine(entry.Name.FullName); } }
public IEnumerable<IContact> GetContacts() { ContactsRequest cr = new ContactsRequest(_rs); //cr.Service.RequestFactory = new GDataLoggingRequestFactory(cr.Service.ServiceIdentifier, "GContactSync"); Feed<Google.Contacts.Contact> feed = cr.GetContacts(); List<IContact> list = new List<IContact>(); foreach (Google.Contacts.Contact gContact in feed.Entries) { IContact c = new GContact(_rs, gContact); list.Add(c); } return list; }
public IEnumerable <IContact> GetContacts() { ContactsRequest cr = new ContactsRequest(_rs); //cr.Service.RequestFactory = new GDataLoggingRequestFactory(cr.Service.ServiceIdentifier, "GContactSync"); Feed <Google.Contacts.Contact> feed = cr.GetContacts(); List <IContact> list = new List <IContact>(); foreach (Google.Contacts.Contact gContact in feed.Entries) { IContact c = new GContact(_rs, gContact); list.Add(c); } return(list); }
/// <summary> /// Send authorized queries to a Request-based library /// </summary> /// <param name="service"></param> private static void RunContactsSample(OAuth2Parameters parameters) { try { RequestSettings settings = new RequestSettings(applicationName, parameters); ContactsRequest cr = new ContactsRequest(settings); Feed<Contact> f = cr.GetContacts(); foreach (Contact c in f.Entries) { Console.WriteLine(c.Name.FullName); } } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
public void TestContactFeed() { Contact contact = new Contact(); //RequestSettings settings = new RequestSettings("Google contacts tutorial", parameters); RequestSettings settings = new RequestSettings("Google contacts tutorial"); ContactsRequest cr = new ContactsRequest(settings); Feed <Contact> feed = cr.GetContacts(); foreach (Contact c in feed.Entries) { //Console.WriteLine(c.Name.FullName); } //Feed<Document> feed = r.GetDocuments(); Feed <Group> fg = cr.GetGroups(); }
public DataTable GetContactsNames() { OAuth2Parameters parameters = new OAuth2Parameters(); parameters.AccessToken = credential.Token.AccessToken; parameters.RefreshToken = credential.Token.RefreshToken; RequestSettings settings = new RequestSettings(ApplicationName, parameters); ContactsRequest cr = new ContactsRequest(settings); Nameday nday = new Nameday(); DataTable dataTable = new DataTable(); DataColumn dataCol = dataTable.Columns.Add("Jmeno", typeof(string)); dataCol.AllowDBNull = false; dataCol.Unique = true; dataCol = dataTable.Columns.Add("Datum", typeof(string)); dataCol.ReadOnly = true; Feed <Contact> f = cr.GetContacts(); foreach (Contact entry in f.Entries) { if (entry.Name != null) { Name name = entry.Name; if (!string.IsNullOrEmpty(name.GivenName)) { Console.WriteLine("\t\t" + name.GivenName); dataTable.Rows.Add(new Object[] { name.GivenName, nday.GetDate(name.GivenName) }); } else { Console.WriteLine("\t\t (no given name found)"); } } else { Console.WriteLine("\t (no name found)"); } } return(dataTable); }
public async Task <IEnumerable <F3.ViewModels.Contact> > GetContacts() { var rs = new RequestSettings("F3Test", Token.AccessToken); rs.AutoPaging = true; var cr = new ContactsRequest(rs); var f = cr.GetContacts(); var c = f.Entries.Select(e => new F3.ViewModels.Contact { Email = e.Emails.Any() ? e.Emails.First().Address : string.Empty, FirstName = e.Name.GivenName, LastName = e.Name.FamilyName, Id = e.Id }).ToList(); return(c); }
public int EnumerateGoogleContacts() { int SynchedContacts = 0; rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> fc = cr.GetContacts(); foreach (Contact gContact in fc.Entries) { _Contacts.Add(gContact); if (GContactFeched != null) { GContactFeched(this, gContact); } } return(SynchedContacts); }
public bool LoginGoogle(string user, string password) { try { var settings = new RequestSettings(Config.appName, user, password) { Maximum = MaxNo, AutoPaging = true }; _google = new ContactsRequest(settings); IsGoogleLogin = (_google.GetContacts().PageSize > 0); return(IsGoogleLogin); } catch (Exception e) { return(false); } }
/// <summary> /// Send authorized queries to a Request-based library /// </summary> /// <param name="service"></param> private static void RunContactsSample(OAuth2Parameters parameters) { try { RequestSettings settings = new RequestSettings(applicationName, parameters); ContactsRequest cr = new ContactsRequest(settings); Feed <Contact> f = cr.GetContacts(); foreach (Contact c in f.Entries) { Console.WriteLine(c.Name.FullName); } } catch (AppsException a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); Console.WriteLine("Error code: {0}", a.ErrorCode); Console.WriteLine("Invalid input: {0}", a.InvalidInput); Console.WriteLine("Reason: {0}", a.Reason); } }
private static void RunContactsSample(OAuth2Parameters parameters) { try { RequestSettings settings = new RequestSettings("Google contacts tutorial", parameters); ContactsRequest cr = new ContactsRequest(settings); var f = cr.GetContacts(); foreach (Contact c in f.Entries) { Console.WriteLine(c.Name.FullName + c.PrimaryPhonenumber); } } catch (Exception a) { Console.WriteLine("A Google Apps error occurred."); Console.WriteLine(); } Console.Read(); }
private void fetchContactList() { // Define string of list List<string> lstContacts = new List<string>(); // Below requestsetting class take 3 parameters applicationname, gmail username, gmail password. Provide appropriate Gmail account details RequestSettings rsLoginInfo = new RequestSettings("", textBox1.Text, textBox2.Text); rsLoginInfo.AutoPaging = true; ContactsRequest cRequest = new ContactsRequest(rsLoginInfo); // fetch contacts list Feed<Contact> feedContacts = cRequest.GetContacts(); //dataGridView1.ColumnCount = 1; //dataGridView1.Columns[0].Name = "Product ID"; // looping the feedcontact entries try { // dataGridView1.Columns.Add("Name", "Name"); RichTextBox rtb = new RichTextBox(); string email = ""; DataTable dt = new DataTable(); dt.Columns.Add("Email Address"); foreach (Contact gmailAddresses in feedContacts.Entries) { // Looping to read email addresses foreach (EMail emailId in gmailAddresses.Emails) { dt.Rows.Add(new object[] {email=emailId.Address}); dataGridView1.DataSource = dt; } dataGridView1.Show(); } } catch (Exception) { MessageBox.Show("Error Please enter the correct credentials","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); //throw; } }
/// <summary> /// Gets the contacts list form the contact provider. /// </summary> /// <returns></returns> public EntityCollection <IContactItem> GetContactsList() { EntityCollection <IContactItem> collection = new EntityCollection <IContactItem>(); // Setup the contacts request (autopage true returns all contacts) RequestSettings requestSettings = new RequestSettings("AgileMe", UserName, Password); requestSettings.AutoPaging = true; ContactsRequest contactsRequest = new ContactsRequest(requestSettings); // Get the feed Feed <Contact> feed = contactsRequest.GetContacts(); // create our collection by looping through the feed foreach (Contact contact in feed.Entries) { GoogleContactItem newContact = new GoogleContactItem(); newContact.Name = contact.PrimaryEmail.Address; newContact.Summary = contact.Summary; collection.Add(newContact); } return(collection); }
protected void btnContacts_Click(object sender, EventArgs e) { //Provide Login Information ViewState["hello"] = txtPassword.Text; RequestSettings rsLoginInfo = new RequestSettings("", txtEmail.Text, txtPassword.Text); rsLoginInfo.AutoPaging = true; // Fetch contacts and dislay them in ListBox ContactsRequest cRequest = new ContactsRequest(rsLoginInfo); Feed<Contact> feedContacts = cRequest.GetContacts(); foreach (Contact gmailAddresses in feedContacts.Entries) { foreach (EMail emailId in gmailAddresses.Emails) { RadListBoxItem item = new RadListBoxItem(); item.Text = emailId.Address; RadListBoxSource.Items.Add(item); } } }
public List <GmailContacts> GetContacts(GooglePlusAccessToken serStatus) { string google_client_id = "936649599657-s9akus1uv18lo7b103ji7t3cu1ljlfjb.apps.googleusercontent.com"; string google_client_sceret = "w5nmQnac-A2gBLR8dh2YWGqk"; /*Get Google Contacts From Access Token and Refresh Token*/ // string refreshToken = serStatus.refresh_token; string accessToken = serStatus.access_token; string scopes = "https://www.google.com/m8/feeds/contacts/default/full/"; OAuth2Parameters oAuthparameters = new OAuth2Parameters() { ClientId = google_client_id, ClientSecret = google_client_sceret, RedirectUri = "http://" + Global.MainLink + "/MyContact/AddGoogleContacts", Scope = scopes, AccessToken = accessToken, // RefreshToken = refreshToken }; RequestSettings settings = new RequestSettings("Group Gifts ", oAuthparameters); ContactsRequest cr = new ContactsRequest(settings); ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default")); query.NumberToRetrieve = 5000; Feed <Contact> ContactList = cr.GetContacts(); List <GmailContacts> olist = new List <GmailContacts>(); foreach (Contact contact in ContactList.Entries) { foreach (EMail email in contact.Emails) { GmailContacts gc = new GmailContacts(); gc.EmailID = email.Address; var a = contact.Name.FullName; olist.Add(gc); } } return(olist); }
static void Main(string[] args) { RequestSettings rs = new RequestSettings("prueba", "usuario", "contraseña"); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); foreach (Contact e in f.Entries) { foreach (EMail email in e.Emails) { Console.WriteLine(email.Address); } foreach (IMAddress im in e.IMs) { Console.WriteLine(im.Address); } } Console.Read(); }
public static List<ContactsView> GetGmailContacts(string App_Name, string Uname, string UPassword) { var contacts = new List<ContactsView>(); var rs = new RequestSettings(App_Name, Uname, UPassword){ AutoPaging = true }; var contactsRequest = new ContactsRequest(rs); var feed = contactsRequest.GetContacts(); foreach (Contact contact in feed.Entries) { var fetchedContact = new ContactsView { Name = contact.Name.FullName }; foreach (EMail email in contact.Emails) { if (email.Address == null) continue; fetchedContact.Email = email.Address; } contacts.Add(fetchedContact); } return contacts; }
protected void btnContacts_Click(object sender, EventArgs e) { //Provide Login Information ViewState["hello"] = txtPassword.Text; RequestSettings rsLoginInfo = new RequestSettings("", txtEmail.Text, txtPassword.Text); rsLoginInfo.AutoPaging = true; // Fetch contacts and dislay them in ListBox ContactsRequest cRequest = new ContactsRequest(rsLoginInfo); Feed <Contact> feedContacts = cRequest.GetContacts(); foreach (Contact gmailAddresses in feedContacts.Entries) { foreach (EMail emailId in gmailAddresses.Emails) { RadListBoxItem item = new RadListBoxItem(); item.Text = emailId.Address; RadListBoxSource.Items.Add(item); } } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test, inserts a new contact</summary> ////////////////////////////////////////////////////////////////////// [Test] public void ModelPhotoTest() { Tracing.TraceMsg("Entering ModelPhotoTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed <Contact> f = cr.GetContacts(); Contact e = null; if (f != null) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(1); entry.PrimaryEmail.Address = "*****@*****.**"; e = cr.Insert(f, entry); } Assert.IsTrue(e != null, "we should have a contact here"); Stream s = cr.GetPhoto(e); Assert.IsTrue(s == null, "There should be no photo yet"); using (FileStream fs = new FileStream(this.resourcePath + "contactphoto.jpg", System.IO.FileMode.Open)) { cr.SetPhoto(e, fs); } // now delete the guy, which requires us to reload him from the server first, as the photo change operation // changes the etag off the entry e = cr.Retrieve(e); cr.Delete(e); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test, inserts a new contact</summary> ////////////////////////////////////////////////////////////////////// [Test] public void ModelBatchContactsTest() { const int numberOfInserts = 5; Tracing.TraceMsg("Entering ModelInsertContactsTest"); DeleteAllContacts(); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); List<Contact> list = new List<Contact>(); Feed<Contact> f = cr.GetContacts(); for (int i = 0; i < numberOfInserts; i++) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i); entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com"; GDataBatchEntryData g = new GDataBatchEntryData(); g.Id = i.ToString(); g.Type = GDataBatchOperationType.insert; entry.BatchData = g; list.Add(entry); } Feed<Contact> r = cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.Default); list.Clear(); int iVerify = 0; foreach (Contact c in r.Entries ) { // let's count and update them iVerify++; c.Title = "get a nother one"; c.BatchData.Type = GDataBatchOperationType.update; list.Add(c); } Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 inserts"); Feed<Contact> u = cr.Batch(list, new Uri(r.AtomFeed.Batch), GDataBatchOperationType.Default); list.Clear(); iVerify = 0; foreach (Contact c in u.Entries ) { // let's count and update them iVerify++; c.BatchData.Type = GDataBatchOperationType.delete; list.Add(c); } Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 updates"); Feed<Contact> d = cr.Batch(list, new Uri(u.AtomFeed.Batch), GDataBatchOperationType.Default); iVerify = 0; foreach (Contact c in d.Entries ) { if (c.BatchData.Status.Code == 200) { // let's count and update them iVerify++; } } Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 deletes"); }
public void ModelTestETagQuery() { const int numberOfInserts = 5; 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); } }
private void DeleteAllContacts() { RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); List<Contact> list = new List<Contact>(); int i=0; foreach (Contact c in f.Entries) { c.BatchData = new GDataBatchEntryData(); c.BatchData.Id = i.ToString(); c.BatchData.Type = GDataBatchOperationType.delete; i++; list.Add(c); } cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.insert); f = cr.GetContacts(); Assert.IsTrue(f.TotalResults == 0, "Feed should be emtpy now"); }
public static void Main(string [] args) { if (args.Length < 2) { Console.WriteLine ("usage: gcontact-yomigana.exe [username] [password] [--delete]"); return; } if (args.Length > 2 && args [2] == "--delete") { Console.WriteLine ("Cleanup mode"); cleanup = true; } ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback; string username = args [0]; string password = args [1]; var rs = new RequestSettings (app_name, username, password); rs.AutoPaging = true; var cr = new ContactsRequest (rs); #if false var cq = new ContactsQuery (ContactsQuery.CreateContactsUri(null)); cq.Group = "My Contacts"; var results = cr.Get<Contact> (cq); #else var results = cr.GetContacts (); #endif if (cleanup) { foreach (var c in results.Entries) { // these silly null check is required since // setting value to nonexistent field causes AE. if (c.Name.FamilyNamePhonetics != null) c.Name.FamilyNamePhonetics = null; if (c.Name.GivenNamePhonetics != null) c.Name.GivenNamePhonetics = null; #if false // this does not work if (c.ContactEntry.Dirty) Console.WriteLine ("{0} {1} being updated", c.Name.FamilyName, c.Name.GivenName); #else cr.Update<Contact> (c); #endif } #if false // Probably this does not work for extensions results.AtomFeed.Publish (); #endif return; } var l = new List<string> (); var dic = new Dictionary<string,string> (); foreach (var c in results.Entries) CollectName (c.Name, l); // query to mecab server string req = String.Join (" ", l.ToArray ()); byte [] bytes = new WebClient ().DownloadData (server_url_param + req); string res = Encoding.UTF8.GetString (bytes); string [] rl = res.Split (' '); if (rl.Length != l.Count) throw new Exception ("Some error occured. I cannot handle address book entry that contains 'm(__)m'."); for (int i = 0; i < l.Count; i++) { var dst = rl [i].Replace ("m(__)m", " "); if (l [i] != dst) dic [l [i]] = dst; } foreach (var p in dic) Console.Write ("{0}=> {1}, ", p.Key, p.Value); // update foreach (var c in results.Entries) UpdateName (c, dic, cr); #if false // Probably this does not work for extension fields. results.AtomFeed.Publish (); #endif }
private void GetAllGoogleContacts(string access_code) { try { parameters.AccessCode = access_code; OAuthUtil.GetAccessToken(parameters); RequestSettings rs = new RequestSettings("ImportContacts", parameters); // AutoPaging results in automatic paging in order to retrieve all contacts rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); ProcessGoogleContacts(f); } catch (Exception ex) { Console.WriteLine(ex.ToString()); NotifyDownloadStatus(DownloadStatus.ERROR_SENDING_REQUEST, ""); } }
internal static void DeleteAllContacts(RequestSettings rs) { rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); List<Contact> list = new List<Contact>(); int i=0; foreach (Contact c in f.Entries) { c.BatchData = new GDataBatchEntryData(); c.BatchData.Id = i.ToString(); c.BatchData.Type = GDataBatchOperationType.delete; i++; list.Add(c); } cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.delete); f = cr.GetContacts(); Assert.IsTrue(f.TotalResults == 0, "Feed should be empty now"); }
public void InsertExtendedPropertyContactsTest() { Tracing.TraceMsg("Entering InsertExtendedPropertyContactsTest"); DeleteAllContacts(); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; FeedQuery query = new FeedQuery(); query.Uri = new Uri(CreateUri(this.resourcePath + "contactsextendedprop.xml")); ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.Get<Contact>(query); Contact newEntry = null; foreach (Contact c in f.Entries) { ExtendedProperty e = c.ExtendedProperties[0]; Assert.IsTrue(e != null); newEntry = c; } f = cr.GetContacts(); Contact createdEntry = cr.Insert<Contact>(f, newEntry); cr.Delete(createdEntry); }
public IEnumerable<Contact> GetAll() { var contactRequest = new ContactsRequest(_settings); var googleContacts = contactRequest.GetContacts().Entries.Where(c => !c.Deleted).OrderBy(c => c.Name.FamilyName).ToList(); return googleContacts.Select(ParseGoogleContact).Where(c => c != null).ToList(); }
private void GetAllGoogleContacts(String access_code) { parameters.AccessCode = access_code; OAuthUtil.GetAccessToken(parameters); RequestSettings rs = new RequestSettings("ImportContacts", parameters); // AutoPaging results in automatic paging in order to retrieve all contacts rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); ProcessGoogleContacts(f); }
public IEnumerable<Contact> GetAllInGroups(IEnumerable<string> groupIds) { var contactRequest = new ContactsRequest(_settings); var googleContacts = contactRequest.GetContacts().Entries.Where(c => !c.Deleted && groupIds.All(gid => IsInGroup(c, gid))).OrderBy(c => c.Name.FamilyName).ToList(); return googleContacts.Select(ParseGoogleContact).Where(c => c != null).ToList(); }
public void OAuth2LeggedContactsTest() { Tracing.TraceMsg("Entering OAuth2LeggedContactsTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); // modify one foreach (Contact c in f.Entries) { c.Title = "new title"; cr.Update(c); break; } Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(1); entry.PrimaryEmail.Address = "*****@*****.**"; Contact e = cr.Insert(f, entry); cr.Delete(e); }
public void OAuth2LeggedModelContactsBatchInsertTest() { const int numberOfInserts = 10; Tracing.TraceMsg("Entering OAuth2LeggedModelContactsBatchInsertTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); ContactsTestSuite.DeleteAllContacts(rs); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); int originalCount = f.TotalResults; PhoneNumber p = null; List<Contact> inserted = new List<Contact>(); if (f != null) { Assert.IsTrue(f.Entries != null, "the contacts needs entries"); for (int i = 0; i < numberOfInserts; i++) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i); entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com"; p = entry.PrimaryPhonenumber; inserted.Add(cr.Insert(f, entry)); } } List<Contact> list = new List<Contact>(); f = cr.GetContacts(); foreach (Contact e in f.Entries) { list.Add(e); } Assert.AreEqual(numberOfInserts, inserted.Count); // now delete them again ContactsTestSuite.DeleteList(inserted, cr, new Uri(f.AtomFeed.Batch)); }
private void AddContactClick(object sender, RoutedEventArgs e) { try { var settings = Authorize(new[] { ContactsScope }); if (settings == null) return; var contactRequest = new ContactsRequest(settings); var contacts = contactRequest.GetContacts(); foreach (var contact in contacts.Entries) { Console.WriteLine(contact.Name.FullName); } } catch (Exception ex) { Console.WriteLine("A Google Apps error occurred:"); Console.WriteLine(ex.Message); } }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /// <summary>runs an basic auth test against the groups feed test</summary> ////////////////////////////////////////////////////////////////////// [Test] public void GroupsModelTest() { Tracing.TraceMsg("Entering GroupsModelTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Group> fg = cr.GetGroups(); Group newGroup = new Group(); newGroup.Title = "Private Data"; Group insertedGroup = cr.Insert(fg, newGroup); Group g2 = new Group(); g2.Title = "Another private Group"; Group insertedGroup2 = cr.Insert(fg, g2); // now insert a new contact that belongs to that group Feed<Contact> fc = cr.GetContacts(); Contact c = new Contact(); c.AtomEntry = ObjectModelHelper.CreateContactEntry(1); GroupMembership member = new GroupMembership(); member.HRef = insertedGroup.Id; GroupMembership member2 = new GroupMembership(); member2.HRef = insertedGroup2.Id; Contact insertedEntry = cr.Insert(fc, c); // now change the group membership insertedEntry.GroupMembership.Add(member); insertedEntry.GroupMembership.Add(member2); Contact currentEntry = cr.Update(insertedEntry); Assert.IsTrue(currentEntry.GroupMembership.Count == 2, "The entry should be in 2 groups"); currentEntry.GroupMembership.Clear(); currentEntry = cr.Update(currentEntry); Assert.IsTrue(currentEntry.GroupMembership.Count == 0, "The entry should not be in a group"); cr.Delete(currentEntry); cr.Delete(insertedGroup); cr.Delete(insertedGroup2); }
public bool LoginGoogle(string user, string password) { try { var settings = new RequestSettings(Config.appName, user, password){Maximum = MaxNo, AutoPaging = true}; _google = new ContactsRequest(settings); IsGoogleLogin = (_google.GetContacts().PageSize > 0); return IsGoogleLogin; } catch (Exception e) { return false; } }
////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test, inserts a new contact</summary> ////////////////////////////////////////////////////////////////////// [Test] public void ModelUpdateContactsTest() { const int numberOfInserts = 5; Tracing.TraceMsg("Entering ModelInsertContactsTest"); DeleteAllContacts(); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); int originalCount = f.TotalResults; PhoneNumber p = null; List<Contact> inserted = new List<Contact>(); if (f != null) { Assert.IsTrue(f.Entries != null, "the contacts needs entries"); for (int i = 0; i < numberOfInserts; i++) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i); entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com"; p = entry.PrimaryPhonenumber; inserted.Add(cr.Insert(f, entry)); } } string newTitle = "This is an update to the title"; f = cr.GetContacts(); if (inserted.Count > 0) { int iVer = numberOfInserts; // let's find those guys foreach (Contact e in f.Entries ) { for (int i = 0; i < inserted.Count; i++) { Contact test = inserted[i]; if (e.Id == test.Id) { iVer--; // verify we got the phonenumber back.... Assert.IsTrue(e.PrimaryPhonenumber != null, "They should have a primary phonenumber"); Assert.AreEqual(e.PrimaryPhonenumber.Value,p.Value, "They should be identical"); e.Title = newTitle; inserted[i] = cr.Update(e); } } } Assert.IsTrue(iVer == 0, "The new entries should all be part of the feed now, we have " + iVer + " left"); } f = cr.GetContacts(); if (inserted.Count > 0) { int iVer = numberOfInserts; // let's find those guys foreach (Contact e in f.Entries ) { for (int i = 0; i < inserted.Count; i++) { Contact test = inserted[i]; if (e.Id == test.Id) { iVer--; // verify we got the phonenumber back.... Assert.IsTrue(e.PrimaryPhonenumber != null, "They should have a primary phonenumber"); Assert.AreEqual(e.PrimaryPhonenumber.Value,p.Value, "They should be identical"); Assert.AreEqual(e.Title, newTitle, "The title should have been updated"); } } } Assert.IsTrue(iVer == 0, "The new entries should all be part of the feed now, we have: " + iVer + " now"); } // now delete them again DeleteList(inserted, cr, new Uri(f.AtomFeed.Batch)); // now make sure they are gone if (inserted.Count > 0) { int iVer = inserted.Count; f = cr.GetContacts(); foreach (Contact e in f.Entries) { // let's find those guys, we should not find ANY for (int i = 0; i < inserted.Count; i++) { Contact test = inserted[i] as Contact; Assert.IsTrue(e.Id != test.Id, "The new entries should all be deleted now"); } } Assert.IsTrue(f.TotalResults == originalCount, "The count should be correct as well"); } }
private void GetContactList(string username, string password) { contactTable.Columns.Add("Photo", typeof(System.Drawing.Bitmap)); contactTable.Columns.Add("Name", typeof(string)); contactTable.Columns.Add("Email", typeof(string)); toDataGrid.DataSource = contactTable; toDataGrid.ShowCellToolTips = false; ccDataGrid.DataSource = contactTable; bccDataGrid.DataSource = contactTable; DataGridViewColumn column = toDataGrid.Columns[0]; column.Width = 42; column.HeaderText = ""; column = ccDataGrid.Columns[0]; column.Width = 42; column.HeaderText = ""; column = bccDataGrid.Columns[0]; column.Width = 42; column.HeaderText = ""; ContactsService client = new ContactsService("William Randol-Gmail Icon Notifier-0.8 (RC1)"); client.setUserCredentials(user, pass); string authToken = client.QueryAuthenticationToken(); // Authenticate the user immediately RequestSettings rs = new RequestSettings("Gmail Icon Notifier", user, pass); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); foreach (Contact c in f.Entries) { foreach (EMail email in c.Emails) { contactTable.Rows.Add(contactPhoto(c, authToken), c.Title, email.Address); } } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>runs an authentication test, inserts a new contact</summary> ////////////////////////////////////////////////////////////////////// [Test] public void ModelPhotoTest() { Tracing.TraceMsg("Entering ModelPhotoTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); Contact e = null; if (f != null) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(1); entry.PrimaryEmail.Address = "*****@*****.**"; e = cr.Insert(f, entry); } Assert.IsTrue(e!=null, "we should have a contact here"); Stream s = cr.GetPhoto(e); Assert.IsTrue(s == null, "There should be no photo yet"); using (FileStream fs = new FileStream(this.resourcePath + "contactphoto.jpg", System.IO.FileMode.Open)) { cr.SetPhoto(e, fs); } // now delete the guy, which requires us to reload him from the server first, as the photo change operation // changes the etag off the entry e = cr.Retrieve(e); cr.Delete(e); }
public int EnumerateGoogleContacts() { int SynchedContacts = 0; rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> fc = cr.GetContacts(); foreach (Contact gContact in fc.Entries) { _Contacts.Add(gContact); if (GContactFeched != null) { GContactFeched (this,gContact); } } return SynchedContacts; }
public IEnumerable<ChannelContact> GetContacts() { var cred = CredentialsProvider.GetCredentials(); var rs = new RequestSettings("Tabdeelee-Inbox2-1", cred.Claim, cred.Evidence) { AutoPaging = true }; var cr = new ContactsRequest(rs); var feed = cr.GetContacts(); foreach (Contact entry in feed.Entries) { ChannelContact contact = new ChannelContact(); contact.Person.Name = entry.Title; contact.Profile.ChannelProfileKey = entry.Id; if (entry.Phonenumbers.Count > 0) { var phone = entry.Phonenumbers.First(); contact.Profile.PhoneNr = phone.Value; } if (entry.PrimaryEmail != null) contact.Profile.SourceAddress = new SourceAddress(entry.PrimaryEmail.Address, contact.Person.Name); try { // Check for 404 with custom httpclient on photourl since regular HttpWebClient keeps throwing exceptions //var token = cr.Service.QueryAuthenticationToken(); //var code = HttpStatusClient.GetStatusCode(entry.PhotoUri.ToString(), // new Dictionary<string, string> { { "Authorization", "GoogleLogin auth=" + token }}); //if (code.HasValue && code == 200) //{ IGDataRequest request = cr.Service.RequestFactory.CreateRequest(GDataRequestType.Query, entry.PhotoUri); request.Execute(); using (var avatarstream = request.GetResponseStream()) { if (avatarstream != null) { ChannelAvatar avatar = new ChannelAvatar(); // Copy avatarstream to a new memorystream because the source // stream does not support seek operations. MemoryStream ms = new MemoryStream(); avatarstream.CopyTo(ms); avatar.Url = entry.PhotoUri.ToString(); avatar.ContentStream = ms; contact.Profile.ChannelAvatar = avatar; } } //} } catch (CaptchaRequiredException) { // Since GMail will keep on raising CaptchaRequiredException, break out here // todo let the user know in some way or another? yield break; } catch (Exception) { } yield return contact; } }
public void OAuth2LeggedModelContactsBatchInsertTest() { const int numberOfInserts = 37; Tracing.TraceMsg("Entering OAuth2LeggedModelContactsBatchInsertTest"); RequestSettings rs = new RequestSettings(this.ApplicationName, this.oAuthConsumerKey, this.oAuthConsumerSecret, this.oAuthUser, this.oAuthDomain); ContactsTestSuite.DeleteAllContacts(rs); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); int originalCount = f.TotalResults; PhoneNumber p = null; List<Contact> inserted = new List<Contact>(); if (f != null) { Assert.IsTrue(f.Entries != null, "the contacts needs entries"); for (int i = 0; i < numberOfInserts; i++) { Contact entry = new Contact(); entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i); entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com"; p = entry.PrimaryPhonenumber; inserted.Add(cr.Insert(f, entry)); } } List<Contact> list = new List<Contact>(); f = cr.GetContacts(); foreach (Contact e in f.Entries) { list.Add(e); } if (inserted.Count > 0) { int iVer = numberOfInserts; // let's find those guys for (int i = 0; i < inserted.Count; i++) { Contact test = inserted[i]; foreach (Contact e in list) { if (e.Id == test.Id) { iVer--; // verify we got the phonenumber back.... Assert.IsTrue(e.PrimaryPhonenumber != null, "They should have a primary phonenumber"); Assert.AreEqual(e.PrimaryPhonenumber.Value, p.Value, "They should be identical"); } } } Assert.IsTrue(iVer == 0, "The new entries should all be part of the feed now, " + iVer + " left over"); } // now delete them again ContactsTestSuite.DeleteList(inserted, cr, new Uri(f.AtomFeed.Batch)); // now make sure they are gone if (inserted.Count > 0) { f = cr.GetContacts(); Assert.IsTrue(f.TotalResults == originalCount, "The count should be correct as well"); foreach (Contact e in f.Entries) { // let's find those guys, we should not find ANY for (int i = 0; i < inserted.Count; i++) { Contact test = inserted[i] as Contact; Assert.IsTrue(e.Id != test.Id, "The new entries should all be deleted now"); } } } }