Exemple #1
0
        private void GeneratePersonaContactHistoryRecords()
        {
            var contactsWithoutPersona = 2658;
            var contactsInB2BPersona   = 426;
            var contactsInB2CPersona   = 1037;
            var personaInfoByCodeName1 = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_CAFE_OWNER);
            var personaInfoByCodeName2 = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_COFEE_GEEK);
            var now        = DateTime.Now;
            var dateTime1  = now.AddDays(30.0);
            var dateTime2  = now.AddDays(-60.0);
            var collection = new Collection <PersonaContactHistoryInfo>();

            for (var time = dateTime2; time < dateTime1; time = time.AddDays(1.0))
            {
                IncreaseContactsCount(time, now, ref contactsWithoutPersona, ref contactsInB2BPersona,
                                      ref contactsInB2CPersona);
                ChangeCountsIfCampaign1IsRunning(time, now, ref contactsInB2CPersona);
                ChangeCountsIfCampaign2IsSendingMails(time, now, ref contactsWithoutPersona, ref contactsInB2CPersona);
                ChangeCountsWhenPersonaRulesChanged(time, now, ref contactsWithoutPersona, ref contactsInB2BPersona,
                                                    ref contactsInB2CPersona);
                collection.Add(CreatePersonaContactHistoryInfo(contactsWithoutPersona, time, new int?()));
                collection.Add(CreatePersonaContactHistoryInfo(contactsInB2BPersona, time,
                                                               personaInfoByCodeName1.PersonaID));
                collection.Add(CreatePersonaContactHistoryInfo(contactsInB2CPersona, time,
                                                               personaInfoByCodeName2.PersonaID));
            }

            PersonaContactHistoryInfoProvider.BulkInsert(collection);
        }
Exemple #2
0
        private void GenerateCafeOwnerPersona()
        {
            var infoObj = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_CAFE_OWNER);

            if (infoObj == null)
            {
                infoObj = new PersonaInfo
                {
                    PersonaDisplayName = "Tony, the Cafe Owner",
                    PersonaName        = PERSONA_CAFE_OWNER,
                    PersonaDescription =
                        "Tony has been running his own cafe for the last 7 years. He always looks at ways of improving the service he provides.\r\n\r\nHe offers coffee that he sources from several roasteries. In addition to that, he also sells brewing machines, accessories and grinders for home use.",
                    PersonaPointsThreshold     = 15,
                    PersonaPictureMetafileGUID = new Guid("220C65BA-2CED-4347-9615-8CF69EAC20E5"),
                    PersonaEnabled             = true
                };
                PersonaInfoProvider.SetPersonaInfo(infoObj);
            }

            var treeNode = DocumentHelper.GetDocuments().All().Culture("en-US").Path("/Partnership").Columns("NodeID")
                           .OnCurrentSite().TopN(1).FirstOrDefault();

            if (treeNode != null)
            {
                var rule = GenerateRule("Visited the Partnership section", 5, infoObj.PersonaScoreID,
                                        "<condition>\r\n  <activity name=\"pagevisit\">\r\n    <field name=\"ActivityCreated\">\r\n      <settings>\r\n        <seconddatetime>1/1/0001 12:00:00 AM</seconddatetime>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityNodeID\">\r\n      <value>" +
                                        treeNode.NodeID +
                                        "</value>\r\n    </field>\r\n    <field name=\"ActivityURL\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityTitle\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityComment\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityCampaign\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityURLReferrer\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityABVariantName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityMVTCombinationName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n  </activity>\r\n  <wherecondition>(ActivityType='pagevisit') AND ([ActivityNodeID] = " +
                                        treeNode.NodeID + ")</wherecondition>\r\n</condition>", RuleTypeEnum.Activity, "pagevisit");
                rule.RuleIsRecurring = true;
                rule.RuleMaxPoints   = 15;
                RuleInfoProvider.SetRuleInfo(rule);
            }

            var infoByName = ProviderHelper.GetInfoByName("cms.form", "BusinessCustomerRegistration", _mSite.SiteID);

            if (infoByName != null)
            {
                var obj = infoByName.GetValue("FormName");
                GenerateRule("Submitted the business registration form", 15, infoObj.PersonaScoreID,
                             BuildMacroRuleCondition("{%Rule(\"(Contact.SubmittedForm(\\\"" + obj +
                                                     "\\\", ToInt(0)))\", \"&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;#enter days&lt;/t&gt;&lt;v&gt;0&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;" +
                                                     obj + "&lt;/t&gt;&lt;v&gt;" + obj +
                                                     "&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;\")%}"),
                             RuleTypeEnum.Macro, null, false);
            }

            GenerateRule("Gmail penalization", -10, infoObj.PersonaScoreID,
                         "<condition>\r\n  <attribute name=\"ContactEmail\">\r\n    <value>gmail.com</value>\r\n    <params>\r\n      <ContactEmailOperator>6</ContactEmailOperator>\r\n    </params>\r\n  </attribute>\r\n  <wherecondition>[ContactEmail] LIKE N'%gmail.com'</wherecondition>\r\n</condition>",
                         RuleTypeEnum.Attribute, "ContactEmail");
        }
