public override void ExecuteCmdlet()
        {
            NewJobParameters parameters = new NewJobParameters(this.BatchContext, this.Id, this.AdditionalBehaviors)
            {
                CommonEnvironmentSettings = this.CommonEnvironmentSettings,
                DisplayName = this.DisplayName,
                Constraints = this.Constraints,
                JobManagerTask = this.JobManagerTask,
                JobPreparationTask = this.JobPreparationTask,
                JobReleaseTask = this.JobReleaseTask,
                Metadata = this.Metadata,
                PoolInformation = this.PoolInformation,
                Priority = this.Priority
            };

            BatchClient.CreateJob(parameters);
        }
        /// <summary>
        /// Creates a test job for use in Scenario tests.
        /// </summary>
        public static void CreateTestJob(BatchController controller, BatchAccountContext context, string jobId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSPoolInformation poolInfo = new PSPoolInformation();
            poolInfo.PoolId = SharedPool;

            NewJobParameters parameters = new NewJobParameters(context, jobId, behaviors)
            {
                PoolInformation = poolInfo
            };

            client.CreateJob(parameters);
        }
        /// <summary>
        /// Creates a new job.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the job.</param>
        public void CreateJob(NewJobParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
            CloudJob      job           = jobOperations.CreateJob();

            job.Id          = parameters.JobId;
            job.DisplayName = parameters.DisplayName;
            job.Priority    = parameters.Priority;

            if (parameters.CommonEnvironmentSettings != null)
            {
                List <EnvironmentSetting> envSettings = new List <EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.CommonEnvironmentSettings)
                {
                    EnvironmentSetting envSetting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    envSettings.Add(envSetting);
                }
                job.CommonEnvironmentSettings = envSettings;
            }

            if (parameters.Constraints != null)
            {
                job.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.JobManagerTask != null)
            {
                Utils.Utils.JobManagerTaskSyncCollections(parameters.JobManagerTask);
                job.JobManagerTask = parameters.JobManagerTask.omObject;
            }

            if (parameters.JobPreparationTask != null)
            {
                Utils.Utils.JobPreparationTaskSyncCollections(parameters.JobPreparationTask);
                job.JobPreparationTask = parameters.JobPreparationTask.omObject;
            }

            if (parameters.JobReleaseTask != null)
            {
                Utils.Utils.JobReleaseTaskSyncCollections(parameters.JobReleaseTask);
                job.JobReleaseTask = parameters.JobReleaseTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                job.Metadata = new List <MetadataItem>();
                foreach (DictionaryEntry d in parameters.Metadata)
                {
                    MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                    job.Metadata.Add(metadata);
                }
            }

            if (parameters.PoolInformation != null)
            {
                Utils.Utils.PoolInformationSyncCollections(parameters.PoolInformation);
                job.PoolInformation = parameters.PoolInformation.omObject;
            }

            WriteVerbose(string.Format(Resources.CreatingJob, parameters.JobId));
            job.Commit(parameters.AdditionalBehaviors);
        }
        /// <summary>
        /// Creates a test job for use in Scenario tests.
        /// </summary>
        public static void CreateTestJob(BatchController controller, BatchAccountContext context, string jobId)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSPoolInformation poolInfo = new PSPoolInformation();
            poolInfo.PoolId = SharedPool;

            NewJobParameters parameters = new NewJobParameters(context, jobId)
            {
                PoolInformation = poolInfo
            };

            client.CreateJob(parameters);
        }
        /// <summary>
        /// Creates a new job.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the job.</param>
        public void CreateJob(NewJobParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
            CloudJob job = jobOperations.CreateJob();

            job.Id = parameters.JobId;
            job.DisplayName = parameters.DisplayName;
            job.Priority = parameters.Priority;

            if (parameters.CommonEnvironmentSettings != null)
            {
                List<EnvironmentSetting> envSettings = new List<EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.CommonEnvironmentSettings)
                {
                    EnvironmentSetting envSetting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    envSettings.Add(envSetting);
                }
                job.CommonEnvironmentSettings = envSettings;
            }

            if (parameters.Constraints != null)
            {
                job.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.UsesTaskDependencies != null)
            {
                job.UsesTaskDependencies = parameters.UsesTaskDependencies;
            }

            if (parameters.JobManagerTask != null)
            {
                Utils.Utils.JobManagerTaskSyncCollections(parameters.JobManagerTask);
                job.JobManagerTask = parameters.JobManagerTask.omObject;
            }

            if (parameters.JobPreparationTask != null)
            {
                Utils.Utils.JobPreparationTaskSyncCollections(parameters.JobPreparationTask);
                job.JobPreparationTask = parameters.JobPreparationTask.omObject;
            }

            if (parameters.JobReleaseTask != null)
            {
                Utils.Utils.JobReleaseTaskSyncCollections(parameters.JobReleaseTask);
                job.JobReleaseTask = parameters.JobReleaseTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                job.Metadata = new List<MetadataItem>();
                foreach (DictionaryEntry d in parameters.Metadata)
                {
                    MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
                    job.Metadata.Add(metadata);
                }
            }

            if (parameters.PoolInformation != null)
            {
                Utils.Utils.PoolInformationSyncCollections(parameters.PoolInformation);
                job.PoolInformation = parameters.PoolInformation.omObject;
            }

            if (parameters.OnAllTasksComplete != null)
            {
                job.OnAllTasksComplete = parameters.OnAllTasksComplete;
            }

            if (parameters.OnTaskFailure != null)
            {
                job.OnTaskFailure = parameters.OnTaskFailure;
            }

            WriteVerbose(string.Format(Resources.CreatingJob, parameters.JobId));
            job.Commit(parameters.AdditionalBehaviors);
        }