2022-03-15 18:00:53 +00:00
|
|
|
// (c) Copyright Ascensio System SIA 2010-2022
|
|
|
|
//
|
|
|
|
// This program is a free software product.
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
// any third-party rights.
|
|
|
|
//
|
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
|
|
|
//
|
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
|
|
|
//
|
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
// trademark law for use of our trademarks.
|
|
|
|
//
|
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
using ASC.Common.Log;
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
namespace ASC.Web.Studio.Core.Notify;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
[Scope]
|
2022-03-17 15:13:38 +00:00
|
|
|
public class StudioPeriodicNotify
|
2020-10-19 15:53:15 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
private readonly NotifyEngineQueue _notifyEngineQueue;
|
|
|
|
private readonly WorkContext _workContext;
|
|
|
|
private readonly TenantManager _tenantManager;
|
|
|
|
private readonly UserManager _userManager;
|
|
|
|
private readonly StudioNotifyHelper _studioNotifyHelper;
|
|
|
|
private readonly PaymentManager _paymentManager;
|
|
|
|
private readonly TenantExtra _tenantExtra;
|
|
|
|
private readonly AuthContext _authContext;
|
|
|
|
private readonly CommonLinkUtility _commonLinkUtility;
|
|
|
|
private readonly ApiSystemHelper _apiSystemHelper;
|
|
|
|
private readonly SetupInfo _setupInfo;
|
|
|
|
private readonly DbContextManager<FeedDbContext> _dbContextManager;
|
|
|
|
private readonly CouponManager _couponManager;
|
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
private readonly SettingsManager _settingsManager;
|
|
|
|
private readonly CoreBaseSettings _coreBaseSettings;
|
|
|
|
private readonly DisplayUserSettingsHelper _displayUserSettingsHelper;
|
|
|
|
private readonly AuthManager _authManager;
|
|
|
|
private readonly SecurityContext _securityContext;
|
2022-04-26 17:53:48 +00:00
|
|
|
private readonly ILogger _log;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
public StudioPeriodicNotify(
|
2022-04-26 17:53:48 +00:00
|
|
|
ILoggerProvider log,
|
2022-04-14 19:42:15 +00:00
|
|
|
NotifyEngineQueue notifyEngineQueue,
|
|
|
|
WorkContext workContext,
|
|
|
|
TenantManager tenantManager,
|
|
|
|
UserManager userManager,
|
|
|
|
StudioNotifyHelper studioNotifyHelper,
|
|
|
|
PaymentManager paymentManager,
|
|
|
|
TenantExtra tenantExtra,
|
|
|
|
AuthContext authContext,
|
|
|
|
CommonLinkUtility commonLinkUtility,
|
|
|
|
ApiSystemHelper apiSystemHelper,
|
|
|
|
SetupInfo setupInfo,
|
|
|
|
DbContextManager<FeedDbContext> dbContextManager,
|
|
|
|
CouponManager couponManager,
|
|
|
|
IConfiguration configuration,
|
|
|
|
SettingsManager settingsManager,
|
|
|
|
CoreBaseSettings coreBaseSettings,
|
|
|
|
DisplayUserSettingsHelper displayUserSettingsHelper,
|
|
|
|
AuthManager authManager,
|
|
|
|
SecurityContext securityContext)
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
_notifyEngineQueue = notifyEngineQueue;
|
|
|
|
_workContext = workContext;
|
|
|
|
_tenantManager = tenantManager;
|
|
|
|
_userManager = userManager;
|
|
|
|
_studioNotifyHelper = studioNotifyHelper;
|
|
|
|
_paymentManager = paymentManager;
|
|
|
|
_tenantExtra = tenantExtra;
|
|
|
|
_authContext = authContext;
|
|
|
|
_commonLinkUtility = commonLinkUtility;
|
|
|
|
_apiSystemHelper = apiSystemHelper;
|
|
|
|
_setupInfo = setupInfo;
|
|
|
|
_dbContextManager = dbContextManager;
|
|
|
|
_couponManager = couponManager;
|
|
|
|
_configuration = configuration;
|
|
|
|
_settingsManager = settingsManager;
|
|
|
|
_coreBaseSettings = coreBaseSettings;
|
|
|
|
_displayUserSettingsHelper = displayUserSettingsHelper;
|
|
|
|
_authManager = authManager;
|
|
|
|
_securityContext = securityContext;
|
2022-04-26 17:53:48 +00:00
|
|
|
_log = log.CreateLogger("ASC.Notify");
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
public Task SendSaasLettersAsync(string senderName, DateTime scheduleDate)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationStartSendSaasTariffLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var activeTenants = _tenantManager.GetTenants().ToList();
|
|
|
|
|
|
|
|
if (activeTenants.Count <= 0)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendSaasTariffLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
2022-02-25 17:16:00 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
return InternalSendSaasLettersAsync(senderName, scheduleDate, activeTenants);
|
|
|
|
}
|
2022-02-16 12:57:37 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
private async Task InternalSendSaasLettersAsync(string senderName, DateTime scheduleDate, List<Tenant> activeTenants)
|
|
|
|
{
|
|
|
|
var nowDate = scheduleDate.Date;
|
2020-07-30 13:33:54 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
foreach (var tenant in activeTenants)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
_tenantManager.SetCurrentTenant(tenant.Id);
|
|
|
|
var client = _workContext.NotifyContext.RegisterClient(_notifyEngineQueue, _studioNotifyHelper.NotifySource);
|
|
|
|
|
|
|
|
var tariff = _paymentManager.GetTariff(tenant.Id);
|
|
|
|
var quota = _tenantManager.GetTenantQuota(tenant.Id);
|
2022-03-17 15:13:38 +00:00
|
|
|
var createdDate = tenant.CreationDateTime.Date;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var dueDateIsNotMax = tariff.DueDate != DateTime.MaxValue;
|
|
|
|
var dueDate = tariff.DueDate.Date;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var delayDueDateIsNotMax = tariff.DelayDueDate != DateTime.MaxValue;
|
|
|
|
var delayDueDate = tariff.DelayDueDate.Date;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
INotifyAction action = null;
|
|
|
|
var paymentMessage = true;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var toadmins = false;
|
|
|
|
var tousers = false;
|
|
|
|
var toowner = false;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var coupon = string.Empty;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> greenButtonText = () => string.Empty;
|
|
|
|
|
|
|
|
string blueButtonText() => WebstudioNotifyPatternResource.ButtonRequestCallButton;
|
|
|
|
var greenButtonUrl = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemText1 = () => string.Empty;
|
|
|
|
Func<string> tableItemText2 = () => string.Empty;
|
|
|
|
Func<string> tableItemText3 = () => string.Empty;
|
|
|
|
Func<string> tableItemText4 = () => string.Empty;
|
|
|
|
Func<string> tableItemText5 = () => string.Empty;
|
|
|
|
Func<string> tableItemText6 = () => string.Empty;
|
|
|
|
Func<string> tableItemText7 = () => string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemUrl1 = string.Empty;
|
|
|
|
var tableItemUrl2 = string.Empty;
|
|
|
|
var tableItemUrl3 = string.Empty;
|
|
|
|
var tableItemUrl4 = string.Empty;
|
|
|
|
var tableItemUrl5 = string.Empty;
|
|
|
|
var tableItemUrl6 = string.Empty;
|
|
|
|
var tableItemUrl7 = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemImg1 = string.Empty;
|
|
|
|
var tableItemImg2 = string.Empty;
|
|
|
|
var tableItemImg3 = string.Empty;
|
|
|
|
var tableItemImg4 = string.Empty;
|
|
|
|
var tableItemImg5 = string.Empty;
|
|
|
|
var tableItemImg6 = string.Empty;
|
|
|
|
var tableItemImg7 = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemComment1 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment2 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment3 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment4 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment5 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment6 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment7 = () => string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemLearnMoreText1 = () => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText2() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText3() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText4() => string.Empty;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
string tableItemLearnMoreText5() => string.Empty;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
string tableItemLearnMoreText6() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText7() => string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemLearnMoreUrl1 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl2 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl3 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl4 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl5 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl6 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl7 = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
if (quota.Free)
|
|
|
|
{
|
|
|
|
#region Free tariff every 2 months during 1 year
|
|
|
|
|
|
|
|
if (createdDate.AddMonths(2) == nowDate || createdDate.AddMonths(4) == nowDate || createdDate.AddMonths(6) == nowDate || createdDate.AddMonths(8) == nowDate || createdDate.AddMonths(10) == nowDate || createdDate.AddMonths(12) == nowDate)
|
2021-05-24 17:41:31 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
action = Actions.SaasAdminPaymentWarningEvery2MonthsV115;
|
|
|
|
toadmins = true;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonUseDiscount;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/Tariffs.aspx");
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
else if (quota.Trial)
|
|
|
|
{
|
|
|
|
#region After registration letters
|
|
|
|
|
|
|
|
#region 1 days after registration to admins SAAS TRIAL
|
|
|
|
|
|
|
|
if (createdDate.AddDays(1) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminModulesV115;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonAccessYouWebOffice;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = $"{_commonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')}/";
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 4 days after registration to admins SAAS TRIAL
|
|
|
|
|
|
|
|
else if (createdDate.AddDays(4) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminComfortTipsV115;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonUseDiscount;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/Tariffs.aspx");
|
2021-05-24 17:41:31 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 7 days after registration to admins and users SAAS TRIAL
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (createdDate.AddDays(7) == nowDate)
|
2021-05-24 17:41:31 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
action = Actions.SaasAdminUserDocsTipsV115;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
tousers = true;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg1 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-formatting-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText1 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_formatting_hdr;
|
|
|
|
tableItemComment1 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_formatting;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
if (!_coreBaseSettings.CustomMode)
|
2021-05-24 17:41:31 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemLearnMoreUrl1 = _studioNotifyHelper.Helplink + "/onlyoffice-editors/index.aspx";
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemLearnMoreText1 = () => WebstudioNotifyPatternResource.LinkLearnMore;
|
2021-05-24 17:41:31 +00:00
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg2 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-share-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText2 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_share_hdr;
|
|
|
|
tableItemComment2 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_share;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg3 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-coediting-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText3 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_coediting_hdr;
|
|
|
|
tableItemComment3 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_coediting;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg4 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-review-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText4 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_review_hdr;
|
|
|
|
tableItemComment4 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_review;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg5 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-modules-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText5 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_contentcontrols_hdr;
|
|
|
|
tableItemComment5 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_contentcontrols;
|
2020-09-11 14:12:35 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg6 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-customize-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText6 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_spreadsheets_hdr;
|
|
|
|
tableItemComment6 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_spreadsheets;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg7 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-attach-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText7 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_differences_hdr;
|
|
|
|
tableItemComment7 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_differences;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonAccessYouWebOffice;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = $"{_commonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')}/products/files/";
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 14 days after registration to admins and users SAAS TRIAL
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (createdDate.AddDays(14) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminUserAppsTipsV115;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
tousers = true;
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region Trial warning letters
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 5 days before SAAS TRIAL ends to admins
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
else if (!_coreBaseSettings.CustomMode && dueDateIsNotMax && dueDate.AddDays(-5) == nowDate)
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
toadmins = true;
|
|
|
|
action = Actions.SaasAdminTrialWarningBefore5V115;
|
|
|
|
coupon = "PortalCreation10%";
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (string.IsNullOrEmpty(coupon))
|
2021-05-24 17:41:31 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
try
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationStartCreateCoupon(tenant.Alias);
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
coupon = SetupInfo.IsSecretEmail(_userManager.GetUsers(tenant.OwnerId).Email)
|
|
|
|
? tenant.Alias
|
|
|
|
: _couponManager.CreateCoupon(_tenantManager);
|
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndCreateCoupon(tenant.Alias, coupon);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
catch (AggregateException ae)
|
|
|
|
{
|
|
|
|
foreach (var ex in ae.InnerExceptions)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorWithException(ex);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendSaasLettersAsync(ex);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2021-05-24 17:41:31 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonUseDiscount;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/tariffs.aspx");
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region SAAS TRIAL expires today to admins
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (dueDate == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminTrialWarningV115;
|
|
|
|
toadmins = true;
|
2021-05-24 17:41:31 +00:00
|
|
|
}
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 1 day after SAAS TRIAL expired to admins
|
|
|
|
|
|
|
|
if (dueDateIsNotMax && dueDate.AddDays(1) == nowDate)
|
2022-03-17 15:01:39 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
action = Actions.SaasAdminTrialWarningAfter1V115;
|
|
|
|
toadmins = true;
|
|
|
|
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonRenewNow;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/Tariffs.aspx");
|
2022-03-17 15:01:39 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 6 months after SAAS TRIAL expired
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (dueDateIsNotMax && dueDate.AddMonths(6) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminTrialWarningAfterHalfYearV115;
|
|
|
|
toowner = true;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonLeaveFeedback;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var owner = _userManager.GetUsers(tenant.OwnerId);
|
|
|
|
greenButtonUrl = _setupInfo.TeamlabSiteRedirect + "/remove-portal-feedback-form.aspx#" +
|
2022-04-15 09:08:06 +00:00
|
|
|
HttpUtility.UrlEncode(Convert.ToBase64String(
|
|
|
|
Encoding.UTF8.GetBytes("{\"firstname\":\"" + owner.FirstName +
|
2022-04-14 19:42:15 +00:00
|
|
|
"\",\"lastname\":\"" + owner.LastName +
|
|
|
|
"\",\"alias\":\"" + tenant.Alias +
|
|
|
|
"\",\"email\":\"" + owner.Email + "\"}")));
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
else if (dueDateIsNotMax && dueDate.AddMonths(6).AddDays(7) <= nowDate)
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
_tenantManager.RemoveTenant(tenant.Id, true);
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_apiSystemHelper.ApiCacheUrl))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
await _apiSystemHelper.RemoveTenantFromCacheAsync(tenant.Alias, _authContext.CurrentAccount.ID);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (tariff.State >= TariffState.Paid)
|
|
|
|
{
|
|
|
|
#region Payment warning letters
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 6 months after SAAS PAID expired
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (tariff.State == TariffState.NotPaid && dueDateIsNotMax && dueDate.AddMonths(6) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.SaasAdminTrialWarningAfterHalfYearV115;
|
|
|
|
toowner = true;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonLeaveFeedback;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var owner = _userManager.GetUsers(tenant.OwnerId);
|
|
|
|
greenButtonUrl = _setupInfo.TeamlabSiteRedirect + "/remove-portal-feedback-form.aspx#" +
|
2022-04-15 09:08:06 +00:00
|
|
|
HttpUtility.UrlEncode(Convert.ToBase64String(
|
|
|
|
Encoding.UTF8.GetBytes("{\"firstname\":\"" + owner.FirstName +
|
2022-04-14 19:42:15 +00:00
|
|
|
"\",\"lastname\":\"" + owner.LastName +
|
|
|
|
"\",\"alias\":\"" + tenant.Alias +
|
|
|
|
"\",\"email\":\"" + owner.Email + "\"}")));
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
else if (tariff.State == TariffState.NotPaid && dueDateIsNotMax && dueDate.AddMonths(6).AddDays(7) <= nowDate)
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
_tenantManager.RemoveTenant(tenant.Id, true);
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_apiSystemHelper.ApiCacheUrl))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
await _apiSystemHelper.RemoveTenantFromCacheAsync(tenant.Alias, _authContext.CurrentAccount.ID);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (action == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var users = toowner
|
2022-03-29 15:39:09 +00:00
|
|
|
? new List<UserInfo> { _userManager.GetUsers(tenant.OwnerId) }
|
2022-04-14 19:42:15 +00:00
|
|
|
: _studioNotifyHelper.GetRecipients(toadmins, tousers, false);
|
|
|
|
|
|
|
|
foreach (var u in users.Where(u => paymentMessage || _studioNotifyHelper.IsSubscribedToNotify(u, Actions.PeriodicNotify)))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
|
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
2022-04-14 19:42:15 +00:00
|
|
|
var rquota = _tenantExtra.GetRightQuota() ?? TenantQuota.Default;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
2022-03-29 15:39:09 +00:00
|
|
|
new[] { _studioNotifyHelper.ToRecipient(u.Id) },
|
2022-03-17 15:13:38 +00:00
|
|
|
new[] { senderName },
|
|
|
|
new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
|
2022-03-29 15:39:09 +00:00
|
|
|
new TagValue(Tags.PricingPage, _commonLinkUtility.GetFullAbsolutePath("~/tariffs.aspx")),
|
|
|
|
new TagValue(Tags.ActiveUsers, _userManager.GetUsers().Length),
|
2022-03-17 15:13:38 +00:00
|
|
|
new TagValue(Tags.Price, rquota.Price),
|
|
|
|
new TagValue(Tags.PricePeriod, rquota.Year3 ? UserControlsCommonResource.TariffPerYear3 : rquota.Year ? UserControlsCommonResource.TariffPerYear : UserControlsCommonResource.TariffPerMonth),
|
|
|
|
new TagValue(Tags.DueDate, dueDate.ToLongDateString()),
|
|
|
|
new TagValue(Tags.DelayDueDate, (delayDueDateIsNotMax ? delayDueDate : dueDate).ToLongDateString()),
|
|
|
|
TagValues.BlueButton(blueButtonText, "http://www.onlyoffice.com/call-back-form.aspx"),
|
|
|
|
TagValues.GreenButton(greenButtonText, greenButtonUrl),
|
|
|
|
TagValues.TableTop(),
|
|
|
|
TagValues.TableItem(1, tableItemText1, tableItemUrl1, tableItemImg1, tableItemComment1, tableItemLearnMoreText1, tableItemLearnMoreUrl1),
|
|
|
|
TagValues.TableItem(2, tableItemText2, tableItemUrl2, tableItemImg2, tableItemComment2, tableItemLearnMoreText2, tableItemLearnMoreUrl2),
|
|
|
|
TagValues.TableItem(3, tableItemText3, tableItemUrl3, tableItemImg3, tableItemComment3, tableItemLearnMoreText3, tableItemLearnMoreUrl3),
|
|
|
|
TagValues.TableItem(4, tableItemText4, tableItemUrl4, tableItemImg4, tableItemComment4, tableItemLearnMoreText4, tableItemLearnMoreUrl4),
|
|
|
|
TagValues.TableItem(5, tableItemText5, tableItemUrl5, tableItemImg5, tableItemComment5, tableItemLearnMoreText5, tableItemLearnMoreUrl5),
|
|
|
|
TagValues.TableItem(6, tableItemText6, tableItemUrl6, tableItemImg6, tableItemComment6, tableItemLearnMoreText6, tableItemLearnMoreUrl6),
|
|
|
|
TagValues.TableItem(7, tableItemText7, tableItemUrl7, tableItemImg7, tableItemComment7, tableItemLearnMoreText7, tableItemLearnMoreUrl7),
|
|
|
|
TagValues.TableBottom(),
|
2022-03-29 15:39:09 +00:00
|
|
|
new TagValue(CommonTags.Footer, u.IsAdmin(_userManager) ? "common" : "social"),
|
2022-03-17 15:13:38 +00:00
|
|
|
new TagValue(Tags.Coupon, coupon));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendSaasLettersAsync(err);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2020-07-30 13:33:54 +00:00
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendSaasTariffLetters();
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2020-09-30 12:46:16 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
public void SendEnterpriseLetters(string senderName, DateTime scheduleDate)
|
|
|
|
{
|
|
|
|
var nowDate = scheduleDate.Date;
|
|
|
|
const string dbid = "webstudio";
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationStartSendTariffEnterpriseLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var activeTenants = _tenantManager.GetTenants().ToList();
|
|
|
|
|
|
|
|
if (activeTenants.Count <= 0)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendTariffEnterpriseLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
foreach (var tenant in activeTenants)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(_settingsManager);
|
|
|
|
_tenantManager.SetCurrentTenant(tenant.Id);
|
|
|
|
var client = _workContext.NotifyContext.RegisterClient(_notifyEngineQueue, _studioNotifyHelper.NotifySource);
|
|
|
|
|
|
|
|
var tariff = _paymentManager.GetTariff(tenant.Id);
|
|
|
|
var quota = _tenantManager.GetTenantQuota(tenant.Id);
|
2022-03-17 15:13:38 +00:00
|
|
|
var createdDate = tenant.CreationDateTime.Date;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var actualEndDate = tariff.DueDate != DateTime.MaxValue ? tariff.DueDate : tariff.LicenseDate;
|
|
|
|
var dueDateIsNotMax = actualEndDate != DateTime.MaxValue;
|
|
|
|
var dueDate = actualEndDate.Date;
|
2020-02-17 08:58:14 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var delayDueDateIsNotMax = tariff.DelayDueDate != DateTime.MaxValue;
|
|
|
|
var delayDueDate = tariff.DelayDueDate.Date;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
INotifyAction action = null;
|
|
|
|
var paymentMessage = true;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var toadmins = false;
|
|
|
|
var tousers = false;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> greenButtonText = () => string.Empty;
|
|
|
|
|
|
|
|
string blueButtonText() => WebstudioNotifyPatternResource.ButtonRequestCallButton;
|
|
|
|
var greenButtonUrl = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemText1 = () => string.Empty;
|
|
|
|
Func<string> tableItemText2 = () => string.Empty;
|
|
|
|
Func<string> tableItemText3 = () => string.Empty;
|
|
|
|
Func<string> tableItemText4 = () => string.Empty;
|
|
|
|
Func<string> tableItemText5 = () => string.Empty;
|
|
|
|
Func<string> tableItemText6 = () => string.Empty;
|
|
|
|
Func<string> tableItemText7 = () => string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemUrl1 = string.Empty;
|
|
|
|
var tableItemUrl2 = string.Empty;
|
|
|
|
var tableItemUrl3 = string.Empty;
|
|
|
|
var tableItemUrl4 = string.Empty;
|
|
|
|
var tableItemUrl5 = string.Empty;
|
|
|
|
var tableItemUrl6 = string.Empty;
|
|
|
|
var tableItemUrl7 = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemImg1 = string.Empty;
|
|
|
|
var tableItemImg2 = string.Empty;
|
|
|
|
var tableItemImg3 = string.Empty;
|
|
|
|
var tableItemImg4 = string.Empty;
|
|
|
|
var tableItemImg5 = string.Empty;
|
|
|
|
var tableItemImg6 = string.Empty;
|
|
|
|
var tableItemImg7 = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemComment1 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment2 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment3 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment4 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment5 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment6 = () => string.Empty;
|
|
|
|
Func<string> tableItemComment7 = () => string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Func<string> tableItemLearnMoreText1 = () => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText2() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText3() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText4() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText5() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText6() => string.Empty;
|
|
|
|
|
|
|
|
string tableItemLearnMoreText7() => string.Empty;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var tableItemLearnMoreUrl1 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl2 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl3 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl4 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl5 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl6 = string.Empty;
|
|
|
|
var tableItemLearnMoreUrl7 = string.Empty;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (quota.Trial && defaultRebranding)
|
|
|
|
{
|
|
|
|
#region After registration letters
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 1 day after registration to admins ENTERPRISE TRIAL + defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (createdDate.AddDays(1) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminCustomizePortalV10;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg1 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-brand-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText1 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_brand_hdr;
|
|
|
|
tableItemComment1 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_brand;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg2 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-regional-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText2 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_regional_hdr;
|
|
|
|
tableItemComment2 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_regional;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg3 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-customize-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText3 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_customize_hdr;
|
|
|
|
tableItemComment3 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_customize;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg4 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-modules-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText4 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_modules_hdr;
|
|
|
|
tableItemComment4 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_modules;
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg5 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-3rdparty-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText5 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_3rdparty_hdr;
|
|
|
|
tableItemComment5 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_3rdparty;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonConfigureRightNow;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath(_commonLinkUtility.GetAdministration(ManagementType.General));
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 4 days after registration to admins ENTERPRISE TRIAL + only 1 user + defaultRebranding
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
else if (createdDate.AddDays(4) == nowDate && _userManager.GetUsers().Length == 1)
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminInviteTeammatesV10;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonInviteRightNow;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = $"{_commonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')}/products/people/";
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 5 days after registration to admins ENTERPRISE TRAIL + without activity in 1 or more days + defaultRebranding
|
2020-02-17 08:58:14 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (createdDate.AddDays(5) == nowDate)
|
|
|
|
{
|
|
|
|
List<DateTime> datesWithActivity;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
datesWithActivity =
|
2022-03-29 15:39:09 +00:00
|
|
|
_dbContextManager.Get(dbid).FeedAggregates
|
|
|
|
.Where(r => r.Tenant == _tenantManager.GetCurrentTenant().Id)
|
2022-03-17 15:13:38 +00:00
|
|
|
.Where(r => r.CreatedDate <= nowDate.AddDays(-1))
|
|
|
|
.GroupBy(r => r.CreatedDate.Date)
|
|
|
|
.Select(r => r.Key)
|
|
|
|
.ToList();
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (datesWithActivity.Count < 5)
|
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminWithoutActivityV10;
|
2021-05-24 17:41:31 +00:00
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 7 days after registration to admins and users ENTERPRISE TRIAL + defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (createdDate.AddDays(7) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminUserDocsTipsV10;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
tousers = true;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg1 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-formatting-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText1 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_formatting_hdr;
|
|
|
|
tableItemComment1 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_formatting;
|
2021-05-24 17:41:31 +00:00
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
if (!_coreBaseSettings.CustomMode)
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemLearnMoreUrl1 = _studioNotifyHelper.Helplink + "/onlyoffice-editors/index.aspx";
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemLearnMoreText1 = () => WebstudioNotifyPatternResource.LinkLearnMore;
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg2 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-share-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText2 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_share_hdr;
|
|
|
|
tableItemComment2 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_share;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg3 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-coediting-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText3 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_coediting_hdr;
|
|
|
|
tableItemComment3 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_coediting;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg4 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-review-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText4 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_review_hdr;
|
|
|
|
tableItemComment4 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_review;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg5 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-3rdparty-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText5 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_3rdparty_hdr;
|
|
|
|
tableItemComment5 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_3rdparty;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg6 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-attach-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText6 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_attach_hdr;
|
|
|
|
tableItemComment6 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_attach;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg7 = _studioNotifyHelper.GetNotificationImageUrl("tips-documents-apps-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText7 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_apps_hdr;
|
|
|
|
tableItemComment7 = () => WebstudioNotifyPatternResource.pattern_saas_admin_user_docs_tips_v115_item_apps;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonAccessYouWebOffice;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = $"{_commonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')}/products/files/";
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 21 days after registration to admins and users ENTERPRISE TRIAL + defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (createdDate.AddDays(21) == nowDate)
|
2022-03-17 15:01:39 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
action = Actions.EnterpriseAdminUserAppsTipsV10;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
|
|
|
tousers = true;
|
2022-03-17 15:01:39 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region Trial warning letters
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 7 days before ENTERPRISE TRIAL ends to admins + defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (dueDateIsNotMax && dueDate.AddDays(-7) == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminTrialWarningBefore7V10;
|
|
|
|
toadmins = true;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonSelectPricingPlans;
|
|
|
|
greenButtonUrl = "http://www.onlyoffice.com/enterprise-edition.aspx";
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region ENTERPRISE TRIAL expires today to admins + defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (dueDate == nowDate)
|
|
|
|
{
|
|
|
|
action = Actions.EnterpriseAdminTrialWarningV10;
|
|
|
|
toadmins = true;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
else if (quota.Trial && !defaultRebranding)
|
|
|
|
{
|
2019-06-14 16:14:24 +00:00
|
|
|
#region After registration letters
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 1 day after registration to admins ENTERPRISE TRIAL + !defaultRebranding
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (createdDate.AddDays(1) == nowDate)
|
2020-09-18 14:45:59 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
action = Actions.EnterpriseWhitelabelAdminCustomizePortalV10;
|
|
|
|
paymentMessage = false;
|
|
|
|
toadmins = true;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg1 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-brand-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText1 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_brand_hdr;
|
|
|
|
tableItemComment1 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_brand;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg2 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-regional-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText2 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_regional_hdr;
|
|
|
|
tableItemComment2 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_regional;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg3 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-customize-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText3 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_customize_hdr;
|
|
|
|
tableItemComment3 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_customize;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
tableItemImg4 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-modules-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText4 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_modules_hdr;
|
|
|
|
tableItemComment4 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_modules;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
if (!_coreBaseSettings.CustomMode)
|
2020-09-18 14:45:59 +00:00
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
tableItemImg5 = _studioNotifyHelper.GetNotificationImageUrl("tips-customize-3rdparty-100.png");
|
2022-03-17 15:13:38 +00:00
|
|
|
tableItemText5 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_3rdparty_hdr;
|
|
|
|
tableItemComment5 = () => WebstudioNotifyPatternResource.pattern_enterprise_admin_customize_portal_v10_item_3rdparty;
|
2020-09-18 14:45:59 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonConfigureRightNow;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath(_commonLinkUtility.GetAdministration(ManagementType.General));
|
2020-09-18 14:45:59 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
else if (tariff.State == TariffState.Paid)
|
|
|
|
{
|
|
|
|
#region Payment warning letters
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 7 days before ENTERPRISE PAID expired to admins
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (dueDateIsNotMax && dueDate.AddDays(-7) == nowDate)
|
|
|
|
{
|
|
|
|
action = defaultRebranding
|
|
|
|
? Actions.EnterpriseAdminPaymentWarningBefore7V10
|
|
|
|
: Actions.EnterpriseWhitelabelAdminPaymentWarningBefore7V10;
|
|
|
|
toadmins = true;
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonSelectPricingPlans;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/tariffs.aspx");
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region ENTERPRISE PAID expires today to admins
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
else if (dueDate == nowDate)
|
|
|
|
{
|
|
|
|
action = defaultRebranding
|
|
|
|
? Actions.EnterpriseAdminPaymentWarningV10
|
|
|
|
: Actions.EnterpriseWhitelabelAdminPaymentWarningV10;
|
|
|
|
toadmins = true;
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonSelectPricingPlans;
|
2022-04-14 19:42:15 +00:00
|
|
|
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/tariffs.aspx");
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#endregion
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (action == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var users = _studioNotifyHelper.GetRecipients(toadmins, tousers, false);
|
|
|
|
|
|
|
|
foreach (var u in users.Where(u => paymentMessage || _studioNotifyHelper.IsSubscribedToNotify(u, Actions.PeriodicNotify)))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
|
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var rquota = _tenantExtra.GetRightQuota() ?? TenantQuota.Default;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
2022-03-29 15:39:09 +00:00
|
|
|
new[] { _studioNotifyHelper.ToRecipient(u.Id) },
|
2022-03-17 15:13:38 +00:00
|
|
|
new[] { senderName },
|
|
|
|
new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
|
2022-03-29 15:39:09 +00:00
|
|
|
new TagValue(Tags.PricingPage, _commonLinkUtility.GetFullAbsolutePath("~/tariffs.aspx")),
|
|
|
|
new TagValue(Tags.ActiveUsers, _userManager.GetUsers().Length),
|
2022-03-17 15:13:38 +00:00
|
|
|
new TagValue(Tags.Price, rquota.Price),
|
|
|
|
new TagValue(Tags.PricePeriod, rquota.Year3 ? UserControlsCommonResource.TariffPerYear3 : rquota.Year ? UserControlsCommonResource.TariffPerYear : UserControlsCommonResource.TariffPerMonth),
|
|
|
|
new TagValue(Tags.DueDate, dueDate.ToLongDateString()),
|
|
|
|
new TagValue(Tags.DelayDueDate, (delayDueDateIsNotMax ? delayDueDate : dueDate).ToLongDateString()),
|
|
|
|
TagValues.BlueButton(blueButtonText, "http://www.onlyoffice.com/call-back-form.aspx"),
|
|
|
|
TagValues.GreenButton(greenButtonText, greenButtonUrl),
|
|
|
|
TagValues.TableTop(),
|
|
|
|
TagValues.TableItem(1, tableItemText1, tableItemUrl1, tableItemImg1, tableItemComment1, tableItemLearnMoreText1, tableItemLearnMoreUrl1),
|
|
|
|
TagValues.TableItem(2, tableItemText2, tableItemUrl2, tableItemImg2, tableItemComment2, tableItemLearnMoreText2, tableItemLearnMoreUrl2),
|
|
|
|
TagValues.TableItem(3, tableItemText3, tableItemUrl3, tableItemImg3, tableItemComment3, tableItemLearnMoreText3, tableItemLearnMoreUrl3),
|
|
|
|
TagValues.TableItem(4, tableItemText4, tableItemUrl4, tableItemImg4, tableItemComment4, tableItemLearnMoreText4, tableItemLearnMoreUrl4),
|
|
|
|
TagValues.TableItem(5, tableItemText5, tableItemUrl5, tableItemImg5, tableItemComment5, tableItemLearnMoreText5, tableItemLearnMoreUrl5),
|
|
|
|
TagValues.TableItem(6, tableItemText6, tableItemUrl6, tableItemImg6, tableItemComment6, tableItemLearnMoreText6, tableItemLearnMoreUrl6),
|
|
|
|
TagValues.TableItem(7, tableItemText7, tableItemUrl7, tableItemImg7, tableItemComment7, tableItemLearnMoreText7, tableItemLearnMoreUrl7),
|
|
|
|
TagValues.TableBottom());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendEnterpriseLetters(err);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendTariffEnterpriseLetters();
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
public void SendOpensourceLetters(string senderName, DateTime scheduleDate)
|
2020-08-24 18:41:06 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
var nowDate = scheduleDate.Date;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationStartSendOpensourceTariffLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var activeTenants = _tenantManager.GetTenants().ToList();
|
|
|
|
|
|
|
|
if (activeTenants.Count <= 0)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendOpensourceTariffLetters();
|
2022-04-14 19:42:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
foreach (var tenant in activeTenants)
|
2020-08-31 08:18:07 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
try
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
_tenantManager.SetCurrentTenant(tenant.Id);
|
|
|
|
var client = _workContext.NotifyContext.RegisterClient(_notifyEngineQueue, _studioNotifyHelper.NotifySource);
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var createdDate = tenant.CreationDateTime.Date;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region After registration letters
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
#region 5 days after registration to admins
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (createdDate.AddDays(5) == nowDate)
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
var users = _studioNotifyHelper.GetRecipients(true, true, false);
|
2022-03-17 15:13:38 +00:00
|
|
|
|
|
|
|
|
2022-04-14 19:42:15 +00:00
|
|
|
foreach (var u in users.Where(u => _studioNotifyHelper.IsSubscribedToNotify(u, Actions.PeriodicNotify)))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
|
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
2022-03-29 15:39:09 +00:00
|
|
|
u.IsAdmin(_userManager) ? Actions.OpensourceAdminDocsTipsV11 : Actions.OpensourceUserDocsTipsV11,
|
|
|
|
new[] { _studioNotifyHelper.ToRecipient(u.Id) },
|
2022-03-17 15:13:38 +00:00
|
|
|
new[] { senderName },
|
2022-03-29 15:39:09 +00:00
|
|
|
new TagValue(Tags.UserName, u.DisplayUserName(_displayUserSettingsHelper)),
|
2022-03-17 15:13:38 +00:00
|
|
|
new TagValue(CommonTags.Footer, "opensource"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendOpensourceLetters(err);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2020-08-31 08:18:07 +00:00
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendOpensourceTariffLetters();
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
public void SendPersonalLetters(string senderName, DateTime scheduleDate)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationStartSendLettersPersonal();
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var activeTenants = _tenantManager.GetTenants().ToList();
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
foreach (var tenant in activeTenants)
|
2020-10-19 15:53:15 +00:00
|
|
|
{
|
2022-03-17 15:13:38 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Func<string> greenButtonText = () => string.Empty;
|
|
|
|
var greenButtonUrl = string.Empty;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var sendCount = 0;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
_tenantManager.SetCurrentTenant(tenant.Id);
|
|
|
|
var client = _workContext.NotifyContext.RegisterClient(_notifyEngineQueue, _studioNotifyHelper.NotifySource);
|
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationCurrentTenant(tenant.Id);
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
var users = _userManager.GetUsers(EmployeeStatus.Active);
|
|
|
|
|
|
|
|
foreach (var user in users.Where(u => _studioNotifyHelper.IsSubscribedToNotify(u, Actions.PeriodicNotify)))
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
INotifyAction action;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
_securityContext.AuthenticateMeWithoutCookie(_authManager.GetAccountByID(tenant.Id, user.Id));
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var culture = tenant.GetCulture();
|
|
|
|
if (!string.IsNullOrEmpty(user.CultureName))
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
culture = user.GetCulture();
|
|
|
|
}
|
|
|
|
catch (CultureNotFoundException exception)
|
|
|
|
{
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendPersonalLetters(exception);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var dayAfterRegister = (int)scheduleDate.Date.Subtract(user.CreateDate.Date).TotalDays;
|
2022-04-14 19:42:15 +00:00
|
|
|
|
|
|
|
if (_coreBaseSettings.CustomMode)
|
2022-03-17 15:13:38 +00:00
|
|
|
{
|
|
|
|
switch (dayAfterRegister)
|
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
action = Actions.PersonalCustomModeAfterRegistration7;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
switch (dayAfterRegister)
|
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
action = Actions.PersonalAfterRegistration7;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
action = Actions.PersonalAfterRegistration14;
|
|
|
|
break;
|
|
|
|
case 21:
|
|
|
|
action = Actions.PersonalAfterRegistration21;
|
|
|
|
break;
|
|
|
|
case 28:
|
|
|
|
action = Actions.PersonalAfterRegistration28;
|
|
|
|
greenButtonText = () => WebstudioNotifyPatternResource.ButtonStartFreeTrial;
|
|
|
|
greenButtonUrl = "https://www.onlyoffice.com/download-workspace.aspx";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
if (action == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationSendLetterPersonal(action.ID, user.Email, culture, tenant.Id, user.GetCulture(), user.CreateDate, scheduleDate.Date);
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
sendCount++;
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
|
|
|
null,
|
2022-03-29 15:39:09 +00:00
|
|
|
_studioNotifyHelper.RecipientFromEmail(user.Email, true),
|
2022-03-17 15:13:38 +00:00
|
|
|
new[] { senderName },
|
|
|
|
TagValues.PersonalHeaderStart(),
|
|
|
|
TagValues.PersonalHeaderEnd(),
|
|
|
|
TagValues.GreenButton(greenButtonText, greenButtonUrl),
|
2022-03-29 15:39:09 +00:00
|
|
|
new TagValue(CommonTags.Footer, _coreBaseSettings.CustomMode ? "personalCustomMode" : "personal"));
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationTotalSendCount(sendCount);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.ErrorSendPersonalLetters(err);
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-14 19:42:15 +00:00
|
|
|
|
2022-05-13 14:48:49 +00:00
|
|
|
_log.InformationEndSendLettersPersonal();
|
2022-03-17 15:13:38 +00:00
|
|
|
}
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
public static bool ChangeSubscription(Guid userId, StudioNotifyHelper studioNotifyHelper)
|
|
|
|
{
|
|
|
|
var recipient = studioNotifyHelper.ToRecipient(userId);
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
var isSubscribe = studioNotifyHelper.IsSubscribedToNotify(recipient, Actions.PeriodicNotify);
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
studioNotifyHelper.SubscribeToNotify(recipient, Actions.PeriodicNotify, !isSubscribe);
|
2022-03-22 10:20:43 +00:00
|
|
|
|
2022-03-17 15:13:38 +00:00
|
|
|
return !isSubscribe;
|
|
|
|
}
|
|
|
|
}
|