Exemple #3
0
        private static void AssignPersonaToSkUs(string personaName, string[] skuNames)
        {
            var personaInfoByCodeName = PersonaInfoProvider.GetPersonaInfoByCodeName(personaName);

            if (personaInfoByCodeName == null)
            {
                return;
            }

            foreach (var treeNode in DocumentHelper.GetDocuments().All().AllCultures().WhereIn("SKUName", skuNames)
                     .Columns("NodeID").OnCurrentSite())
            {
                PersonaNodeInfoProvider.RemovePersonaFromNode(personaInfoByCodeName.PersonaID, treeNode.NodeID);
                PersonaNodeInfoProvider.AddPersonaToNode(personaInfoByCodeName.PersonaID, treeNode.NodeID);
            }
        }
Exemple #4
0
        private void GenerateBannerPersonalizationVariantsMacrosAndEnableVariants()
        {
            var personalizationVariant1 =
                ContentPersonalizationVariantInfoProvider.GetContentPersonalizationVariant(
                    "TheCafeOwnerBannerVariant_dd20f145-3779-4748-9bc8-d383eecfbd15");
            var personalizationVariant2 =
                ContentPersonalizationVariantInfoProvider.GetContentPersonalizationVariant(
                    "TheCoffeeGeekBannerVariant_d862b458-e5a5-432f-a3fe-60f495acad9f");

            if (personalizationVariant1 == null || personalizationVariant2 == null ||
                personalizationVariant1.VariantEnabled || personalizationVariant2.VariantEnabled ||
                personalizationVariant1.VariantDisplayCondition != "{%// Macro will be added by generator%}" ||
                personalizationVariant2.VariantDisplayCondition != "{%// Macro will be added by generator%}")
            {
                return;
            }

            var personaInfoByCodeName1 = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_CAFE_OWNER);
            var personaInfoByCodeName2 = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_COFEE_GEEK);

            if (personaInfoByCodeName1 == null || personaInfoByCodeName2 == null)
            {
                return;
            }

            var identityOption = MacroIdentityOption.FromUserInfo(UserInfoProvider.AdministratorUser);

            personalizationVariant1.VariantDisplayCondition = MacroSecurityProcessor.AddSecurityParameters(
                string.Format(
                    "{{%Rule(\"(Contact.IsInPersona(\\\"{0}\\\"))\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"ContactIsInPersona\\\" ><p n=\\\"_is\\\"><t>is</t><v></v><r>0</r><d>select operation</d><vt>text</vt><tv>0</tv></p><p n=\\\"personaguid\\\"><t>{1}</t><v>{0}</v><r>1</r><d>select persona</d><vt>text</vt><tv>0</tv></p></r></rules>\")%}}",
                    personaInfoByCodeName1.PersonaGUID, personaInfoByCodeName1.PersonaDisplayName),
                identityOption, null);
            personalizationVariant2.VariantDisplayCondition = MacroSecurityProcessor.AddSecurityParameters(
                string.Format(
                    "{{%Rule(\"(Contact.IsInPersona(\\\"{0}\\\"))\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"ContactIsInPersona\\\" ><p n=\\\"_is\\\"><t>is</t><v></v><r>0</r><d>select operation</d><vt>text</vt><tv>0</tv></p><p n=\\\"personaguid\\\"><t>{1}</t><v>{0}</v><r>1</r><d>select persona</d><vt>text</vt><tv>0</tv></p></r></rules>\")%}}",
                    personaInfoByCodeName2.PersonaGUID, personaInfoByCodeName2.PersonaDisplayName),
                identityOption, null);
            personalizationVariant1.VariantEnabled = true;
            personalizationVariant2.VariantEnabled = true;
            ContentPersonalizationVariantInfoProvider.SetContentPersonalizationVariant(personalizationVariant1);
            ContentPersonalizationVariantInfoProvider.SetContentPersonalizationVariant(personalizationVariant2);
        }
