Skip to content

Commit

Permalink
Bugfixing and ready for 3.2.0 release
Browse files Browse the repository at this point in the history
Fixed Commerce provider to use new configuration system, defaulted back
to appSettings for sender config to not break upgrades. Fixed a bug in
the remove from text provider.
  • Loading branch information
evest committed May 7, 2015
1 parent a44f02f commit ac717ca
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 71 deletions.
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ When you install the module using Nuget, the following configuration is added to

#### Available Sender Engines ####
The default is the MailSenderNetSmtp engine. Change the `senderType` to select another sender engine.

SMTP Server: `<epicodeNewsletter senderType="BVNetwork.EPiSendMail.Library.MailSenderNetSmtp, BVNetwork.EPiSendMail">`

Mailgun: `<epicodeNewsletter senderType="BVNetwork.EPiSendMail.Library.MailSenderMailgun, BVNetwork.EPiSendMail">`

SendGrid: `<epicodeNewsletter senderType="BVNetwork.EPiSendMail.SendGrid.MailSenderSendGrid, BVNetwork.EPiSendMail.SendGrid">`

> Note! Mailgun and SendGrid requires additional settings.
### Recipient List Providers ###
Expand Down Expand Up @@ -159,7 +163,7 @@ The Api keys can be found on the Mailgun Account home page: https://mailgun.com/
You also need to configure your mail sending domain for your Mailgun account, which is well described on your Mailgun account page. For testing purposes, you can use the sandbox domain that is created when you register your Mailgun account.

### Configuring SendGrid ###
Add the following keys to the `<appSettings>` section in web.config to use Mailgun:
Add the following keys to the `<appSettings>` section in web.config to use SendGrid:
```xml
<add key="Newsletter.SenderType" value="BVNetwork.EPiSendMail.SendGrid.MailSenderSendGrid, BVNetwork.EPiSendMail.SendGrid" />
```
Expand Down Expand Up @@ -200,7 +204,7 @@ In some cases, there are missing assembly redirects for some of the `System.Net`
</assemblyBinding>

