Skip to content

Commit 5388837

Browse files
committed
final adjustments
Signed-off-by: Neil South <neil.south@answerdigital.com>
1 parent ee61cf9 commit 5388837

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/TaskManager/TaskManager/TaskManager.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,17 @@ private async Task HandleCancellationTask(JsonMessage<TaskCancellationEvent> mes
241241
}
242242

243243
var pluginAssembly = string.Empty;
244-
ITaskPlugin? taskRunner = null;
244+
ITaskPlugin? taskRunner;
245245
try
246246
{
247247
var taskExecution = await _taskDispatchEventService.GetByTaskExecutionIdAsync(message.Body.ExecutionId).ConfigureAwait(false);
248-
pluginAssembly = _options.Value.TaskManager.PluginAssemblyMappings[taskExecution?.Event.TaskPluginType] ?? string.Empty;
249-
var taskExecEvent = taskExecution?.Event;
250-
if (taskExecEvent == null)
248+
249+
var taskExecEvent = taskExecution?.Event ?? throw new InvalidOperationException("Task Event data not found.");
250+
251+
pluginAssembly = string.Empty;
252+
if (_options.Value.TaskManager.PluginAssemblyMappings.ContainsKey(taskExecution?.Event.TaskPluginType))
251253
{
252-
throw new InvalidOperationException("Task Event data not found.");
254+
pluginAssembly = _options.Value.TaskManager.PluginAssemblyMappings[taskExecution?.Event.TaskPluginType];
253255
}
254256

255257
taskRunner = typeof(ITaskPlugin).CreateInstance<ITaskPlugin>(serviceProvider: _scope.ServiceProvider, typeString: pluginAssembly, _serviceScopeFactory, taskExecEvent);

src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public async Task AddOrUpdateItemAsync(string workflowInstanceId, string taskId,
166166

167167
var item = new ArtifactReceivedItems()
168168
{
169+
Id = workflowInstanceId + taskId,
169170
WorkflowInstanceId = workflowInstanceId,
170171
TaskId = taskId,
171172
Artifacts = artifacts.ToList()
@@ -175,18 +176,28 @@ public async Task AddOrUpdateItemAsync(string workflowInstanceId, string taskId,
175176
.FindAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId).ConfigureAwait(false);
176177
var existing = await result.FirstOrDefaultAsync().ConfigureAwait(false);
177178

178-
if (existing == null)
179+
try
179180
{
180-
await _artifactReceivedItemsCollection.InsertOneAsync(item).ConfigureAwait(false);
181+
if (existing == null)
182+
{
183+
await _artifactReceivedItemsCollection.InsertOneAsync(item).ConfigureAwait(false);
184+
}
185+
else
186+
{
187+
item.Artifacts = item.Artifacts.Concat(existing.Artifacts).ToList();
188+
var update = Builders<ArtifactReceivedItems>.Update.Set(a => a.Artifacts, item.Artifacts);
189+
await _artifactReceivedItemsCollection
190+
.UpdateOneAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId, update)
191+
.ConfigureAwait(false);
192+
}
181193
}
182-
else
194+
catch (Exception ex)
183195
{
184-
item.Artifacts = item.Artifacts.Concat(existing.Artifacts).ToList();
185-
var update = Builders<ArtifactReceivedItems>.Update.Set(a => a.Artifacts, item.Artifacts);
186-
await _artifactReceivedItemsCollection
187-
.UpdateOneAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId, update)
188-
.ConfigureAwait(false);
196+
197+
throw;
189198
}
199+
200+
190201
}
191202
}
192203
}

0 commit comments

Comments
 (0)