Last active
May 15, 2019 04:44
-
-
Save markgibbons25/54162f81b141418af69962c431ab6484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web.UI.WebControls; | |
using Sitecore.Modules.EmailCampaign.Application.EmailDispatch; | |
namespace Foundation.xDB.sitecore.admin | |
{ | |
public partial class ExmMessageActivator : System.Web.UI.Page | |
{ | |
private IEmailDispatch _emailDispatch; | |
private const string EmailXpath = "/sitecore/content/Email//*[@@templateid='{078D8A76-F971-4891-B422-76C0BCF9FA03}']"; | |
public ExmMessageActivator() | |
{ | |
_emailDispatch = Sitecore.Modules.EmailCampaign.Application.Application.Instance.EmailDispatch; | |
} | |
protected void btnActivate_Click(object sender, EventArgs e) | |
{ | |
var items = GetItems(false); | |
foreach (var item in items) | |
{ | |
_emailDispatch.Activate(item); | |
} | |
} | |
protected void btnDeactivate_Click(object sender, EventArgs e) | |
{ | |
var items = GetItems(true); | |
foreach (var item in items) | |
{ | |
_emailDispatch.Deactivate(item); | |
} | |
} | |
private List<Guid> GetItems(bool isReadOnly) | |
{ | |
return Sitecore.Data.Database.GetDatabase("master") | |
.SelectItems(EmailXpath) | |
.Where(x => x.Appearance.ReadOnly == isReadOnly) | |
.Select(x => x.ID.Guid) | |
.ToList(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment