public CreateJobSchedule ( |
||
parameters | The parameters to use when creating the job schedule. | |
리턴 | void |
public void CreateJobSchedule(NewJobScheduleParameters parameters)
{
if (parameters == null)
{
throw new ArgumentNullException("parameters");
}
JobScheduleOperations jobScheduleOperations = parameters.Context.BatchOMClient.JobScheduleOperations;
CloudJobSchedule jobSchedule = jobScheduleOperations.CreateJobSchedule();
jobSchedule.Id = parameters.JobScheduleId;
jobSchedule.DisplayName = parameters.DisplayName;
if (parameters.Schedule != null)
{
jobSchedule.Schedule = parameters.Schedule.omObject;
}
if (parameters.JobSpecification != null)
{
Utils.Utils.JobSpecificationSyncCollections(parameters.JobSpecification);
jobSchedule.JobSpecification = parameters.JobSpecification.omObject;
}
if (parameters.Metadata != null)
{
jobSchedule.Metadata = new List<MetadataItem>();
foreach (DictionaryEntry d in parameters.Metadata)
{
MetadataItem metadata = new MetadataItem(d.Key.ToString(), d.Value.ToString());
jobSchedule.Metadata.Add(metadata);
}
}
WriteVerbose(string.Format(Resources.CreatingJobSchedule, parameters.JobScheduleId));
jobSchedule.Commit(parameters.AdditionalBehaviors);
}
/// <summary> /// Creates a test job schedule for use in Scenario tests. /// </summary> public static void CreateTestJobSchedule(BatchController controller, BatchAccountContext context, string jobScheduleId, TimeSpan?recurrenceInterval) { RequestInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSJobSpecification jobSpecification = new PSJobSpecification(); jobSpecification.PoolInformation = new PSPoolInformation(); jobSpecification.PoolInformation.PoolId = SharedPool; PSSchedule schedule = new PSSchedule(); if (recurrenceInterval != null) { schedule = new PSSchedule(); schedule.RecurrenceInterval = recurrenceInterval; } NewJobScheduleParameters parameters = new NewJobScheduleParameters(context, jobScheduleId, behaviors) { JobSpecification = jobSpecification, Schedule = schedule }; client.CreateJobSchedule(parameters); }