Skip to content

Commit 82805bf

Browse files
BeniGemperleBeniGemperle
authored andcommitted
Updated to Version 1.40 for nopCommerce 3.80
1 parent bea475f commit 82805bf

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

Description.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Group: Misc
22
FriendlyName: Razor MessageService
33
SystemName: ToSIC.RazorMessageService
4-
Version: 1.20
5-
SupportedVersions: 3.70
4+
Version: 1.40
5+
SupportedVersions: 3.80
66
Author: 2sic Internet Solutions
77
DisplayOrder: 1
88
FileName: ToSic.Nop.Plugins.RazorMessageService.dll

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.0.0")]
36-
[assembly: AssemblyFileVersion("1.3.0.0")]
35+
[assembly: AssemblyVersion("1.4.0.0")]
36+
[assembly: AssemblyFileVersion("1.4.0.0")]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Service.EmailAFriend | Store, Customer, Product, PersonalMessage, CustomerEmail
8585
ShipmentDelivered.CustomerNotification | Store, Shipment, Order, Customer
8686
ShipmentSent.CustomerNotification | Store, Shipment, Order, Customer
8787
VendorAccountApply.StoreOwnerNotification | Store, Customer, Vendor
88+
VendorInformationChange.StoreOwnerNotification | Store, Vendor
8889
Wishlist.EmailAFriend | Store, Customer, PersonalMessage, CustomerEmail
8990
9091
@@ -105,6 +106,9 @@ How to Install
105106
106107
Version
107108
----
109+
###1.40
110+
* Works with nopCommerce 3.80
111+
108112
###1.30
109113
* Works with nopCommerce 3.70
110114

RazorWorkflowMessageService.cs

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ protected virtual int SendNotification(MessageTemplate messageTemplate,
7979
string attachmentFilePath = null, string attachmentFileName = null,
8080
string replyToEmailAddress = null, string replyToName = null)
8181
{
82+
if (messageTemplate == null)
83+
throw new ArgumentNullException("messageTemplate");
84+
if (emailAccount == null)
85+
throw new ArgumentNullException("emailAccount");
86+
8287
//retrieve localized message template data
8388
var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
8489
var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
@@ -122,7 +127,9 @@ protected virtual int SendNotification(MessageTemplate messageTemplate,
122127
AttachmentFileName = attachmentFileName,
123128
AttachedDownloadId = messageTemplate.AttachedDownloadId,
124129
CreatedOnUtc = DateTime.UtcNow,
125-
EmailAccountId = emailAccount.Id
130+
EmailAccountId = emailAccount.Id,
131+
DontSendBeforeDateUtc = !messageTemplate.DelayBeforeSend.HasValue ? null
132+
: (DateTime?)(DateTime.UtcNow + TimeSpan.FromHours(messageTemplate.DelayPeriod.ToHours(messageTemplate.DelayBeforeSend.Value)))
126133
};
127134

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

172179
protected virtual EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate, int languageId)
173180
{
174-
var emailAccounId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
175-
var emailAccount = _emailAccountService.GetEmailAccountById(emailAccounId);
181+
var emailAccountId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
182+
//some 0 validation (for localizable "Email account" dropdownlist which saves 0 if "Standard" value is chosen)
183+
if (emailAccountId == 0)
184+
emailAccountId = messageTemplate.EmailAccountId;
185+
186+
var emailAccount = _emailAccountService.GetEmailAccountById(emailAccountId);
176187
if (emailAccount == null)
177188
emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
178189
if (emailAccount == null)
@@ -1308,7 +1319,7 @@ public int SendPrivateMessageNotification(PrivateMessage privateMessage, int lan
13081319
var store = _storeService.GetStoreById(privateMessage.StoreId) ?? _storeContext.CurrentStore;
13091320

13101321
var messageTemplate = GetActiveMessageTemplate("Customer.NewPM", store.Id);
1311-
if (messageTemplate == null)
1322+
if (messageTemplate == null )
13121323
{
13131324
return 0;
13141325
}
@@ -1379,6 +1390,43 @@ public virtual int SendNewVendorAccountApplyStoreOwnerNotification(Customer cust
13791390
toEmail, toName);
13801391
}
13811392

1393+
/// <summary>
1394+
/// Sends 'Vendor information changed' message to a store owner
1395+
/// </summary>
1396+
/// <param name="vendor">Vendor</param>
1397+
/// <param name="languageId">Message language identifier</param>
1398+
/// <returns>Queued email identifier</returns>
1399+
public virtual int SendVendorInformationChangeNotification(Vendor vendor, int languageId)
1400+
{
1401+
if (vendor == null)
1402+
throw new ArgumentNullException("vendor");
1403+
1404+
var store = _storeContext.CurrentStore;
1405+
languageId = EnsureLanguageIsActive(languageId, store.Id);
1406+
1407+
var messageTemplate = GetActiveMessageTemplate("VendorInformationChange.StoreOwnerNotification", store.Id);
1408+
if (messageTemplate == null)
1409+
return 0;
1410+
1411+
//email account
1412+
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);
1413+
1414+
//tokens
1415+
var tokens = new List<Token>();
1416+
_messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
1417+
_messageTokenProvider.AddVendorTokens(tokens, vendor);
1418+
1419+
//event notification
1420+
_eventPublisher.MessageTokensAdded(messageTemplate, tokens);
1421+
1422+
var toEmail = emailAccount.Email;
1423+
var toName = emailAccount.DisplayName;
1424+
return SendNotification(messageTemplate, emailAccount,
1425+
languageId, tokens,
1426+
new { Store = store, Vendor = vendor }, // customized
1427+
toEmail, toName);
1428+
}
1429+
13821430
/// <summary>
13831431
/// Sends a gift card notification
13841432
/// </summary>
@@ -1470,7 +1518,7 @@ public virtual int SendProductReviewNotificationMessage(ProductReview productRev
14701518
/// <returns>Queued email identifier</returns>
14711519
public virtual int SendQuantityBelowStoreOwnerNotification(Product product, int languageId)
14721520
{
1473-
if (product == null)
1521+
if (product== null)
14741522
throw new ArgumentNullException("product");
14751523

14761524
var store = _storeContext.CurrentStore;
@@ -1538,7 +1586,7 @@ public virtual int SendQuantityBelowStoreOwnerNotification(ProductAttributeCombi
15381586
}
15391587

15401588
/// <summary>
1541-
/// Sends a "new VAT sumitted" notification to a store owner
1589+
/// Sends a "new VAT submitted" notification to a store owner
15421590
/// </summary>
15431591
/// <param name="customer">Customer</param>
15441592
/// <param name="vatName">Received VAT name</param>

ToSic.Nop.Plugins.RazorMessageService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
<Private>False</Private>
4949
</Reference>
5050
<Reference Include="Nop.Core">
51-
<HintPath>..\nopCommerce_3.70_NoSource\bin\Nop.Core.dll</HintPath>
51+
<HintPath>..\nopCommerce_3.80_NoSource\bin\Nop.Core.dll</HintPath>
5252
<Private>False</Private>
5353
</Reference>
5454
<Reference Include="Nop.Services">
55-
<HintPath>..\nopCommerce_3.70_NoSource\bin\Nop.Services.dll</HintPath>
55+
<HintPath>..\nopCommerce_3.80_NoSource\bin\Nop.Services.dll</HintPath>
5656
<Private>False</Private>
5757
</Reference>
5858
<Reference Include="RazorEngine">

0 commit comments

Comments
 (0)