Esempio n. 1
0
        /// <summary>
        /// Cancels future executions of a task with a given queue ID and task type (read from the <paramref name="job"/>'s directive).
        /// If the directive also contains a next-execution date then reschedules an execution of the task at that time.
        /// </summary>
        /// <param name="job"></param>
        protected virtual void HandleReschedule(ITaskProcessingJob <RescheduleProcessorTaskDirective> job)
        {
            // Cancel any future executions.
            this.CancelAllFutureExecutions
            (
                job.Directive.QueueID,
                job.Directive.TaskType,
                includeCurrentlyExecuting: false,
                vault: job.Vault
            );

            // Re-schedule?
            if (job.Directive.NextExecution.HasValue)
            {
                // Schedule the next run.
                this.AddTask
                (
                    job.Vault,
                    job.Directive.QueueID,
                    job.Directive.TaskType,
                    directive: job.Directive.InnerDirective,
                    activationTime: job.Directive.NextExecution.Value
                );
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Commits the job, but does not write anything to the vault.
        /// </summary>
        /// <typeparam name="TDirective">The type of directive this job accepts.</typeparam>
        /// <param name="job">The job to commit.</param>
        /// <remarks>
        /// The default transaction mode is <see cref="TransactionMode.Hybrid"/>, which forces the task processor to call
        /// <see cref="ITaskProcessingJob{TDirective}.Commit(Action{MFilesAPI.Vault})"/> prior to the processing completing.
        /// In some situations the task processing may not need to actually make any updates to the server.  This extension
        /// method is simply a shorthand for passing a lambda with no body to
        /// <see cref="ITaskProcessingJob{TDirective}.Commit(Action{MFilesAPI.Vault})"/>.
        /// </remarks>
        public static void CommitWithNoAction <TDirective>(this ITaskProcessingJob <TDirective> job)
            where TDirective : TaskDirective
        {
            // Sanity.
            if (null == job)
            {
                throw new ArgumentNullException(nameof(job));
            }

            // No action in the commit phase.
            job.Commit(ITaskProcessingJobOfTExtensionMethods.NoAction);
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the in-progress status of the task.
        /// </summary>
        /// <typeparam name="TDirective">The type of directive this job accepts.</typeparam>
        /// <param name="job">The job.</param>
        /// <param name="taskInformation">Information about the task.</param>
        public static void Update <TDirective>(this ITaskProcessingJob <TDirective> job, TaskInformation taskInformation)
            where TDirective : TaskDirective
        {
            // Sanity.
            if (null == job)
            {
                throw new ArgumentNullException(nameof(job));
            }
            if (null == taskInformation)
            {
                return;
            }

            // Use the standard method.
            job.Update
            (
                percentComplete: taskInformation.PercentageComplete,
                details: taskInformation.StatusDetails,
                data: taskInformation.ToJObject()
            );
        }