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))\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" ><p n=\\\"_perfectum\\\"><t>has</t><v></v><r>0</r><d>select operation</d><vt>text</vt><tv>0</tv></p><p n=\\\"days\\\"><t>150</t><v>150</v><r>0</r><d>enter days</d><vt>integer</vt><tv>1</tv></p><p n=\\\"item\\\"><t>&lt;Contact Us&gt;</t><v>ContactUs</v><r>1</r><d>select form</d><vt>text</vt><tv>0</tv></p></r></rules>\")%}</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(\\\"@\\\")\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactFieldContainsValue\\\" ><p n=\\\"field\\\"><t>E-mail address</t><v>ContactEmail</v><r>1</r><d>select field</d><vt>text</vt><tv>0</tv></p><p n=\\\"op\\\"><t>contains</t><v>Contains</v><r>0</r><d>select operator</d><vt>text</vt><tv>0</tv></p><p n=\\\"value\\\"><t>@</t><v>@</v><r>0</r><d>enter value</d><vt>text</vt><tv>1</tv></p></r></rules>\")%}</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))\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" ><p n=\\\"_perfectum\\\"><t>has</t><v></v><r>0</r><d>select operation</d><vt>text</vt><tv>0</tv></p><p n=\\\"days\\\"><t>150</t><v>150</v><r>0</r><d>enter days</d><vt>integer</vt><tv>1</tv></p><p n=\\\"item\\\"><t>&lt;Contact Us&gt;</t><v>ContactUs</v><r>1</r><d>select form</d><vt>text</vt><tv>0</tv></p></r></rules>\")%}</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); }