次の方法で共有


How to Purge Old Marketing Data

Periodically, you may have to remove expired marketing data from your installation.

Marketing data is marked as archived instead of being physically removed when it is deleted by using the marketing management API. This enables a database administrator to recover accidentally deleted data.

Database administrators can periodically purge the old data from the marketing database using the DataManager object.

To Purge Old Marketing Data

  1. Define the number of days of data that you want to delete.

  2. Connect a DataManager object to the Marketing databases.

  3. Purge Promotion Code data that was created before the specified number of days before today.

  4. Purge Campaign item data that was created before the specified number of days before today.

  5. Purge Campaign data that was created before the specified number of days before today.

  6. Purge Customer data that was created before the specified number of days before today.

Example

You can view the results in the Marketing Manager.

using Microsoft.CommerceServer;
using Microsoft.CommerceServer.Marketing;

namespace CommerceServerMarketingExamples
{
    public class CSMarketingExamples
    {
        public void PurgeMarketingData()
        {
            try
            {
                // Purge 60 days of Promotion Code data.
                int ageOutDays = 60;
                // Purge 90 days of Campaign, Campaign Item, and Customer data.
                int daysSinceDeletion = 90;
                DataManager manager = new DataManager("Data Source=(local);Initial Catalog=StarterSite_marketing;Integrated Security=SSPI", "Data Source=(local);Initial Catalog=StarterSite_marketing_lists;Integrated Security=SSPI");
                manager.PurgeOldPromoCodes(ageOutDays, PromoCodePurgeOption.CodesForExpiredDiscountsAndDeletedDiscounts);
                manager.PurgeDeletedCampaignItems(daysSinceDeletion);
                manager.PurgeDeletedCampaigns(daysSinceDeletion);
                manager.PurgeDeletedCustomers(daysSinceDeletion);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}\r\nMessage: {1} " + ex.GetType() + " " + ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine("\r\nInner Exception: {0}\r\nMessage: {1}" + ex.InnerException.GetType() + ex.InnerException.Message);
                Console.WriteLine("\n");
            }
     }
}

See Also

Other Resources

Marketing Data Management Scenarios