Class JobManagerHelper
Job manager helper class for the Jobs API.
public class JobManagerHelper : BaseManagerHelper
- Inheritance
-
JobManagerHelper
- Inherited Members
- Extension Methods
Examples
public static SectionDefinition CreateProductSectionDefinition(JobManagerHelper helper)
{
// Creation of a job section "ProductSection" which will define that a job needs information about a product.
var productSectionDefinition = new CustomSectionDefinition()
{
Name = "ProductSection"
};
// The ProductSection gets two fields, a reference number and a description.
var referenceNumberField = new FieldDescriptor()
{
FieldType = typeof(long),
Name = "Product Reference",
// Optionally add validators here.
};
var productDescriptionField = new FieldDescriptor()
{
FieldType = typeof(string),
Name = "Product Description"
// Optionally add validators here.
};
productSectionDefinition.AddOrReplaceFieldDescriptor(referenceNumberField);
productSectionDefinition.AddOrReplaceFieldDescriptor(productDescriptionField);
// Save the job section to the server.
try
{
productSectionDefinition = helper.SectionDefinitions.Create(productSectionDefinition) as CustomSectionDefinition;
}
catch (CrudFailedException e)
{
// The operation failed, this can be handled with the information in the of the exception.
return null;
}
return productSectionDefinition;
}
public static void CreateOperatorSectionDefinition(JobManagerHelper helper)
{
// Creation for a job section "OperatorSection" which will define that a job needs information about the operator that is responsible for the Job.
var operatorSectionDefinition = new CustomSectionDefinition()
{
Name = "OperatorSection",
};
// The ProductSection one field, a list of operator names.
var operatorNameField = new FieldDescriptor()
{
FieldType = typeof(string),
Name = "OperatorName",
// Optionally add validators here.
};
var operatorContactField = new FieldDescriptor()
{
FieldType = typeof(string),
Name = "PhoneNumber",
// Optionally add validators here.
};
operatorSectionDefinition.AddOrReplaceFieldDescriptor(operatorNameField);
// Save the job section to the server.
try
{
operatorSectionDefinition = helper.SectionDefinitions.Create(operatorSectionDefinition) as CustomSectionDefinition;
}
catch (CrudFailedException e)
{
// The operation failed, this can be handled with the information in the of the exception.
Assert.Fail(e.ToString());
}
}
public static void CreateJobWithOperatorAndProductSection(JobManagerHelper helper)
{
// First we get the sections and their field descriptors that we want to add to the job.
var productSectionDefinition = helper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("ProductSection")).FirstOrDefault();
var productReferenceField = productSectionDefinition.GetAllFieldDescriptors().First(d => d.Name.Contains("Reference"));
var productDescriptionField = productSectionDefinition.GetAllFieldDescriptors().First(d => d.Name.Contains("Description"));
var operatorSectionDefinition = helper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("OperatorSection")).FirstOrDefault();
var operatorNameField = operatorSectionDefinition.GetAllFieldDescriptors().First();
var operatorContactField = operatorSectionDefinition.GetAllFieldDescriptors().First();
var job = new Job();
job.SetJobName("The general name of the job");
job.SetJobStartTime(DateTime.UtcNow);
job.SetJobEndTime(job.GetJobStartTime().Value.AddHours(2));
// Add a section to the Job about the operator.
var operatorSection = new Section(operatorSectionDefinition);
operatorSection.AddOrReplaceFieldValue(new FieldValue(operatorNameField)
{
Value = new ValueWrapper<string>("Bob Driver")
});
operatorSection.AddOrReplaceFieldValue(new FieldValue(operatorContactField)
{
Value = new ValueWrapper<string>("+32400000000")
});
job.Sections.Add(operatorSection);
// Add a section to the Job about the product.
var productInfo = new Section(productSectionDefinition);
productInfo.AddOrReplaceFieldValue(new FieldValue(productReferenceField)
{
Value = new ValueWrapper<long>(13248)
});
productInfo.AddOrReplaceFieldValue(new FieldValue(productDescriptionField)
{
Value = new ValueWrapper<string>("Some extra comment that is relevant to the product"),
});
job.Sections.Add(productInfo);
// Save the job to the server.
try
{
job = helper.Jobs.Create(job);
}
catch (CrudFailedException e)
{
// The operation failed, this can be handled with the information in the of the exception.
Assert.Fail(e.ToString());
}
}
Constructors
- JobManagerHelper(Func<DMSMessage[], DMSMessage[]>)
Initializes a new instance of the JobManagerHelper class.
Properties
- JobDomains
Gets the job domains.
- JobTemplates
Gets the job templates.
- Jobs
Gets the Jobs.
- RecordDefinitions
Gets the record definitions.
- Records
Gets the records.
- SectionDefinitions
Gets the section definitions.
Methods
- StitchJobs(List<Job>)
Stitches the Jobs to its SectionDefinition and FieldDescriptor by retrieving those from the server.
- StitchJobs(List<Job>, List<SectionDefinition>)
Stitches the Jobs to its SectionDefinition and FieldDescriptor by using the specified
existingSectionDefinitions
.
- StitchJobs(List<Job>, List<SectionDefinition>, List<JobDomain>)
Stitches the Jobs to its SectionDefinition and FieldDescriptor by using the provided
existingSectionDefinitions
. Also assigns the JobDomains usingexistingJobDomains
.
- StitchJobsHelper(List<Job>, List<SectionDefinition>, List<JobDomain>)
Stitches the Jobs to its SectionDefinition and FieldDescriptor by using the provided
existingSectionDefinitions
. Also assigns the JobDomains usingexistingJobDomains
.