private void GenerateRealFemalePersona(int siteId)
        {
            PersonalDataStructure personalData = new RealPersonalDataGenerator().GeneratePersonalData(UserGenderEnum.Female);

            PersonaInfo persona = new PersonaInfo
            {
                PersonaDisplayName     = personalData.FirstName + " " + personalData.LastName + " (female)",
                PersonaName            = "Persona-" + Guid.NewGuid(),
                PersonaSiteID          = siteId,
                PersonaPointsThreshold = 100,
                PersonaEnabled         = true
            };

            persona.Insert();

            var rule = new RuleInfo
            {
                RuleScoreID     = persona.PersonaScoreID,
                RuleDisplayName = "Is female",
                RuleName        = "Rule-" + Guid.NewGuid(),
                RuleValue       = 1000,
                RuleType        = RuleTypeEnum.Attribute,
                RuleParameter   = "ContactGender",
                RuleCondition   = "<condition><attribute name=\"ContactGender\"><value>2</value></attribute><wherecondition>ContactGender = 2</wherecondition></condition>",
                RuleSiteID      = siteId
            };

            rule.Insert();
        }
        private void GenerateDisabledPersona(int siteId)
        {
            var realPerson = new RealPersonalDataGenerator().GeneratePersonalData();

            PersonaInfo persona = new PersonaInfo
            {
                PersonaDisplayName     = realPerson.FirstName + " " + realPerson.LastName + " (disabled)",
                PersonaName            = "Persona-" + Guid.NewGuid(),
                PersonaSiteID          = siteId,
                PersonaPointsThreshold = 100,
                PersonaEnabled         = false
            };

            persona.Insert();
        }
        private void GenerateRealMalePersona(int siteId)
        {
            PersonalDataStructure personalData = new RealPersonalDataGenerator().GeneratePersonalData(UserGenderEnum.Male);

            PersonaInfo persona = new PersonaInfo
            {
                PersonaDisplayName = personalData.FirstName + " " + personalData.LastName + " (male)",
                PersonaName = "Persona-" + Guid.NewGuid(),
                PersonaSiteID = siteId,
                PersonaPointsThreshold = 100,
                PersonaEnabled = true
            };
            persona.Insert();

            var rule = new RuleInfo
            {
                RuleScoreID = persona.PersonaScoreID,
                RuleDisplayName = "Is male",
                RuleName = "Rule-" + Guid.NewGuid(),
                RuleValue = 1000,
                RuleType = RuleTypeEnum.Attribute,
                RuleParameter = "ContactGender",
                RuleCondition = "<condition><attribute name=\"ContactGender\"><value>1</value></attribute><wherecondition>ContactGender = 1</wherecondition></condition>",
                RuleSiteID = siteId
            };
            rule.Insert();
        }
        private void GenerateDisabledPersona(int siteId)
        {
            var realPerson = new RealPersonalDataGenerator().GeneratePersonalData();

            PersonaInfo persona = new PersonaInfo
            {
                PersonaDisplayName = realPerson.FirstName + " " + realPerson.LastName + " (disabled)",
                PersonaName = "Persona-" + Guid.NewGuid(),
                PersonaSiteID = siteId,
                PersonaPointsThreshold = 100,
                PersonaEnabled = false
            };
            persona.Insert();
        }
    private static void GenerateVisitorAndContentRaterPersona()
    {
        var persona = new PersonaInfo
        {
            PersonaDisplayName = "Page visitor and Content rater",
            PersonaName = "Persona-" + Guid.NewGuid(),
            PersonaSiteID = SiteContext.CurrentSiteID,
            PersonaPointsThreshold = 75,
            PersonaEnabled = true
        };
        persona.Insert();

        GenerateBasicRule(
            persona,
            "100 points for content rating activity",
            100,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"rating\"><field name=\"ActivityValue\"><value>0</value><params><operator>11</operator></params></field><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><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></activity><wherecondition>(ActivityType='rating') AND (CASE ISNUMERIC([ActivityValue]) WHEN 1 THEN CAST([ActivityValue] AS FLOAT) ELSE NULL END &gt; CAST(0 AS FLOAT))</wherecondition></condition>",
            "rating"
            );

        GenerateBasicRule(
            persona,
            "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"
            );

        GenerateBasicRule(
            persona,
            "Always satisfied macro rule for 30 points",
            30,
            RuleTypeEnum.Macro,
            "<condition><macro><value>{%Rule(\"Contact.ContactLastName.Contains(\\\"Anonym\\\") || Contact.ContactLastName.NotContains(\\\"Anonym\\\")\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"or\\\" n=\\\"CMSContactFieldContainsValue\\\" &gt;&lt;p n=\\\"field\\\"&gt;&lt;t&gt;Last name&lt;/t&gt;&lt;v&gt;ContactLastName&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;Anonym&lt;/t&gt;&lt;v&gt;Anonym&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;r pos=\\\"1\\\" par=\\\"\\\" op=\\\"or\\\" n=\\\"CMSContactFieldContainsValue\\\" &gt;&lt;p n=\\\"field\\\"&gt;&lt;t&gt;Last name&lt;/t&gt;&lt;v&gt;ContactLastName&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;does not contain&lt;/t&gt;&lt;v&gt;NotContains&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;Anonym&lt;/t&gt;&lt;v&gt;Anonym&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>"
            );

        var pageVisitRule = GenerateBasicRule(
            persona,
            "10 points per every page visit",
            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();
    }
    private static void GenerateDisabledPersona()
    {
        var persona = new PersonaInfo
        {
            PersonaDisplayName = "Disabled persona with various rules",
            PersonaName = "Persona-" + Guid.NewGuid(),
            PersonaSiteID = SiteContext.CurrentSiteID,
            PersonaPointsThreshold = 5,
            PersonaEnabled = false
        };
        persona.Insert();

        GenerateBasicRule(
            persona,
            "100 points for content rating activity",
            100,
            RuleTypeEnum.Activity,
            "<condition><activity name=\"rating\"><field name=\"ActivityValue\"><value>0</value><params><operator>11</operator></params></field><field name=\"ActivityCreated\"><params><seconddatetime>1/1/0001 12:00:00 AM</seconddatetime></params></field><field name=\"ActivityURL\"><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></activity><wherecondition>(ActivityType='rating') AND (CASE ISNUMERIC([ActivityValue]) WHEN 1 THEN CAST([ActivityValue] AS FLOAT) ELSE NULL END &gt; CAST(0 AS FLOAT))</wherecondition></condition>",
            "rating"
            );

        GenerateBasicRule(
            persona,
            "Always satisfied macro rule for 30 points",
            30,
            RuleTypeEnum.Macro,
            "<condition><macro><value>{%Rule(\"Contact.ContactLastName.Contains(\\\"Anonym\\\") || Contact.ContactLastName.NotContains(\\\"Anonym\\\")\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"or\\\" n=\\\"CMSContactFieldContainsValue\\\" &gt;&lt;p n=\\\"field\\\"&gt;&lt;t&gt;Last name&lt;/t&gt;&lt;v&gt;ContactLastName&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;Anonym&lt;/t&gt;&lt;v&gt;Anonym&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;r pos=\\\"1\\\" par=\\\"\\\" op=\\\"or\\\" n=\\\"CMSContactFieldContainsValue\\\" &gt;&lt;p n=\\\"field\\\"&gt;&lt;t&gt;Last name&lt;/t&gt;&lt;v&gt;ContactLastName&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;does not contain&lt;/t&gt;&lt;v&gt;NotContains&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;Anonym&lt;/t&gt;&lt;v&gt;Anonym&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>"
            );

        GenerateBasicRule(
            persona,
            "Contact has got e-mail address filled for 50p",
            50,
            RuleTypeEnum.Attribute,
            "<condition><attribute name=\"ContactEmail\"><value>@</value><params><Operator>0</Operator></params></attribute><wherecondition>ISNULL([ContactEmail], '') LIKE N'%@%'</wherecondition></condition>",
            "ContactEmail"
            );

        GenerateBasicRule(
            persona,
            "Contact has filled \"Contact us\" form for 50p",
            50,
            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>"
            );

        var pageVisitRule = GenerateBasicRule(
            persona,
            "5 points per every page visit",
            5,
            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 = 100000;
        pageVisitRule.RuleIsRecurring = true;
        pageVisitRule.Update();
    }