Наследование: Microsoft.Azure.Commands.Batch.Models.JobOperationParameters
Пример #1
0
        /// <summary>
        /// Adds a collection of tasks
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the tasks.</param>
        public void AddTaskCollection(NewBulkTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Func <PSCloudTask, CloudTask> mappingFunc = task =>
            {
                Utils.Utils.CloudTaskSyncCollections(task);
                return(task.omObject);
            };

            IEnumerable <CloudTask> taskCollection = parameters.Tasks.Select(mappingFunc);

            JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
            string        jobId         = parameters.Job == null ? parameters.JobId : parameters.Job.Id;

            jobOperations.AddTask(jobId, taskCollection, additionalBehaviors: parameters.AdditionalBehaviors);
        }
        public override void ExecuteCmdlet()
        {
            if (Tasks != null)
            {
                NewBulkTaskParameters parameters = new NewBulkTaskParameters(this.BatchContext, this.JobId, this.Job, this.Tasks, this.AdditionalBehaviors);
                BatchClient.AddTaskCollection(parameters);
            }
            else
            {
                NewTaskParameters parameters = new NewTaskParameters(this.BatchContext, this.JobId, this.Job,
                    this.Id, this.AdditionalBehaviors)
                {
                    DisplayName = this.DisplayName,
                    CommandLine = this.CommandLine,
                    ResourceFiles = this.ResourceFiles,
                    EnvironmentSettings = this.EnvironmentSettings,
                    RunElevated = this.RunElevated.IsPresent,
                    AffinityInformation = this.AffinityInformation,
                    Constraints = this.Constraints,
                    MultiInstanceSettings = this.MultiInstanceSettings,
                    DependsOn = this.DependsOn,
                };

                BatchClient.CreateTask(parameters);
            }
        }
        /// <summary>
        /// Adds a collection of tasks
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the tasks.</param>
        public void AddTaskCollection(NewBulkTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Func<PSCloudTask, CloudTask> mappingFunc = task =>
            {
                Utils.Utils.CloudTaskSyncCollections(task);
                return task.omObject;
            };

            IEnumerable<CloudTask> taskCollection = parameters.Tasks.Select(mappingFunc);

            JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
            string jobId = parameters.Job == null ? parameters.JobId : parameters.Job.Id;

            jobOperations.AddTask(jobId, taskCollection, additionalBehaviors: parameters.AdditionalBehaviors);
        }