Example #1
0
        Communication ICampaignEmailsCommand.GeneratePreview(CampaignEmail email, Guid campaignId)
        {
            // Get the campaign.

            var campaign = _campaignsQuery.GetCampaign(campaignId);

            if (campaign == null)
            {
                throw new ApplicationException("Cannot find the campaign with id '" + campaignId + "'.");
            }

            email.Properties.Add("Category", campaign.CommunicationCategoryId == null ? "Campaign" : _settingsQuery.GetCategory(campaign.CommunicationCategoryId.Value).Name);
            email.Properties.Add("IncludeUnsubscribe", true);

            var template = _campaignsQuery.GetTemplate(campaign.Id);

            if (template != null)
            {
                // Create an item template based on it.

                var templateContentItem = CreateTemplateContentItem(campaign, template);
                return(_emailsCommand.GeneratePreview(email, templateContentItem));
            }

            return(_emailsCommand.GeneratePreview(email));
        }
Example #2
0
        public override void ExecuteTask(string[] args)
        {
            const string method = "ExecuteTask";

            EventSource.Raise(Event.FlowEnter, method, "Entering CampaignFile task.");

            if (args.Length < 2)
            {
                throw new ArgumentException("Need at least 2 arguments, \"campaign file\"");
            }

            var campaignName = args[0];
            var fileName     = args[1];

            // Get the campaign.

            var campaign = _campaignsQuery.GetCampaign(campaignName);

            if (campaign == null)
            {
                EventSource.Raise(Event.Error, method, string.Format("Cannot find campaign the '{0}' campaign.", campaignName));
            }
            else
            {
                Execute(campaign, fileName);
            }

            EventSource.Raise(Event.FlowExit, method, "Exiting Campaigns task.");
        }
Example #3
0
        protected void AssertCampaigns(params Campaign[] expectedCampaigns)
        {
            // Get each individually.

            foreach (var expectedCampaign in expectedCampaigns)
            {
                Assert.AreNotEqual(DateTime.MinValue, expectedCampaign.CreatedTime);
                Assert.AreEqual(expectedCampaign, _campaignsQuery.GetCampaign(expectedCampaign.Id));
            }

            // Get all.

            var campaigns = _campaignsQuery.GetCampaigns(null, new Range());

            Assert.AreEqual(expectedCampaigns.Length, campaigns.RangeItems.Count);
            for (var index = 0; index < expectedCampaigns.Length; ++index)
            {
                Assert.AreEqual(expectedCampaigns[index], campaigns.RangeItems[index]);
            }
        }
Example #4
0
        public ActionResult Edit(Guid id)
        {
            // Get the campaign.

            var campaign = _campaignsQuery.GetCampaign(id);

            if (campaign == null)
            {
                return(NotFound("campaign", "id", id));
            }

            var createdBy = _administratorsQuery.GetAdministrator(campaign.CreatedBy);

            return(View(new CampaignSummaryModel {
                Campaign = campaign, CreatedBy = createdBy, IsReadOnly = IsReadOnly(campaign), CommunicationDefinitions = _settingsQuery.GetDefinitions(), CommunicationCategories = _settingsQuery.GetCategories()
            }));
        }