コード例 #1
0
    /// <summary>
    /// Returns all e-mail addresses for specified newsletter.
    /// </summary>
    /// <param name="newsletterId">Newsletter</param>
    /// <param name="siteId">Site</param>
    private int GetEmailAddressCount(int newsletterId, int siteId)
    {
        // Get e-mail addresses for ordinary subscriber, user subriber and role subscriber
        string siteName       = SiteInfoProvider.GetSiteName(siteId);
        int    emailAddresses = NewsletterInfoProvider.GetEmailAddressCount(newsletterId, siteName);

        DataSet ContactID = SubscriberNewsletterInfoProvider.GetSubscriptions(
            String.Format("NewsletterID={0} AND (SubscriptionApproved=1 OR SubscriptionApproved IS NULL) AND (SubscriptionEnabled=1 OR SubscriptionEnabled IS NULL) AND SubscriberType='om.contactgroup'", newsletterId), null, 0, "DISTINCT(SubscriberRelatedID) AS SubscriberRelatedID");

        if (!DataHelper.DataSourceIsEmpty(ContactID))
        {
            int groupId = 0;
            foreach (DataRow dr in ContactID.Tables[0].Rows)
            {
                groupId = ValidationHelper.GetInteger(dr[0], 0);

                DataSet dsMembers = ModuleCommands.OnlineMarketingGetContactGroupMemberIDs(groupId, 0, 0,
                                                                                           NewsletterHelper.MonitorBouncedEmails(siteName),
                                                                                           NewsletterHelper.BouncedEmailsLimit(siteName), newsletterId);
                if (!DataHelper.DataSourceIsEmpty(dsMembers))
                {
                    emailAddresses += ValidationHelper.GetInteger(dsMembers.Tables[0].Rows.Count, 0);
                }
            }
        }

        return(emailAddresses);
    }