Skip to content

Commit b3bbed3

Browse files
committed
Enhanced TaskListView with error string if last run result is not successful.
1 parent 590494f commit b3bbed3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

TaskEditor/TaskListView.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,22 @@ private string[] LVIItemsFromTask(Task task)
199199
td == null ? "" : task.Definition.Triggers.ToString(),
200200
disabled || task.NextRunTime < DateTime.Now ? string.Empty : task.NextRunTime.ToString("G"),
201201
task.LastRunTime == DateTime.MinValue ? EditorProperties.Resources.Never : task.LastRunTime.ToString("G"),
202-
task.LastRunTime == DateTime.MinValue ? string.Empty : task.State == TaskState.Running ? string.Format(EditorProperties.Resources.LastResultRunning, task.LastTaskResult) : ((task.LastTaskResult == 0 ? EditorProperties.Resources.LastResultSuccessful : string.Format("(0x{0:X})", task.LastTaskResult))),
202+
task.LastRunTime == DateTime.MinValue ? string.Empty : LastResultString(),
203203
td == null ? "" : task.Definition.RegistrationInfo.Author,
204204
string.Empty
205205
};
206+
207+
string LastResultString()
208+
{
209+
if (task.State == TaskState.Running)
210+
return string.Format(EditorProperties.Resources.LastResultRunning, task.LastTaskResult);
211+
if (task.LastTaskResult == 0)
212+
return EditorProperties.Resources.LastResultSuccessful;
213+
var exc = new Win32Exception(task.LastTaskResult);
214+
if (string.IsNullOrEmpty(exc.Message))
215+
return string.Format("(0x{0:X})", task.LastTaskResult);
216+
return exc.Message.IndexOf(task.LastTaskResult.ToString("X"), StringComparison.InvariantCultureIgnoreCase) == -1 ? string.Format("{1} (0x{0:X})", task.LastTaskResult, exc.Message) : exc.Message;
217+
}
206218
}
207219

208220
private void RefreshItems()

TaskSchedulerMockup/TaskSchedulerMockup.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
<ApplicationIcon>Resources\ts.ico</ApplicationIcon>
4848
</PropertyGroup>
4949
<ItemGroup>
50-
<Reference Include="JetBrains.Annotations, Version=2019.1.1.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
51-
<HintPath>..\packages\JetBrains.Annotations.2019.1.1\lib\net20\JetBrains.Annotations.dll</HintPath>
50+
<Reference Include="JetBrains.Annotations, Version=2019.1.3.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
51+
<HintPath>..\packages\JetBrains.Annotations.2019.1.3\lib\net20\JetBrains.Annotations.dll</HintPath>
5252
</Reference>
5353
<Reference Include="System" />
5454
<Reference Include="System.Design" />

TaskSchedulerMockup/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="JetBrains.Annotations" version="2019.1.1" targetFramework="net20" />
3+
<package id="JetBrains.Annotations" version="2019.1.3" targetFramework="net20" />
44
<package id="TimeSpan2" version="2.2.0" targetFramework="net20" />
55
</packages>

0 commit comments

Comments
 (0)