Exemple #5
0
        private void GenerateCafeOwnerPersona()
        {
            var coffeeOwnerPersona = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_CAFE_OWNER);

            if (coffeeOwnerPersona != null)
            {
                return;
            }

            coffeeOwnerPersona = new PersonaInfo
            {
                PersonaDisplayName         = "Tony, the Cafe Owner",
                PersonaName                = PERSONA_CAFE_OWNER,
                PersonaDescription         = "Tony has been running his own cafe for the last 7 years. He always looks at ways of improving the service he provides.\r\n\r\nHe offers coffee that he sources from several roasteries. In addition to that, he also sells brewing machines, accessories and grinders for home use.",
                PersonaPointsThreshold     = 15,
                PersonaPictureMetafileGUID = new Guid("220C65BA-2CED-4347-9615-8CF69EAC20E5"),
                PersonaEnabled             = true
            };
            PersonaInfoProvider.SetPersonaInfo(coffeeOwnerPersona);
        }
Exemple #6
0
        private void GenerateCoffeeGeekPersona()
        {
            var coffeeGeekPersona = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_COFEE_GEEK);

            if (coffeeGeekPersona != null)
            {
                return;
            }

            coffeeGeekPersona = new PersonaInfo
            {
                PersonaDisplayName         = "Martina, the Coffee Geek",
                PersonaName                = PERSONA_COFEE_GEEK,
                PersonaDescription         = "Martina is 28, she's an online entrepreneur and a foodie girl who likes to blog about her gastronomic experiences. \r\n\r\nThe preparation of her coffee has to be perfect.  She knows all the technical bits that go into the process. Not to leave things to chance, she also owns a professional espresso machine and a grinder.\r\n\r\nMartina drinks a cappuccino or a filtered coffee in the morning and then an espresso or machiato after each meal.",
                PersonaPointsThreshold     = 15,
                PersonaPictureMetafileGUID = new Guid("8A3AF6F7-0914-42E1-9641-B7F2E04AED1B"),
                PersonaEnabled             = true
            };
            PersonaInfoProvider.SetPersonaInfo(coffeeGeekPersona);
        }
