Skip to content

Commit 9644419

Browse files
committed
* Task Scheduler:
- Can run tasks manually now (async) - Better UI - Shows last error - (Developer) Breaking change: New parameter TaskExecutionContext for ITask.Execute() * (Developer) New IoC method ContainerManager.InjectProperties()
1 parent 2eef27f commit 9644419

39 files changed

Lines changed: 694 additions & 246 deletions

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
##SmartStore.NET 2.1#
44

5+
###New Features###
6+
* (Developer) New IoC method ContainerManager.InjectProperties()
7+
58
###Improvements###
9+
* Task Scheduler:
10+
- Can run tasks manually now (async)
11+
- Better UI
12+
- Shows last error
13+
- (Developer) Breaking change: New parameter _TaskExecutionContext_ for _ITask.Execute()_
614
* UI: TabStrips remember their last selected tab across page requests in an unobtrusive way (removed old selection code)
715
* TinyMCE 4: activated spell checking, added FontSelect and FontSizeSelect tools to the toolbar
816
* Price formatting: the DisplayLocale's FormatProvider was not applied when _CustomFormatting_ was specified for Currency

src/Libraries/SmartStore.Core/Domain/Tasks/ScheduleTask.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public class ScheduleTask : BaseEntity
3535
public DateTime? LastEndUtc { get; set; }
3636

3737
public DateTime? LastSuccessUtc { get; set; }
38+
39+
public string LastError { get; set; }
3840
}
3941
}

src/Libraries/SmartStore.Core/Infrastructure/DependencyManagement/ContainerManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ public object ResolveOptional(Type serviceType, ILifetimeScope scope = null)
189189
return (scope ?? Scope()).ResolveOptional(serviceType);
190190
}
191191

192+
public T InjectProperties<T>(T instance, ILifetimeScope scope = null)
193+
{
194+
return (scope ?? Scope()).InjectProperties(instance);
195+
}
196+
197+
public T InjectUnsetProperties<T>(T instance, ILifetimeScope scope = null)
198+
{
199+
return (scope ?? Scope()).InjectUnsetProperties(instance);
200+
}
192201

193202
public void UpdateContainer(Action<ContainerBuilder> action)
194203
{

src/Libraries/SmartStore.Data/Mapping/Tasks/ScheduleTaskMap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public ScheduleTaskMap()
1111
this.HasKey(t => t.Id);
1212
this.Property(t => t.Name).IsRequired();
1313
this.Property(t => t.Type).IsRequired();
14+
this.Property(t => t.LastError).HasMaxLength(1000);
1415
}
1516
}
1617
}

src/Libraries/SmartStore.Data/Migrations/201405282243489_TaskUpdate.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
namespace SmartStore.Data.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
using SmartStore.Data.Setup;
6+
7+
public partial class TaskUpdate : DbMigration, ILocaleResourcesProvider, IDataSeeder<SmartObjectContext>
8+
{
9+
public override void Up()
10+
{
11+
AddColumn("dbo.ScheduleTask", "LastError", c => c.String(maxLength: 1000));
12+
}
13+
14+
public override void Down()
15+
{
16+
DropColumn("dbo.ScheduleTask", "LastError");
17+
}
18+
19+
public bool RollbackOnFailure
20+
{
21+
get { return false; }
22+
}
23+
24+
public void Seed(SmartObjectContext context)
25+
{
26+
context.MigrateLocaleResources(MigrateLocaleResources);
27+
}
28+
29+
public void MigrateLocaleResources(LocaleResourcesBuilder builder)
30+
{
31+
builder.AddOrUpdate("Admin.Catalog.Products.Variants.ProductVariantAttributes.AttributeCombinations.CombiNotExists",
32+
"The selected attribute combination does not exist yet.",
33+
"Die gewählte Attribut-Kombination existiert noch nicht.");
34+
35+
builder.AddOrUpdate("Common.Duration",
36+
"Duration",
37+
"Dauer");
38+
builder.AddOrUpdate("Common.Never",
39+
"Never",
40+
"Nie");
41+
42+
builder.AddOrUpdate("Admin.System.ScheduleTasks.StopOnError",
43+
"Stop on error",
44+
"Bei Fehler anhalten");
45+
46+
builder.AddOrUpdate("Admin.System.ScheduleTasks.LastStart",
47+
"Last run",
48+
"Letzte Ausführung");
49+
builder.AddOrUpdate("Admin.System.ScheduleTasks.LastEnd", // Obsolete
50+
"Last end",
51+
"Zuletzt beendet");
52+
builder.AddOrUpdate("Admin.System.ScheduleTasks.LastSuccess",
53+
"Last success",
54+
"Letzte erfolgreiche Ausführung");
55+
56+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow",
57+
"Run now",
58+
"Jetzt ausführen");
59+
60+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow.Completed",
61+
"Task execution completed",
62+
"Ausführung der Aufgabe abgeschlossen");
63+
64+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow.IsRunning",
65+
"Is running...",
66+
"Wird ausgeführt...");
67+
68+
builder.AddOrUpdate("Admin.System.ScheduleTasks.RunNow.Progress",
69+
"Task is now running in the background",
70+
"Aufgabe wird jetzt im Hintergrund ausgeführt");
71+
}
72+
}
73+
}

src/Libraries/SmartStore.Data/Migrations/201405282243489_TaskUpdate.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@
164164
<Compile Include="Migrations\201405071457441_FixRes1.Designer.cs">
165165
<DependentUpon>201405071457441_FixRes1.cs</DependentUpon>
166166
</Compile>
167+
<Compile Include="Migrations\201405282243489_TaskUpdate.cs" />
168+
<Compile Include="Migrations\201405282243489_TaskUpdate.Designer.cs">
169+
<DependentUpon>201405282243489_TaskUpdate.cs</DependentUpon>
170+
</Compile>
167171
<Compile Include="Setup\Builder\SettingsBuilder.cs" />
168172
<Compile Include="Setup\Builder\SettingsMigrator.cs" />
169173
<Compile Include="Setup\DbMigrationContext.cs" />
@@ -340,6 +344,9 @@
340344
<EmbeddedResource Include="Migrations\201405071457441_FixRes1.resx">
341345
<DependentUpon>201405071457441_FixRes1.cs</DependentUpon>
342346
</EmbeddedResource>
347+
<EmbeddedResource Include="Migrations\201405282243489_TaskUpdate.resx">
348+
<DependentUpon>201405282243489_TaskUpdate.cs</DependentUpon>
349+
</EmbeddedResource>
343350
<EmbeddedResource Include="Sql\Indexes.sql" />
344351
<EmbeddedResource Include="Sql\StoredProcedures.sql" />
345352
</ItemGroup>

src/Libraries/SmartStore.Services/Caching/ClearCacheTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public ClearCacheTask(Func<string, ICacheManager> cache)
2020
/// <summary>
2121
/// Executes a task
2222
/// </summary>
23-
public void Execute()
23+
public void Execute(TaskExecutionContext ctx)
2424
{
2525
_cacheManager.Clear();
2626
}

src/Libraries/SmartStore.Services/Common/KeepAliveTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public KeepAliveTask(IStoreContext storeContext)
1616
this._storeContext = storeContext;
1717
}
1818

19-
public void Execute()
19+
public void Execute(TaskExecutionContext ctx)
2020
{
2121
var storeUrl = _storeContext.CurrentStore.Url.TrimEnd('\\').EnsureEndsWith("/");
2222
string url = storeUrl + "keepalive/index";

0 commit comments

Comments
 (0)