예제 #1
0
        public void GenerateScores(int scoresCount, int siteId)
        {
            List <ScoreInfo> scores = new List <ScoreInfo>();

            for (int i = 0; i < scoresCount; i++)
            {
                ScoreInfo score = new ScoreInfo
                {
                    ScoreDisplayName      = "Score #" + i,
                    ScoreName             = "Score-" + Guid.NewGuid(),
                    ScoreBelongsToPersona = false,
                    ScoreEnabled          = true,
                    ScoreStatus           = 0,
                    ScoreSiteID           = siteId
                };
                score.Insert();
                scores.Add(score);
            }

            List <RuleInfo> rules = new List <RuleInfo>();

            foreach (var score in scores)
            {
                rules.AddRange(GenerateRules(score));
            }

            BulkInsertion.Insert(rules);
        }
    private static void GenerateScoringWithRulesAndMailNotification()
    {
        ScoreInfo score = new ScoreInfo
        {
            ScoreDisplayName = "Score with notification " + Guid.NewGuid(),
            ScoreName = "ScoreMailAndTrigger-" + Guid.NewGuid(),
            ScoreBelongsToPersona = false,
            ScoreEnabled = true,
            ScoreStatus = ScoreStatusEnum.RecalculationRequired,
            ScoreSiteID = SiteContext.CurrentSiteID,
            ScoreEmailAtScore = 50,
            ScoreNotificationEmail = "*****@*****.**"
        };
        score.Insert();

        GenerateBasicScoringRule(
            score,
            "Notification test: 10 points per ONE page visit, NOT recurring",
            10,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"pagevisit\"><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><value>XXXYYYZZZ</value><params><operator>1</operator></params></field><field name=\"ActivityTitle\"><params><operator>0</operator></params></field><field name=\"ActivityComment\"><params><operator>0</operator></params></field><field name=\"ActivityCampaign\"><params><operator>0</operator></params></field><field name=\"ActivityIPAddress\"><params><operator>0</operator></params></field><field name=\"ActivityURLReferrer\"><params><operator>0</operator></params></field><field name=\"PageVisitDetail\"><params><operator>0</operator></params></field><field name=\"PageVisitABVariantName\"><params><operator>0</operator></params></field><field name=\"PageVisitMVTCombinationName\"><params><operator>0</operator></params></field></activity><wherecondition>(ActivityType='pagevisit') AND (ISNULL([ActivityURL], '') NOT LIKE N'%XXXYYYZZZ%')</wherecondition></condition>",
            "pagevisit"
            );

        GenerateBasicScoringRule(
            score,
            "Notification test: 15 points for Home landing page",
            15,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"landingpage\"><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><value>Home</value><params><operator>0</operator></params></field><field name=\"ActivityTitle\"><params><operator>0</operator></params></field><field name=\"ActivityComment\"><params><operator>0</operator></params></field><field name=\"ActivityCampaign\"><params><operator>0</operator></params></field><field name=\"ActivityIPAddress\"><params><operator>0</operator></params></field><field name=\"ActivityURLReferrer\"><params><operator>0</operator></params></field><field name=\"PageVisitDetail\"><params><operator>0</operator></params></field><field name=\"PageVisitABVariantName\"><params><operator>0</operator></params></field><field name=\"PageVisitMVTCombinationName\"><params><operator>0</operator></params></field></activity><wherecondition>(ActivityType='landingpage') AND (ISNULL([ActivityURL], '') LIKE N'%Home%')</wherecondition></condition>",
            "landingpage"
            );

        GenerateBasicScoringRule(
            score,
            "Notification test: Contact has filled \"Contact us\" form for 30p",
            30,
            RuleTypeEnum.Macro,
            "<condition><macro><value>{%Rule(\"Contact.SubmittedForm(\\\"ContactUs\\\", ToInt(150))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" &gt;&lt;p n=\\\"_perfectum\\\"&gt;&lt;t&gt;has&lt;/t&gt;&lt;v&gt;&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;select operation&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"days\\\"&gt;&lt;t&gt;150&lt;/t&gt;&lt;v&gt;150&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;integer&lt;/vt&gt;&lt;tv&gt;1&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;&amp;lt;Contact Us&amp;gt;&lt;/t&gt;&lt;v&gt;ContactUs&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select form&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;/r&gt;&lt;/rules&gt;\")%}</value></macro></condition>"
            );
    }
    private static void GenerateScoringWithRules()
    {
        ScoreInfo score = new ScoreInfo
        {
            ScoreDisplayName = "Score " + Guid.NewGuid(),
            ScoreName = "Score-" + Guid.NewGuid(),
            ScoreBelongsToPersona = false,
            ScoreEnabled = true,
            ScoreStatus = ScoreStatusEnum.RecalculationRequired,
            ScoreSiteID = SiteContext.CurrentSiteID
        };
        score.Insert();

        GenerateBasicScoringRule(
            score,
            "Has got e-mail address filled attribute rule",
            10,
            RuleTypeEnum.Attribute,
            "<condition><attribute name=\"ContactEmail\"><value>@</value><params><Operator>0</Operator></params></attribute><wherecondition>ISNULL([ContactEmail], '') LIKE N'%@%'</wherecondition></condition>",
            "ContactEmail"
            );

        GenerateBasicScoringRule(
            score,
            "Has got e-mail address filled macro rule",
            10,
            RuleTypeEnum.Macro,
            "<condition><macro><value>{%Rule(\"Contact.ContactEmail.Contains(\\\"@\\\")\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactFieldContainsValue\\\" &gt;&lt;p n=\\\"field\\\"&gt;&lt;t&gt;E-mail address&lt;/t&gt;&lt;v&gt;ContactEmail&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select field&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"op\\\"&gt;&lt;t&gt;contains&lt;/t&gt;&lt;v&gt;Contains&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;select operator&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"value\\\"&gt;&lt;t&gt;@&lt;/t&gt;&lt;v&gt;@&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter value&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;1&lt;/tv&gt;&lt;/p&gt;&lt;/r&gt;&lt;/rules&gt;\")%}</value></macro></condition>"
            );

        GenerateBasicScoringRule(
            score,
            "Contact has filled \"Contact us\" form for 10p",
            10,
            RuleTypeEnum.Macro,
            "<condition><macro><value>{%Rule(\"Contact.SubmittedForm(\\\"ContactUs\\\", ToInt(150))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" &gt;&lt;p n=\\\"_perfectum\\\"&gt;&lt;t&gt;has&lt;/t&gt;&lt;v&gt;&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;select operation&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"days\\\"&gt;&lt;t&gt;150&lt;/t&gt;&lt;v&gt;150&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;integer&lt;/vt&gt;&lt;tv&gt;1&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;&amp;lt;Contact Us&amp;gt;&lt;/t&gt;&lt;v&gt;ContactUs&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select form&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;/r&gt;&lt;/rules&gt;\")%}</value></macro></condition>"
            );

        GenerateBasicScoringRule(
            score,
            "10 points per ONE page visit, NOT recurring",
            10,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"pagevisit\"><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><value>XXXYYYZZZ</value><params><operator>1</operator></params></field><field name=\"ActivityTitle\"><params><operator>0</operator></params></field><field name=\"ActivityComment\"><params><operator>0</operator></params></field><field name=\"ActivityCampaign\"><params><operator>0</operator></params></field><field name=\"ActivityIPAddress\"><params><operator>0</operator></params></field><field name=\"ActivityURLReferrer\"><params><operator>0</operator></params></field><field name=\"PageVisitDetail\"><params><operator>0</operator></params></field><field name=\"PageVisitABVariantName\"><params><operator>0</operator></params></field><field name=\"PageVisitMVTCombinationName\"><params><operator>0</operator></params></field></activity><wherecondition>(ActivityType='pagevisit') AND (ISNULL([ActivityURL], '') NOT LIKE N'%XXXYYYZZZ%')</wherecondition></condition>",
            "pagevisit"
            );

        var pageVisitRule = GenerateBasicScoringRule(
            score,
            "10 points per every page visit, recurring, max 35 total points",
            10,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"pagevisit\"><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><value>XXXYYYZZZ</value><params><operator>1</operator></params></field><field name=\"ActivityTitle\"><params><operator>0</operator></params></field><field name=\"ActivityComment\"><params><operator>0</operator></params></field><field name=\"ActivityCampaign\"><params><operator>0</operator></params></field><field name=\"ActivityIPAddress\"><params><operator>0</operator></params></field><field name=\"ActivityURLReferrer\"><params><operator>0</operator></params></field><field name=\"PageVisitDetail\"><params><operator>0</operator></params></field><field name=\"PageVisitABVariantName\"><params><operator>0</operator></params></field><field name=\"PageVisitMVTCombinationName\"><params><operator>0</operator></params></field></activity><wherecondition>(ActivityType='pagevisit') AND (ISNULL([ActivityURL], '') NOT LIKE N'%XXXYYYZZZ%')</wherecondition></condition>",
            "pagevisit"
            );
        pageVisitRule.RuleMaxPoints = 35;
        pageVisitRule.RuleIsRecurring = true;
        pageVisitRule.Update();

        var pageVisitRuleWithValidity = GenerateBasicScoringRule(
            score,
            "10 points per ONE page visit, NOT recurring, 5 days validity",
            10,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"pagevisit\"><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><value>XXXYYYZZZ</value><params><operator>1</operator></params></field><field name=\"ActivityTitle\"><params><operator>0</operator></params></field><field name=\"ActivityComment\"><params><operator>0</operator></params></field><field name=\"ActivityCampaign\"><params><operator>0</operator></params></field><field name=\"ActivityIPAddress\"><params><operator>0</operator></params></field><field name=\"ActivityURLReferrer\"><params><operator>0</operator></params></field><field name=\"PageVisitDetail\"><params><operator>0</operator></params></field><field name=\"PageVisitABVariantName\"><params><operator>0</operator></params></field><field name=\"PageVisitMVTCombinationName\"><params><operator>0</operator></params></field></activity><wherecondition>(ActivityType='pagevisit') AND (ISNULL([ActivityURL], '') NOT LIKE N'%XXXYYYZZZ%')</wherecondition></condition>",
            "pagevisit"
            );
        pageVisitRuleWithValidity.RuleValidFor = 5;
        pageVisitRuleWithValidity.RuleValidity = ValidityEnum.Days;
        pageVisitRuleWithValidity.Update();
    }
        public void GenerateScores(int scoresCount, int siteId)
        {
            List<ScoreInfo> scores = new List<ScoreInfo>();

            for (int i = 0; i < scoresCount; i++)
            {
                ScoreInfo score = new ScoreInfo
                {
                    ScoreDisplayName = "Score #" + i,
                    ScoreName = "Score-" + Guid.NewGuid(),
                    ScoreBelongsToPersona = false,
                    ScoreEnabled = true,
                    ScoreStatus = ScoreStatusEnum.RecalculationRequired,
                    ScoreSiteID = siteId
                };
                score.Insert();
                scores.Add(score);
            }

            List<RuleInfo> rules = new List<RuleInfo>();

            foreach (var score in scores)
            {
                rules.AddRange(GenerateRules(score));
            }

            BulkInsertion.Insert(rules);
        }