```
'''Important! ''' You might have never versions of these referenced in your project. Make sure you check the actual versions of the assemblies before you add the redirects.
**Important!** You might have never versions of these referenced in your project. Make sure you check the actual versions of the assemblies before you add the redirects.

## Support ##
This module is open source and unsupported. Feel free to [register new issues](https://github.com/BVNetwork/Newsletter/issues/new) though.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EPiServer.Framework, Version=7.5.394.2, Culture=neutral, PublicKeyToken=8fe83dea738b45b7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\EPiServer.Framework.dll</HintPath>
<Reference Include="EPiServer.Framework">
<HintPath>..\Newsletter\References\EPiServer.Framework.dll</HintPath>
</Reference>
<Reference Include="Mediachase.BusinessFoundation">
<HintPath>References\Mediachase.BusinessFoundation.dll</HintPath>
Expand All @@ -52,17 +51,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfoVersion.cs" />
<Compile Include="Plugin\WorkItemProviders\CommerceUsersProvider.ascx.cs">
<Compile Include="Plugin\ItemProviders\CommerceUsersProvider.ascx.cs">
<DependentUpon>CommerceUsersProvider.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Plugin\WorkItemProviders\CommerceUsersProvider.ascx.designer.cs">
<Compile Include="Plugin\ItemProviders\CommerceUsersProvider.ascx.designer.cs">
<DependentUpon>CommerceUsersProvider.ascx</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Plugin\WorkItemProviders\CommerceUsersProvider.ascx">
<Content Include="Plugin\ItemProviders\CommerceUsersProvider.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>
</ItemGroup>
Expand All @@ -76,6 +75,7 @@
<None Include="EPiCode.Newsletter.Commerce.nuspec">
<SubType>Designer</SubType>
</None>
<None Include="web.config.install.xdt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<files>
<file src="Plugin\**\*.as?x"
target="content\modules\epicode.newsletter\plugin\" />

<!-- Configuration -->
<file src="web.config.install.xdt"
target="content" />

<file src="bin\BVNetwork.EPiSendMail.CommerceProvider.dll"
target="lib\net45\BVNetwork.EPiSendMail.CommerceProvider.dll" />
<file src="bin\BVNetwork.EPiSendMail.CommerceProvider.dll"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private void LoadCommerceProfileViewsGroups()
}
allCustomerViews.Add(new KeyValuePair<string, string>(listViewProfile.Id, " " + name));
}

ListViewProfile[] userProfiles = ListViewProfile.GetProfiles(MetaClassName, "EntityList",
SecurityContext.Current.CurrentContactId);
foreach (ListViewProfile listViewProfile in userProfiles)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/Newsletter.CommerceProvider/web.config.install.xdt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<epicodeNewsletter>
<recipientListProviders>
<add name="CommerceUsers"
displayName="Add email addresses from Commerce Contacts"
url="/modules/epicode.newsletter/plugin/itemproviders/CommerceUsersProvider.ascx"
xdt:Locator="Match(name)"
xdt:Transform="InsertIfMissing" />
</recipientListProviders>
</epicodeNewsletter>
</configuration>
5 changes: 4 additions & 1 deletion src/Newsletter/EPiCode.Newsletter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@
<Content Include="Plugin\WorkItemProviders\RecipientRemoveProvider.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="Plugin\WorkItemProviders\TextRemoveProvider.ascx" />
<Content Include="Plugin\WorkItemProviders\TextRemoveProvider.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>
<Content Include="Plugin\ItemProviders\RecipientProvider.ascx">
<SubType>ASPXCodeBehind</SubType>
</Content>
Expand All @@ -619,6 +621,7 @@
<Content Include="lang\EPiCode.Newsletter.NO.xml" />
<EmbeddedResource Include="Tools\newsletter-validating-query-301.sql" />
<EmbeddedResource Include="Tools\newsletter-install-301.sql" />
<None Include="web.config.install.xdt" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
2 changes: 1 addition & 1 deletion src/Newsletter/EPiCode.Newsletter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
target="content\modules\epicode.newsletter\module.config" />

<!-- Configuration -->
<file src="..\InstallationResources\web.config.install.xdt"
<file src="web.config.install.xdt"
target="content" />
<!--
// This removes all changed settings on updates, which is a pain
Expand Down
9 changes: 5 additions & 4 deletions src/Newsletter/Library/EPiMailEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ public string GetMailSenderTypeName()
{
const string defSender = "MailSenderNetSmtp";

// First get from new config section
string typeName = NewsletterConfigurationSection.Instance.SenderType;
// For backwards compatibility, we need to use the appSettings value first
string typeName = NewsLetterConfiguration.MailSenderTypename;

if(string.IsNullOrEmpty(typeName))
{
// Fallback to previous way of configuration in appSettings
typeName = NewsLetterConfiguration.MailSenderTypename;
// Get from new config section
typeName = NewsletterConfigurationSection.Instance.SenderType;
}

if (typeName == null)
Expand Down
42 changes: 7 additions & 35 deletions src/Newsletter/Plugin/Jobs/AddWorkItems.ascx.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.WebControls;
using BVNetwork.EPiSendMail.Configuration;
using BVNetwork.EPiSendMail.DataAccess;
using BVNetwork.EPiSendMail.Plugin.ItemProviders;
using EPiServer.Core;
using EPiServer.Framework.Localization;
using EPiServer.ServiceLocation;
Expand Down Expand Up @@ -30,44 +33,13 @@ protected override void InitializeWorkItemDescriptors()
{
LocalizationService localizationService = ServiceLocator.Current.GetInstance<LocalizationService>();

NameValueCollection config = NewsLetterConfiguration.GetRecipientListProviders();
if (config != null)
List<RecipientListProviderDescriptor> recipientProviders = NewsLetterConfiguration.GetRecipientListProviderDescriptors();

foreach (RecipientListProviderDescriptor descriptor in recipientProviders)
{
foreach (string item in config)
{
WorkItemProviderDescriptor provider = new WorkItemProviderDescriptor(item,
localizationService.GetString("/newsletterRecipientProvider/" + item, item),
config[item]);
AddProviderWithChecks(WorkItemProviders, provider);
}
AddProviderWithChecks(WorkItemProviders, descriptor);
}

// Build the provider list, this will be configurable later
WorkItemProviderDescriptor recipientListProvider =
new WorkItemProviderDescriptor("RecipientList",
"Select one of your Recipient Lists",
BVNetwork.EPiSendMail.Configuration.NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/workitemproviders/recipientprovider.ascx");

AddProviderWithChecks(WorkItemProviders, recipientListProvider);

WorkItemProviderDescriptor textProvider =
new WorkItemProviderDescriptor("TextImport",
"Import from text",
BVNetwork.EPiSendMail.Configuration.NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/workitemproviders/TextImportProvider.ascx");
AddProviderWithChecks(WorkItemProviders, textProvider);

WorkItemProviderDescriptor sidGroupProvider =
new WorkItemProviderDescriptor("EPiServerGroup",
"Add email addresses from an EPiServer Group",
BVNetwork.EPiSendMail.Configuration.NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/workitemproviders/EPiServerGroupProvider.ascx");
AddProviderWithChecks(WorkItemProviders, sidGroupProvider);

WorkItemProviderDescriptor commerceUsersProvider =
new WorkItemProviderDescriptor("CommerceUsers",
"Add users from Commerce",
BVNetwork.EPiSendMail.Configuration.NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/workitemproviders/CommerceUsersProvider.ascx");
AddProviderWithChecks(WorkItemProviders, commerceUsersProvider);

}

protected void Page_Load(object sender, EventArgs e)
Expand Down
23 changes: 23 additions & 0 deletions src/Newsletter/Plugin/Jobs/JobStatus.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@
console.debug(data);
var html = $('#jobStatusTemplate').render(data);
$('#pnlStatusMessage').html(html);
},
error: function(data) {
console.debug(data);
if (data.status === 500) {
var errorData = {};
errorData.status = data.status;
errorData.errorMessage = data.statusText;
if (data.responseJSON) {
errorData.detailedMessage = data.responseJSON.ExceptionMessage;
}
var html = $('#jobStatusErrorTemplate').render(errorData);
$('#pnlStatusMessage').html(html);
}
else {
$('#pnlStatusMessage').html("An error occured.");
}
}
});
}
Expand All @@ -59,6 +75,13 @@
<span style="font-size: 14px;" class="glyphicon glyphicon-refresh"></span> Update status
</a>

<script id="jobStatusErrorTemplate" type="text/x-jsrender">
<div class="alert alert-warning" role="alert">
<span class="label label-warning">{{:status}} - {{:errorMessage}}</span>
<p>{{:detailedMessage}}</p>
</div>
</script>

<script id="jobStatusTemplate" type="text/x-jsrender">
{{if SchedulerIsOnline===false}}
<div class="alert alert-warning" role="alert">
Expand Down
29 changes: 11 additions & 18 deletions src/Newsletter/Plugin/WorkItemProviders/TextRemoveProvider.ascx.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
using System;
using BVNetwork.EPiSendMail.DataAccess;
using BVNetwork.EPiSendMail.Plugin.ItemProviders;

namespace BVNetwork.EPiSendMail.Plugin.WorkItemProviders
{
public partial class TextRemoveProvider : System.Web.UI.UserControl, IWorkItemProvider
public partial class TextRemoveProvider : System.Web.UI.UserControl, IEmailImporterProvider
{
private IEmailImporter _importer;
private IShowFeedback _feedbackCtrl;

private Job _job;
private IJobUi _jobUi;

protected void Page_Load(object sender, EventArgs e)
{
// Do not do databind here - the container will do this for us
}

protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
}

protected void cmdRemoveCsvEmailAddresses_Click(object sender, EventArgs e)
{
string addresses = txtRemoveEmailWorkItems.Text;
if (string.IsNullOrEmpty(addresses))
{
_jobUi.ShowError("Please enter email addresses to remove.");
_feedbackCtrl.ShowError("Please enter email addresses to remove.");
return;
}

Expand All @@ -34,19 +32,14 @@ protected void cmdRemoveCsvEmailAddresses_Click(object sender, EventArgs e)
item.Delete();
}

// Construct log message
string message = "Removed email addresses";
_jobUi.ShowInfo(string.Format(message));
_feedbackCtrl.ShowInfo("Removed email addresses");
}

#region IWorkItemProvider Members

public void Initialize(BVNetwork.EPiSendMail.DataAccess.Job job, IJobUi jobUi)
public void Initialize(IEmailImporter importer, IShowFeedback feedbackUi)
{
_job = job;
_jobUi = jobUi;
_importer = importer;
_job = (Job) importer;
_feedbackCtrl = feedbackUi;
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<add name="EPiServerGroup"
displayName="Add email addresses from an EPiServer Group"
url="/modules/epicode.newsletter/plugin/itemproviders/EPiServerGroupProvider.ascx"/>
<add name="CommerceUsers"
displayName="Add email addresses from Commerce Contacts"
url="/modules/epicode.newsletter/plugin/itemproviders/CommerceUsersProvider.ascx"/>
</recipientListProviders>
</epicodeNewsletter>
</configuration>

0 comments on commit ac717ca

Please sign in to comment.