Exemple #7
0
        private void GenerateCoffeeGeekPersona()
        {
            var personaInfo = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_COFEE_GEEK);

            if (personaInfo == null)
            {
                personaInfo = new PersonaInfo
                {
                    PersonaDisplayName = "Martina, the Coffee Geek",
                    PersonaName        = PERSONA_COFEE_GEEK,
                    PersonaDescription =
                        "Martina is 28, she's an online entrepreneur and a foodie girl who likes to blog about her gastronomic experiences. \r\n\r\nThe preparation of her coffee has to be perfect.  She knows all the technical bits that go into the process. Not to leave things to chance, she also owns a professional espresso machine and a grinder.\r\n\r\nMartina drinks a cappuccino or a filtered coffee in the morning and then an espresso or machiato after each meal.",
                    PersonaPointsThreshold     = 15,
                    PersonaPictureMetafileGUID = new Guid("8A3AF6F7-0914-42E1-9641-B7F2E04AED1B"),
                    PersonaEnabled             = true
                };
                PersonaInfoProvider.SetPersonaInfo(personaInfo);
            }

            SubscribeCoffeeGeekContactGroupToEmailCampaign(personaInfo);
            var newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo("DancingGoatNewsletter", _mSite.SiteID);

            if (newsletterInfo != null)
            {
                GenerateRule("Is subscribed to the Dancing goat newsletter", 10, personaInfo.PersonaScoreID,
                             "<condition>\r\n  <activity name=\"newslettersubscription\">\r\n    <field name=\"ActivityItemID\">\r\n      <value>" +
                             newsletterInfo.NewsletterID +
                             "</value>\r\n    </field>\r\n    <field name=\"ActivityCreated\">\r\n      <settings>\r\n        <seconddatetime>1/1/0001 12:00:00 AM</seconddatetime>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityURL\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityTitle\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityComment\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityCampaign\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityURLReferrer\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n  </activity>\r\n  <wherecondition>(ActivityType='newslettersubscription') AND ([ActivityItemID] = " +
                             newsletterInfo.NewsletterID + ")</wherecondition>\r\n</condition>", RuleTypeEnum.Activity,
                             "newslettersubscription");
            }

            GenerateRule("Downloaded the America's coffee poster file", 5, personaInfo.PersonaScoreID,
                         BuildMacroRuleCondition(
                             "<condition>\r\n  <macro>\r\n    <value>{%Rule(\"(Contact.VisitedPage(\\\"/Campaign-assets/Cafe-promotion/America-s-coffee-poster\\\", ToInt(0)))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasDownloadedSpecifiedFileInLastXDays\\\" &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;#enter days&lt;/t&gt;&lt;v&gt;0&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;/Campaign-assets/Cafe-promotion/America-s-coffee-poster&lt;/t&gt;&lt;v&gt;/Campaign-assets/Cafe-promotion/America-s-coffee-poster&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select file&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>\r\n  </macro>\r\n</condition>"),
                         RuleTypeEnum.Macro);
            GenerateRule("Spent between $1 and $100", 10, personaInfo.PersonaScoreID,
                         BuildMacroRuleCondition(
                             "{%Rule(\"(Contact.SpentMoney(ToDouble(1), ToDouble(100), ToInt(90)))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSpentMoneyInTheStoreInTheLastXDays\\\" &gt;&lt;p n=\\\"money1\\\"&gt;&lt;t&gt;1&lt;/t&gt;&lt;v&gt;1&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;enter value&lt;/d&gt;&lt;vt&gt;double&lt;/vt&gt;&lt;tv&gt;1&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"days\\\"&gt;&lt;t&gt;90&lt;/t&gt;&lt;v&gt;90&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=\\\"money2\\\"&gt;&lt;t&gt;100&lt;/t&gt;&lt;v&gt;100&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;enter value&lt;/d&gt;&lt;vt&gt;double&lt;/vt&gt;&lt;tv&gt;1&lt;/tv&gt;&lt;/p&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;/r&gt;&lt;/rules&gt;\")%}"),
                         RuleTypeEnum.Macro);
        }
 /// <summary>
 /// Creates an empty instance of <see cref="IsInPersonaConditionType"/> class.
 /// </summary>
 public IsInPersonaConditionType()
 {
     mPersona = new Lazy <PersonaInfo>(() => PersonaInfoProvider.GetPersonaInfoByCodeName(PersonaName));
 }