/// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param>
    /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo sb, int subscriberId, int newsletterId, int issueId, int contactId)
    {
        bool isFromContactGroup = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);

        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(sb);
        }

        if (sb == null)
        {
            sb = SubscriberInfoProvider.GetSubscriberInfo(subscriberId);
        }

        if (contactId > 0)
        {
            NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);

            Activity activity = new ActivityNewsletterUnsubscribing(sb, news, CMSContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID    = contactId;
                activity.Data.ItemDetailID = issueId;
                activity.Data.Value        = isFromContactGroup ? "contactgroup(" + sb.SubscriberRelatedID + ")" : null;
                activity.Log();
            }
        }
    }
    /// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="subscriber">Subscriber</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo subscriber, int newsletterId, int issueId, int contactId)
    {
        if (subscriber == null)
        {
            throw new ArgumentNullException("subscriber");
        }
        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(subscriber);
        }

        if (contactId > 0)
        {
            NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
            bool           isFromContactGroup = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);
            bool           isFromPersona      = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.PERSONA, true);
            Activity       activity           = new ActivityNewsletterUnsubscribing(subscriber, news, AnalyticsContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID    = contactId;
                activity.Data.ItemDetailID = issueId;
                if (isFromContactGroup)
                {
                    activity.Data.Value = "contactgroup(" + subscriber.SubscriberRelatedID + ")";
                }
                else if (isFromPersona)
                {
                    activity.Data.Value = "persona(" + subscriber.SubscriberRelatedID + ")";
                }
                activity.Log();
            }
        }
    }
Example #3
0
    /// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param>
    /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="siteId">Site ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="issueGuid">Issue GUID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo sb, int subscriberId, int newsletterId, int siteId, int issueId, Guid issueGuid, int contactId)
    {
        // Load subscriber info object according to its ID if not given
        if (sb == null)
        {
            sb = SubscriberInfoProvider.GetSubscriberInfo(subscriberId);
        }

        NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
        bool           isFromContactGroup = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);
        bool           isFromPersona      = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.PERSONA, true);

        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(sb);
        }

        if (contactId > 0)
        {
            // Load additional info (issue id)
            if ((issueId <= 0) && (issueGuid != Guid.Empty))
            {
                IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueGuid, siteId);
                if (issue != null)
                {
                    issueId = issue.IssueID;
                }
            }

            Activity activity = new ActivityNewsletterUnsubscribing(sb, news, AnalyticsContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID    = contactId;
                activity.Data.ItemDetailID = issueId;
                activity.Data.Value        = isFromContactGroup
                    ? "contactgroup(" + sb.SubscriberRelatedID + ")"
                    : isFromPersona
                        ? "persona(" + sb.SubscriberRelatedID + ")"
                        : null;
                activity.Log();
            }
        }
    }
    /// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param>
    /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="siteId">Site ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="issueGuid">Issue GUID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo sb, int subscriberId, int newsletterId, int siteId, int issueId, Guid issueGuid, int contactId)
    {
        // Load subscriber info object according to its ID if not given
        if (sb == null)
        {
            sb = SubscriberInfoProvider.GetSubscriberInfo(subscriberId);
        }

        NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
        bool isFromContactGroup = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);
        bool isFromPersona = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.PERSONA, true);
        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(sb);
        }

        if (contactId > 0)
        {
            // Load additional info (issue id)
            if ((issueId <= 0) && (issueGuid != Guid.Empty))
            {
                IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueGuid, siteId);
                if (issue != null)
                {
                    issueId = issue.IssueID;
                }
            }

            Activity activity = new ActivityNewsletterUnsubscribing(sb, news, AnalyticsContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID = contactId;
                activity.Data.ItemDetailID = issueId;
                activity.Data.Value = isFromContactGroup
                    ? "contactgroup(" + sb.SubscriberRelatedID + ")"
                    : isFromPersona
                        ? "persona(" + sb.SubscriberRelatedID + ")"
                        : null;
                activity.Log();
            }
        }
    }
    /// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="subscriber">Subscriber</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo subscriber, int newsletterId, int issueId, int contactId)
    {
        if (subscriber == null)
        {
            throw new ArgumentNullException("subscriber");
        }
        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(subscriber);
        }

        if (contactId > 0)
        {
            NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
            bool isFromContactGroup = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);
            bool isFromPersona = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.PERSONA, true);
            Activity activity = new ActivityNewsletterUnsubscribing(subscriber, news, AnalyticsContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID = contactId;
                activity.Data.ItemDetailID = issueId;
                if (isFromContactGroup)
                {
                    activity.Data.Value = "contactgroup(" + subscriber.SubscriberRelatedID + ")";
                }
                else if (isFromPersona)
                {
                    activity.Data.Value = "persona(" + subscriber.SubscriberRelatedID + ")";
                }
                activity.Log();
            }
        }
    }
    /// <summary>
    /// Logs activity for unsubscribing.
    /// </summary>
    /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param>
    /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param>
    /// <param name="newsletterId">Newsletter ID</param>
    /// <param name="issueId">Issue ID</param>
    /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param>
    private void LogActivity(SubscriberInfo sb, int subscriberId, int newsletterId, int issueId, int contactId)
    {
        bool isFromContactGroup = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true);
        if (contactId <= 0)
        {
            contactId = ActivityTrackingHelper.GetContactID(sb);
        }

        if (sb == null)
        {
            sb = SubscriberInfoProvider.GetSubscriberInfo(subscriberId);
        }

        if (contactId > 0)
        {
            NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);

            Activity activity = new ActivityNewsletterUnsubscribing(sb, news, CMSContext.ActivityEnvironmentVariables);
            if (activity.Data != null)
            {
                activity.Data.ContactID = contactId;
                activity.Data.ItemDetailID = issueId;
                activity.Data.Value = isFromContactGroup ? "contactgroup(" + sb.SubscriberRelatedID + ")" : null;
                activity.Log();
            }
        }
    }