Hello,
We have a requirement to retrieve the collection of contacts whose condition is based on lastupdatedate. We basically have to sync our database for the subscribed and unsubscribed users. For that i found information from your site link given below
http://developer.constantcontact.com/doc/manageContacts#update_contact_info
Based on this I searched on the Utitliy class and I didn't see any equivalent method. So I added a new method based on the information provided in the above link. Below i have attached the piece of code.
public static List<Contact> SearchContactByUpdatedDate(AuthenticationData authenticationData, string currentChunkId, out string nextChunkId)
{
//IList<Contact> list = Utility.SearchContactByEmail(AuthenticationData, emailAddress, out nextChunkId);
//IList<ContactList> list = Utility.GetUserContactListCollection(AuthenticationData, out nextChunkId);
//int count = list.Count;
ValidateAuthenticationData(authenticationData);
StringBuilder uriAddress = new StringBuilder();
uriAddress.Append(authenticationData.AccountContactsUri);
uriAddress.Append("?");
uriAddress.AppendFormat("updatedsince={0}&listtype={1}", HttpUtility.UrlEncode("2010-02-09T01:00:00.000Z"),HttpUtility.UrlEncode("active"));
string currentAddress = String.Format(CultureInfo.InvariantCulture, "{0}{1}",
uriAddress, currentChunkId);
Stream stream = Stream.Null;
try
{
// get the response stream
stream = GetResponseStream(new Uri(currentAddress), authenticationData);
// parse the stream and get a collection of Contacts
return ContactComponent.GetContactCollection(stream, out nextChunkId);
}
catch (Exception e)
{
throw new ConstantException(e.Message, e);
}
finally
{
// close the response stream
stream.Close();
}
}
#endregion
For me everything is fine but I am not able to navigate after 50 records. Basically my call from my service will hit every 50 and keep adding to my local collection and once it collects the entire data then it will be send as a whole object in my local application. Also providing that sample below. The issue here I am not able to navigate to next set of 50 records and so...
string currentChunkId = String.Empty;
string nextChunkId;
string CurrentChunk;
string NextChunk;
long ChunkIndex;
CurrentChunk = null;
NextChunk = null;
ChunkIndex = 1;
IList<Contact> list;
do
{
//list = Utility.SearchContactByUpdatedDate(AuthenticationData, "", out nextChunkId);
string nextChunk;
list = string.IsNullOrEmpty(CurrentChunk)
? Utility.SearchContactByUpdatedDate(AuthenticationData, null, out nextChunk)
: Utility.SearchContactByUpdatedDate(AuthenticationData, CurrentChunk, out nextChunk);
int count = list.Count;
/// logic that will add the list to the main list.
NextChunk = nextChunk;
CurrentChunk = NextChunk;
NextChunk = null;
ChunkIndex += 50;
} while (list.Count > 0);
Could you pleaes let me know how to achive this functionality? Or do you have any methods where i can access this. Also need from where i can grab the latest new dll's. Please provide me the location for the same.
Regards,
Elango
... View more