public GetMoreResults ( ) : FuelSDK.GetReturn | ||
Результат | FuelSDK.GetReturn |
// ------------------------------------------------------------ // Name: UpdateConvertedProspects // Abstract: Retrieve subscribers from a list // ------------------------------------------------------------ public static Dictionary<string, string> GetDuplicateSubscribers() { Dictionary<string, string> dctDuplicateSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctAllSubscribers = new Dictionary<string, string>(); try { string strCustomerNumber = ""; string strSubscriberKey = ""; string strEmail = ""; // Get subscriber dates ET_Subscriber getSub = new ET_Subscriber(); getSub.AuthStub = m_etcTDClient; getSub.Props = new string[] { "SubscriberKey", "EmailAddress" }; GetReturn getResponse = getSub.Get(); Console.WriteLine("Get Status: " + getResponse.Status.ToString()); Console.WriteLine("Message: " + getResponse.Message.ToString()); Console.WriteLine("Code: " + getResponse.Code.ToString()); Console.WriteLine("Results Length: " + getResponse.Results.Length); while (getResponse.MoreResults == true) { foreach (ET_Subscriber sub in getResponse.Results) { Console.WriteLine("SubscriberKey: " + sub.SubscriberKey); // Add to our list dctAllSubscribers.Add(sub.SubscriberKey, sub.EmailAddress); } getResponse = getSub.GetMoreResults(); } foreach (KeyValuePair<string, string> entry in dctAllSubscribers) { strSubscriberKey = entry.Key; strEmail = entry.Value; // Add to duplicates if email already exists if (dctSubscribers.ContainsValue(strEmail) == true) { // Get customer number from duplicate if duplicate hasn't been logged if (dctDuplicateSubscribers.ContainsValue(strEmail) == false) { strCustomerNumber = dctSubscribers.FirstOrDefault(x => x.Value == strEmail).Key; // Add (both) duplicate entries dctDuplicateSubscribers.Add(strSubscriberKey, strEmail); dctDuplicateSubscribers.Add(strCustomerNumber, strEmail); } else { dctDuplicateSubscribers.Add(strSubscriberKey, strEmail); } } else { // Add to our list dctSubscribers.Add(strSubscriberKey, strEmail); } } } catch (Exception excError) { // Display Error Console.WriteLine("Error: " + excError.ToString()); } return dctDuplicateSubscribers; }
// ------------------------------------------------------------ // Name: UpdateConvertedProspects // Abstract: Retrieve subscribers from a list // ------------------------------------------------------------ public static void SetVerifiedEmailStatus() { Dictionary<string, string> dctAllSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctDataExtensionSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctNewsletterListSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctDENewsletterSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctRemindersListSubscribers = new Dictionary<string, string>(); Dictionary<string, string> dctDERemindersSubscribers = new Dictionary<string, string>(); List<string> alstrValidSubscriberKeys = new List<string>(); try { string strSubscriberKey = ""; string strEmail = ""; string strCustomerNumber = ""; string strStatus = ""; string strDEStatus = ""; int intUpdateRecordCount = 0; // Data DateTime dtmCreatedDate = DateTime.Now; // Get subscriber dates ET_Subscriber getSub = new ET_Subscriber(); getSub.AuthStub = m_etcTDClientShared; getSub.Props = new string[] { "SubscriberKey", "EmailAddress", "Status", "CreatedDate" }; GetReturn getResponse = getSub.Get(); Console.WriteLine("Get Status: " + getResponse.Status.ToString()); Console.WriteLine("Message: " + getResponse.Message.ToString()); Console.WriteLine("Code: " + getResponse.Code.ToString()); Console.WriteLine("Results Length: " + getResponse.Results.Length); int intResults = getResponse.Results.Length; // Get all subscriber keys associated with active subscribers while (getResponse.MoreResults == true || intResults > 0) { foreach (ET_Subscriber sub in getResponse.Results) { strStatus = sub.Status.ToString(); dctAllSubscribers.Add(sub.SubscriberKey, strStatus); Console.WriteLine("Added EmailAddress: " + sub.EmailAddress + " Status: " + strStatus); } getResponse = getSub.GetMoreResults(); intResults = getResponse.Results.Length; } // Get all customers and their 'VerifiedEmail' field from CustomerBaseDatabase Console.WriteLine("\n Retrieve All Rows from DataExtension"); ET_DataExtensionRow deRowGet = new ET_DataExtensionRow(); deRowGet.AuthStub = m_etcTDClientShared; deRowGet.DataExtensionName = "CustomerDatabase"; deRowGet.Props = new string[] { "SubscriberKey", "VerifiedEmail" }; GetReturn grRow = deRowGet.Get(); Console.WriteLine("Get Status: " + grRow.Status.ToString()); Console.WriteLine("Message: " + grRow.Message.ToString()); Console.WriteLine("Code: " + grRow.Code.ToString()); Console.WriteLine("Results Length: " + grRow.Results.Length); intResults = grRow.Results.Length; string x; while (grRow.MoreResults == true || intResults > 0) { foreach (ET_DataExtensionRow column in grRow.Results) { strSubscriberKey = column.ColumnValues["SubscriberKey"]; strStatus = column.ColumnValues["VerifiedEmail"]; if (dctAllSubscribers.TryGetValue(strSubscriberKey, out x) == true) { dctDataExtensionSubscribers.Add(strSubscriberKey, strStatus); Console.WriteLine("Added customer: " + strSubscriberKey); } } grRow = deRowGet.GetMoreResults(); intResults = grRow.Results.Length; } // Update statuses ET_DataExtensionRow deRowPatch = null; foreach (KeyValuePair<string, string> entry in dctDataExtensionSubscribers) { strSubscriberKey = entry.Key; strDEStatus = entry.Value; // if our status = active, set to true strStatus = dctAllSubscribers[strSubscriberKey]; if (strStatus.Equals("Active") == true) { strStatus = "True"; } else { strStatus = "False"; } // Is the status of our subscriber the same on the All Subscribers list as it is on the Data Extension? if (strDEStatus.Equals(strStatus) == false) { intUpdateRecordCount += 1; // No, update the verified email field deRowPatch = new ET_DataExtensionRow(); deRowPatch.AuthStub = m_etcTDClientShared; deRowPatch.DataExtensionCustomerKey = "CustomerDBKey"; deRowPatch.ColumnValues.Add("SubscriberKey", strSubscriberKey); deRowPatch.ColumnValues.Add("VerifiedEmail", strStatus); PatchReturn patchRowResponse = deRowPatch.Patch(); Console.WriteLine("Post Status: " + patchRowResponse.Status.ToString()); Console.WriteLine("Count: " + intUpdateRecordCount.ToString()); } } Console.WriteLine("Done editing email statuses!"); } catch (Exception excError) { // Display Error Console.WriteLine("Error: " + excError.ToString()); } }
// ------------------------------------------------------------ // Name: GetSubscriberEmails // Abstract: Get subscriber keys and emails // ------------------------------------------------------------ public static Dictionary<string, string> GetSubscriberEmails() { Dictionary<string, string> dctAllSubscribers = new Dictionary<string, string>(); try { ET_Subscriber getSub = new ET_Subscriber(); getSub.AuthStub = m_etcTDClientShared; getSub.Props = new string[] { "SubscriberKey", "EmailAddress" }; GetReturn getResponse = getSub.Get(); Console.WriteLine("Get Status: " + getResponse.Status.ToString()); Console.WriteLine("Message: " + getResponse.Message.ToString()); Console.WriteLine("Code: " + getResponse.Code.ToString()); Console.WriteLine("Results Length: " + getResponse.Results.Length); int intResults = getResponse.Results.Length; // Get all subscriber keys associated with active subscribers while (getResponse.MoreResults == true || intResults > 0) { foreach (ET_Subscriber sub in getResponse.Results) { dctAllSubscribers.Add(sub.SubscriberKey, sub.EmailAddress); } getResponse = getSub.GetMoreResults(); intResults = getResponse.Results.Length; } } catch (Exception excError) { // Display Error Console.WriteLine("Error: " + excError.ToString()); } return dctAllSubscribers; }