/// <summary> /// Processes a single job. /// </summary> /// <param name="job">Task processor job.</param> private void ProcessSequentialTask(TaskProcessorJob job) { // Debug Logging. if (this.Configuration.LoggingEnabled) { Debug.WriteLine($"Sequential task processing with task id => {job.Data?.Value.Id}."); } // Ensure cancellation has not been requested. job.ThrowIfCancellationRequested(); // Update the progress of the task in the task queue. this.TaskProcessor.UpdateTaskAsAssignedToProcessor(job); // Sanity. if (null == job.Data?.Value) { return; } // Deserialize the directive. var dir = TaskQueueDirective.Parse <ObjVerExTaskQueueDirective>(job.Data?.Value); // Sanity. if (string.IsNullOrWhiteSpace(dir?.ObjVerEx)) { return; } // Update the object. try { // Mark that we're updating the object. this.TaskProcessor.UpdateTaskInfo ( job.Data?.Value, MFTaskState.MFTaskStateInProgress, $"Updating object {dir.ObjVerEx}", false ); // Load the object, check it out, update, check it in. var objVerEx = ObjVerEx.Parse(job.Vault, dir.ObjVerEx); objVerEx.CheckOut(); objVerEx.SetProperty ( MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle, MFDataType.MFDatatypeText, DateTime.Now.ToLongTimeString() ); objVerEx.SaveProperties(); objVerEx.CheckIn(); // Updated. this.TaskProcessor.UpdateTaskInfo ( job.Data?.Value, MFTaskState.MFTaskStateCompleted, $"Object {dir.ObjVerEx} updated", false ); } catch (Exception e) { // Exception. this.TaskProcessor.UpdateTaskInfo ( job.Data?.Value, MFTaskState.MFTaskStateFailed, e.Message, false ); } }