コード例 #1
0
    /// <summary>
    /// Test if campaign is valid.
    /// </summary>
    public override bool IsValid()
    {
        String value = ValidationHelper.GetString(usCampaign.Value, String.Empty).Trim();

        if (value != String.Empty && value != UniSelector.US_NONE_RECORD.ToString())
        {
            String domain = RequestContext.CurrentDomain;
            if (DataHelper.GetNotEmpty(domain, "") != "")
            {
                string parsedDomain = LicenseKeyInfoProvider.ParseDomainName(domain);
                if (!LicenseKeyInfoProvider.IsFeatureAvailable(parsedDomain, FeatureEnum.CampaignAndConversions))
                {
                    ValidationError = GetString("campaignselector.nolicence");
                    return(false);
                }
            }

            if (!ValidationHelper.IsCodeName(value))
            {
                ValidationError = GetString("campaign.validcodename");
                return(false);
            }

            // If campaign object not found
            CampaignInfo ci = CampaignInfoProvider.GetCampaignInfo(value, SiteInfoProvider.GetSiteName(SiteID));

            // Handle info not found
            if (ci == null)
            {
                if (!CreateOnUnknownName)
                {
                    // Selector is not set to create new campaigns so error out
                    ValidationError = GetString("campaign.validcodename");
                    return(false);
                }

                // Or check permissions ..
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageCampaigns"))
                {
                    ValidationError = GetString("campaign.notallowedcreate");
                    return(false);
                }

                // .. and try to create a new one.
                ci = new CampaignInfo();
                ci.CampaignName        = value;
                ci.CampaignUTMCode     = value;
                ci.CampaignDisplayName = value;
                ci.CampaignEnabled     = true;
                ci.CampaignSiteID      = SiteID;

                CampaignInfoProvider.SetCampaignInfo(ci);
            }
        }

        return(true);
    }
コード例 #2
0
        /// <summary>
        /// Generates campaign.
        /// </summary>
        /// <param name="campaignData">Campaign data for generating.</param>
        private void GenerateCampaign(CampaignData campaignData)
        {
            var siteName = mSite.SiteName;
            var campaign = CampaignInfoProvider.GetCampaignInfo(campaignData.CampaignName, siteName);

            if (campaign != null)
            {
                return;
            }

            campaign = new CampaignInfo
            {
                CampaignName         = campaignData.CampaignName,
                CampaignDisplayName  = campaignData.CampaignDisplayName,
                CampaignDescription  = campaignData.CampaignDescription,
                CampaignOpenFrom     = campaignData.CampaignOpenFrom,
                CampaignCalculatedTo = campaignData.CampaignOpenFrom,
                CampaignOpenTo       = campaignData.CampaignOpenTo,
                CampaignSiteID       = mSite.SiteID,
                CampaignUTMCode      = campaignData.CampaignUTMCode
            };

            CampaignInfoProvider.SetCampaignInfo(campaign);

            /* Add email to campaign promotion section  */
            CampaignDataGeneratorHelpers.AddNewsletterAsset(campaign, campaignData.CampaignEmailPromotion);
            var issue = ProviderHelper.GetInfoByGuid(PredefinedObjectType.NEWSLETTERISSUE, campaignData.CampaignEmailPromotion, campaign.CampaignSiteID);

            if (issue != null)
            {
                issue.SetValue("IssueStatus", 5);
                issue.SetValue("IssueMailoutTime", campaignData.CampaignOpenFrom);

                issue.Update();
            }

            /* Add page assets to campaign content inventory section */
            foreach (var assetUrlGuid in campaignData.CampaignContentInventory)
            {
                CampaignDataGeneratorHelpers.AddPageAsset(campaign.CampaignID, assetUrlGuid);
            }

            /* Add conversions to campaign report setup section */
            foreach (var conversion in campaignData.CampaignReportSetup)
            {
                CampaignDataGeneratorHelpers.CreateConversion(campaign.CampaignID, conversion);
            }
        }
コード例 #3
0
        private void GenerateCampaign(CampaignData campaignData)
        {
            var siteName = _mSite.SiteName;

            if (CampaignInfoProvider.GetCampaignInfo(campaignData.CampaignName, siteName) != null)
            {
                return;
            }

            var campaignInfo = new CampaignInfo
            {
                CampaignName         = campaignData.CampaignName,
                CampaignDisplayName  = campaignData.CampaignDisplayName,
                CampaignDescription  = campaignData.CampaignDescription,
                CampaignOpenFrom     = campaignData.CampaignOpenFrom,
                CampaignCalculatedTo = campaignData.CampaignOpenFrom,
                CampaignOpenTo       = campaignData.CampaignOpenTo,
                CampaignSiteID       = _mSite.SiteID,
                CampaignUTMCode      = campaignData.CampaignUtmCode
            };

            CampaignInfoProvider.SetCampaignInfo(campaignInfo);
            CampaignDataGeneratorHelpers.AddNewsletterAsset(campaignInfo, campaignData.CampaignEmailPromotion);
            var infoByGuid = ProviderHelper.GetInfoByGuid("newsletter.issue", campaignData.CampaignEmailPromotion,
                                                          campaignInfo.CampaignSiteID);

            if (infoByGuid != null)
            {
                infoByGuid.SetValue("IssueStatus", 5);
                infoByGuid.SetValue("IssueMailoutTime", campaignData.CampaignOpenFrom);
                infoByGuid.Update();
            }

            foreach (var pagePath in campaignData.CampaignContentInventory)
            {
                CampaignDataGeneratorHelpers.AddPageAsset(campaignInfo.CampaignID, pagePath);
            }

            foreach (var conversionData in campaignData.CampaignReportSetup)
            {
                CampaignDataGeneratorHelpers.CreateConversion(campaignInfo.CampaignID, conversionData);
            }
        }
コード例 #4
0
    protected void ConversionsSelection_changed(object sender, EventArgs ea)
    {
        // Check "modify" permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageCampaigns"))
        {
            RedirectToAccessDenied("CMS.WebAnalytics", "Manage campaigns");
        }

        if (ci != null)
        {
            ci.CampaignUseAllConversions = rbAllConversions.Checked;
            if (ci.CampaignUseAllConversions)
            {
                CampaignInfoProvider.RemoveAllConversionsFromCampaign(campaignID);
            }

            CampaignInfoProvider.SetCampaignInfo(ci);

            ShowChangesSaved();
        }
    }