Skip to content

Commit ecdff57

Browse files
committed
Schedule task type dependent notification messages when starting a task
1 parent d82fcf0 commit ecdff57

4 files changed

Lines changed: 31 additions & 9 deletions

File tree

src/Libraries/SmartStore.Data/Migrations/201601262000441_ImportFramework1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
4747
"Add import file...",
4848
"Importdatei hinzufügen...");
4949

50-
builder.AddOrUpdate("Admin.DataExchange.Import.RunNowNote",
50+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow.Success.DataImportTask",
5151
"The task is now running in the background. You will receive an email as soon as it is completed. The progress can be tracked in the import profile list.",
5252
"Die Aufgabe wird jetzt im Hintergrund ausgeführt. Sie erhalten eine E-Mail, sobald sie abgeschlossen ist. Den Fortschritt können Sie in der Importprofilliste verfolgen.");
5353

54-
builder.AddOrUpdate("Admin.DataExchange.Export.RunNowNote",
54+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow.Success.DataExportTask",
5555
"The task is now running in the background. You will receive an email as soon as it is completed. The progress can be tracked in the export profile list.",
5656
"Die Aufgabe wird jetzt im Hintergrund ausgeführt. Sie erhalten eine E-Mail, sobald sie abgeschlossen ist. Den Fortschritt können Sie in der Exportprofilliste verfolgen.");
5757

src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ public ActionResult Execute(int id, string selectedIds)
10141014

10151015
_taskScheduler.RunSingleTask(profile.SchedulingTaskId, taskParams);
10161016

1017-
NotifyInfo(T("Admin.DataExchange.Export.RunNowNote"));
1017+
NotifyInfo(T("Admin.System.ScheduleTasks.RunNow.Success.DataExportTask"));
10181018

10191019
return RedirectToAction("List");
10201020
}

src/Presentation/SmartStore.Web/Administration/Controllers/ImportController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public ActionResult Execute(int id)
622622

623623
_taskScheduler.RunSingleTask(profile.SchedulingTaskId, taskParams);
624624

625-
NotifyInfo(T("Admin.DataExchange.Import.RunNowNote"));
625+
NotifyInfo(T("Admin.System.ScheduleTasks.RunNow.Success.DataImportTask"));
626626

627627
return RedirectToAction("List");
628628
}

src/Presentation/SmartStore.Web/Administration/Controllers/ScheduleTaskController.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace SmartStore.Admin.Controllers
1818
{
19-
[AdminAuthorize]
19+
[AdminAuthorize]
2020
public partial class ScheduleTaskController : AdminControllerBase
2121
{
2222
private readonly IScheduleTaskService _scheduleTaskService;
@@ -52,7 +52,30 @@ private bool IsTaskVisible(ScheduleTask task)
5252
return false;
5353
}
5454

55-
public ActionResult Index()
55+
private string GetTaskMessage(ScheduleTask task, string resourceKey)
56+
{
57+
string message = null;
58+
59+
var taskClassName = task.Type
60+
.SplitSafe(",")
61+
.SafeGet(0)
62+
.SplitSafe(".")
63+
.LastOrDefault();
64+
65+
if (taskClassName.HasValue())
66+
{
67+
message = T(string.Concat(resourceKey, ".", taskClassName));
68+
}
69+
70+
if (message.IsEmpty())
71+
{
72+
message = T(resourceKey);
73+
}
74+
75+
return message;
76+
}
77+
78+
public ActionResult Index()
5679
{
5780
return RedirectToAction("List");
5881
}
@@ -128,7 +151,7 @@ public ActionResult RunJob(int id, string returnUrl = "")
128151
{
129152
if (task.IsRunning)
130153
{
131-
NotifyInfo(T("Admin.System.ScheduleTasks.RunNow.Progress"));
154+
NotifyInfo(GetTaskMessage(task, "Admin.System.ScheduleTasks.RunNow.Progress"));
132155
}
133156
else
134157
{
@@ -138,10 +161,9 @@ public ActionResult RunJob(int id, string returnUrl = "")
138161
}
139162
else
140163
{
141-
NotifySuccess(T("Admin.System.ScheduleTasks.RunNow.Success"));
164+
NotifySuccess(GetTaskMessage(task, "Admin.System.ScheduleTasks.RunNow.Success"));
142165
}
143166
}
144-
var now = DateTime.UtcNow;
145167
}
146168

147169
return Redirect(returnUrl);

0 commit comments

Comments
 (0)