Skip to content

Commit

Permalink
Merge branch 'schedule-tasks-full-name' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMaz committed Nov 9, 2017
2 parents 0eba93e + 2d0ab0b commit be5dd31
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Libraries/Nop.Services/Tasks/Task.cs
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Domain.Tasks;
Expand Down Expand Up @@ -43,7 +44,11 @@ private void ExecuteTask()
if (!Enabled)
return;

var type = Type.GetType(ScheduleTask.Type);
var type = Type.GetType(ScheduleTask.Type) ??
//ensure that it works fine when only the type name is specified (do not require fully qualified names)
AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(ScheduleTask.Type))
.FirstOrDefault(t => t != null);
if (type == null)
throw new Exception($"Schedule task ({ScheduleTask.Type}) cannot by instantiated");

Expand Down
Expand Up @@ -39,7 +39,7 @@ public static class SquarePaymentDefaults
/// <summary>
/// Type of the renew access token schedule task
/// </summary>
public static string RenewAccessTokenTask => $"Nop.Plugin.Payments.Square.Services.RenewAccessTokenTask, {typeof(SquarePaymentDefaults).Assembly.FullName}";
public static string RenewAccessTokenTask => "Nop.Plugin.Payments.Square.Services.RenewAccessTokenTask";

/// <summary>
/// Default access token renewal period in days
Expand Down
8 changes: 7 additions & 1 deletion upgradescripts/3.90-4.00 (under development)/upgrade.sql
Expand Up @@ -1002,4 +1002,10 @@ BEGIN
INSERT [Setting] ([Name], [Value], [StoreId])
VALUES (N'squarepaymentsettings.usesandbox', N'true', 0)
END
GO
GO

--update schedule task type
UPDATE [ScheduleTask]
SET [Type] = 'Nop.Plugin.Payments.Square.Services.RenewAccessTokenTask'
WHERE [Type] like 'Nop.Plugin.Payments.Square.Services.RenewAccessTokenTask%'
GO

0 comments on commit be5dd31

Please sign in to comment.