Skip to content

Commit

Permalink
Updated to Version 1.40 for nopCommerce 3.80
Browse files Browse the repository at this point in the history
  • Loading branch information
BeniGemperle authored and BeniGemperle committed Oct 25, 2016
1 parent bea475f commit 82805bf
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Description.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Group: Misc
FriendlyName: Razor MessageService
SystemName: ToSIC.RazorMessageService
Version: 1.20
SupportedVersions: 3.70
Version: 1.40
SupportedVersions: 3.80
Author: 2sic Internet Solutions
DisplayOrder: 1
FileName: ToSic.Nop.Plugins.RazorMessageService.dll
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Service.EmailAFriend | Store, Customer, Product, PersonalMessage, CustomerEmail
ShipmentDelivered.CustomerNotification | Store, Shipment, Order, Customer
ShipmentSent.CustomerNotification | Store, Shipment, Order, Customer
VendorAccountApply.StoreOwnerNotification | Store, Customer, Vendor
VendorInformationChange.StoreOwnerNotification | Store, Vendor
Wishlist.EmailAFriend | Store, Customer, PersonalMessage, CustomerEmail
Expand All @@ -105,6 +106,9 @@ How to Install
Version
----
###1.40
* Works with nopCommerce 3.80
###1.30
* Works with nopCommerce 3.70
Expand Down
60 changes: 54 additions & 6 deletions RazorWorkflowMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ protected virtual int SendNotification(MessageTemplate messageTemplate,
string attachmentFilePath = null, string attachmentFileName = null,
string replyToEmailAddress = null, string replyToName = null)
{
if (messageTemplate == null)
throw new ArgumentNullException("messageTemplate");
if (emailAccount == null)
throw new ArgumentNullException("emailAccount");

//retrieve localized message template data
var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
Expand Down Expand Up @@ -122,7 +127,9 @@ protected virtual int SendNotification(MessageTemplate messageTemplate,
AttachmentFileName = attachmentFileName,
AttachedDownloadId = messageTemplate.AttachedDownloadId,
CreatedOnUtc = DateTime.UtcNow,
EmailAccountId = emailAccount.Id
EmailAccountId = emailAccount.Id,
DontSendBeforeDateUtc = !messageTemplate.DelayBeforeSend.HasValue ? null
: (DateTime?)(DateTime.UtcNow + TimeSpan.FromHours(messageTemplate.DelayPeriod.ToHours(messageTemplate.DelayBeforeSend.Value)))
};

_queuedEmailService.InsertQueuedEmail(email);
Expand Down Expand Up @@ -171,8 +178,12 @@ protected virtual MessageTemplate GetActiveMessageTemplate(string messageTemplat

protected virtual EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate, int languageId)
{
var emailAccounId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
var emailAccount = _emailAccountService.GetEmailAccountById(emailAccounId);
var emailAccountId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
//some 0 validation (for localizable "Email account" dropdownlist which saves 0 if "Standard" value is chosen)
if (emailAccountId == 0)
emailAccountId = messageTemplate.EmailAccountId;

var emailAccount = _emailAccountService.GetEmailAccountById(emailAccountId);
if (emailAccount == null)
emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
if (emailAccount == null)
Expand Down Expand Up @@ -1308,7 +1319,7 @@ public int SendPrivateMessageNotification(PrivateMessage privateMessage, int lan
var store = _storeService.GetStoreById(privateMessage.StoreId) ?? _storeContext.CurrentStore;

var messageTemplate = GetActiveMessageTemplate("Customer.NewPM", store.Id);
if (messageTemplate == null)
if (messageTemplate == null )
{
return 0;
}
Expand Down Expand Up @@ -1379,6 +1390,43 @@ public virtual int SendNewVendorAccountApplyStoreOwnerNotification(Customer cust
toEmail, toName);
}

/// <summary>
/// Sends 'Vendor information changed' message to a store owner
/// </summary>
/// <param name="vendor">Vendor</param>
/// <param name="languageId">Message language identifier</param>
/// <returns>Queued email identifier</returns>
public virtual int SendVendorInformationChangeNotification(Vendor vendor, int languageId)
{
if (vendor == null)
throw new ArgumentNullException("vendor");

var store = _storeContext.CurrentStore;
languageId = EnsureLanguageIsActive(languageId, store.Id);

var messageTemplate = GetActiveMessageTemplate("VendorInformationChange.StoreOwnerNotification", store.Id);
if (messageTemplate == null)
return 0;

//email account
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);

//tokens
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
_messageTokenProvider.AddVendorTokens(tokens, vendor);

//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, tokens);

var toEmail = emailAccount.Email;
var toName = emailAccount.DisplayName;
return SendNotification(messageTemplate, emailAccount,
languageId, tokens,
new { Store = store, Vendor = vendor }, // customized
toEmail, toName);
}

/// <summary>
/// Sends a gift card notification
/// </summary>
Expand Down Expand Up @@ -1470,7 +1518,7 @@ public virtual int SendProductReviewNotificationMessage(ProductReview productRev
/// <returns>Queued email identifier</returns>
public virtual int SendQuantityBelowStoreOwnerNotification(Product product, int languageId)
{
if (product == null)
if (product== null)
throw new ArgumentNullException("product");

var store = _storeContext.CurrentStore;
Expand Down Expand Up @@ -1538,7 +1586,7 @@ public virtual int SendQuantityBelowStoreOwnerNotification(ProductAttributeCombi
}

/// <summary>
/// Sends a "new VAT sumitted" notification to a store owner
/// Sends a "new VAT submitted" notification to a store owner
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="vatName">Received VAT name</param>
Expand Down
4 changes: 2 additions & 2 deletions ToSic.Nop.Plugins.RazorMessageService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
<Private>False</Private>
</Reference>
<Reference Include="Nop.Core">
<HintPath>..\nopCommerce_3.70_NoSource\bin\Nop.Core.dll</HintPath>
<HintPath>..\nopCommerce_3.80_NoSource\bin\Nop.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Nop.Services">
<HintPath>..\nopCommerce_3.70_NoSource\bin\Nop.Services.dll</HintPath>
<HintPath>..\nopCommerce_3.80_NoSource\bin\Nop.Services.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RazorEngine">
Expand Down

0 comments on commit 82805bf

Please sign in to comment.