private static void GenerateContactGroups(bool global)
    {
        var contactGroupsGenerator = new SampleContactGroupsGenerator();

        contactGroupsGenerator.GenerateContactGroup("{%Rule(\"Contact.SubmittedForm(\\\"ContactUs\\\", ToInt(7))\", \"<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>7</t><v>7</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>\")%}", "CG: Submited Contact us form in the last 7 days", global);
        contactGroupsGenerator.GenerateContactGroup("{%Rule(\"Contact.DidActivity(null, null, ToInt(7))\", \"<rules><r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasDoneAnyActivityInTheLastXDays\\\" ><p n=\\\"days\\\"><t>7</t><v>7</v><r>0</r><d>enter days</d><vt>integer</vt><tv>1</tv></p><p n=\\\"_perfectum\\\"><t>has</t><v></v><r>0</r><d>select operation</d><vt>text</vt><tv>0</tv></p></r></rules>\")%}", "CG: Contact has done any activity in the last 7 days", global);
        contactGroupsGenerator.GenerateContactGroup("{%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>\")%}", "CG: Contact has e-mail field filled", global);
    }
        public void Generate(GenerationOptions options)
        {
            try
            {
                if (options.GenerateContactStatuses)
                {
                    if (ContactStatusInfoProvider.GetContactStatuses().OnSite(mSiteId).Any())
                    {
                        Information("Contact statuses already exists");
                    }
                    else
                    {
                        new SampleContactStatusesGenerator(mSiteId).Generate();
                        Information("Contact statuses generated");
                    }
                }
                if (options.ContactsCount > 0)
                {
                    if (options.ContactsWithRealNames && options.ContactsCount > 100)
                    {
                        Error("Contacts where not generated. \"Contacts with real names\" setting shouldn't be used for generating more than 100 contacts at once.");
                    }
                    else
                    {
                        IPersonalDataGenerator personalDataGenerator = options.ContactsWithRealNames ?
                            new RealPersonalDataGenerator() :
                            (IPersonalDataGenerator)new StupidPersonalDataGenerator();
                        SampleContactsGenerator generator = new SampleContactsGenerator(personalDataGenerator, mSiteId);
                        var batch = 10000;
                        var count = options.ContactsCount;
                        while (count > batch)
                        {
                            generator.Generate(batch);
                            count -= batch;
                        }
                        generator.Generate(count);
                        Information(options.ContactsCount + " contacts generated");
                    }
                }
                if (options.GenerateMergedContacts)
                {
                    var personalDataGenerator = new StupidPersonalDataGenerator();
                    var generator = new SampleContactsGenerator(personalDataGenerator, mSiteId);
                    generator.GenerateMergedContacts();
                    Information(options.ContactsCount + " merged contacts generated");
                }
                if (options.GenerateContactRelationships)
                {
                    var generator = new ContactRelationshipsGenerator();
                    int generated = generator.GenerateContactRelationships(SiteContext.CurrentSite);
                    Information(generated + " relationships between contact and user generated");
                }
                if (options.GeneratePersonas)
                {
                    ISamplePersonasGenerator personaGenerator = options.ContactsWithRealNames ?
                        new RealPersonasGenerator() :
                        (ISamplePersonasGenerator)new StupidPersonasGenerator();
                    personaGenerator.GeneratePersonas(mSiteId);
                    Information("Sample personas generated");
                }
                if (options.GenerateContactGroups > 0)
                {
                    int generatedCGs = new SampleContactGroupsGenerator().GenerateContactGroups(options.GenerateContactGroups);

                    Information(generatedCGs + " contact groups generated");
                }
                if (options.ScoresCount > 0)
                {
                    new SampleScoresGenerator().GenerateScores(options.ScoresCount, mSiteId);
                    Information(options.ScoresCount + " scores generated");
                }
                if (options.ActivitiesForEachExistingContactCount > 0)
                {
                    var contacts = ContactInfoProvider.GetContacts().OnSite(mSiteId);

                    var documents = DocumentHelper.GetDocuments()
                                                  .PublishedVersion()
                                                  .OnSite(mSiteId)
                                                  .ToList();

                    int activitiesGenerated = 0;
                    contacts.ForEachPage(page => activitiesGenerated += new SampleActivitiesGenerator().GenerateActivitiesForContacts(page, options.ActivitiesForEachExistingContactCount, documents), 10000);

                    Information(activitiesGenerated + " activities generated");
                }
            }
            catch (Exception e)
            {
                Error(e.Message);
            }
        }