Leadtools.Services.Cloud.ServiceContracts Namespace > IJobService Interface : AddJob Method |
[FaultContractAttribute(DetailType=Leadtools.Services.Cloud.FaultContracts.CloudFault, Action="", Name="", Namespace="", ProtectionLevel=ProtectionLevel.None, HasProtectionLevel=false)] [OperationContractAttribute()] AddJobResponse AddJob( AddJobRequest request )
'Declaration <FaultContractAttribute(DetailType=Leadtools.Services.Cloud.FaultContracts.CloudFault, Action="", Name="", Namespace="", ProtectionLevel=ProtectionLevel.None, HasProtectionLevel=False)> <OperationContractAttribute()> Function AddJob( _ ByVal request As AddJobRequest _ ) As AddJobResponse
'Usage Dim instance As IJobService Dim request As AddJobRequest Dim value As AddJobResponse value = instance.AddJob(request)
[FaultContractAttribute(DetailType=Leadtools.Services.Cloud.FaultContracts.CloudFault, Action="", Name="", Namespace="", ProtectionLevel=ProtectionLevel.None, HasProtectionLevel=false)] [OperationContractAttribute()] AddJobResponse AddJob( AddJobRequest request )
FaultContractAttribute(DetailType=Leadtools.Services.Cloud.FaultContracts.CloudFault, Action="", Name="", Namespace="", ProtectionLevel=ProtectionLevel.None, HasProtectionLevel=) OperationContractAttribute() function Leadtools.Services.Cloud.ServiceContracts.IJobService.AddJob( request )
[FaultContractAttribute(DetailType=Leadtools.Services.Cloud.FaultContracts.CloudFault, Action="", Name="", Namespace="", ProtectionLevel=ProtectionLevel.None, HasProtectionLevel=false)] [OperationContractAttribute()] AddJobResponse^ AddJob( AddJobRequest^ request )
Use this method to add a new job to the cloud database. The Leadtools.Services.Cloud.DataContracts.AddJobResponse class will contain the ID (Guid) of the added job. To add a batch of jobs at once, use AddJobs.
'This method will be used to store the conversion settings (how the file should be converted). 'We will serialize it at the, and the worker assembly will deserialize it to obtain the settings. Public Structure JobMetadata Public SourceFile As String Public TargetFile As String Public Format As String Public Sub New(ByVal _sourceFile As String, ByVal _targetFile As String, ByVal _format As String) SourceFile = _sourceFile TargetFile = _targetFile Format = _format End Sub End Structure 'Serialize the job metadata to an xml string so it can be stored in the cloud database, 'and deserialized later by the worker assembly when the job is processed. Public Function SerializeToString(ByVal jobMetadata As JobMetadata) As String 'Serialize the job metadata to an xml string so it can be stored in the cloud database, 'and deserialized later by the worker assembly when the job is processed. Using sw As StringWriter = New StringWriter() Dim xmlSerializer As XmlSerializer = New XmlSerializer(GetType(JobMetadata)) xmlSerializer.Serialize(sw, jobMetadata) Return sw.ToString() End Using End Function Public Sub AddJob() Using jobServiceClient As JobServiceClient = New JobServiceClient() Dim addJobRequest As AddJobRequest = New AddJobRequest() addJobRequest.UserToken = "User1" 'The job metadata describes how the job should be converted. For this example, we will assume the worker assembly 'will convert image files from one format to another. We will create a struct (JobMetadata) to hold the conversion 'information, serialize it to a string, and add it as the job metadata. In a typical scenario, the worker assembly 'would receive the job metadata, deserialize it, and convert the file based on the properties in the JobMetadata 'struct. Dim jobMetadata As JobMetadata = New JobMetadata("c:\input.jpg", "c:\output.pdf", "PDF") addJobRequest.JobMetadata = SerializeToString(jobMetadata) addJobRequest.JobType = "ConvertToPDF" Dim addJobResponse As AddJobResponse = jobServiceClient.AddJob(addJobRequest) If (Not String.IsNullOrEmpty(addJobResponse.ID)) Then Console.WriteLine(String.Format("The ID of the new job is {0}", addJobResponse.ID)) End If End Using End Sub
//This method will be used to store the conversion settings (how the file should be converted). //We will serialize it at the, and the worker assembly will deserialize it to obtain the settings. public struct JobMetadata { public string SourceFile; public string TargetFile; public string Format; public JobMetadata(string _sourceFile, string _targetFile, string _format) { SourceFile = _sourceFile; TargetFile = _targetFile; Format = _format; } } //Serialize the job metadata to an xml string so it can be stored in the cloud database, //and deserialized later by the worker assembly when the job is processed. public string SerializeToString(JobMetadata jobMetadata) { //Serialize the job metadata to an xml string so it can be stored in the cloud database, //and deserialized later by the worker assembly when the job is processed. using (StringWriter sw = new StringWriter()) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(JobMetadata)); xmlSerializer.Serialize(sw, jobMetadata); return sw.ToString(); } } public void AddJob() { using (JobServiceClient jobServiceClient = new JobServiceClient()) { AddJobRequest addJobRequest = new AddJobRequest(); addJobRequest.UserToken = "User1"; //The job metadata describes how the job should be converted. For this example, we will assume the worker assembly //will convert image files from one format to another. We will create a struct (JobMetadata) to hold the conversion //information, serialize it to a string, and add it as the job metadata. In a typical scenario, the worker assembly //would receive the job metadata, deserialize it, and convert the file based on the properties in the JobMetadata //struct. JobMetadata jobMetadata = new JobMetadata(@"c:\input.jpg", @"c:\output.pdf", "PDF"); addJobRequest.JobMetadata = SerializeToString(jobMetadata); addJobRequest.JobType = "ConvertToPDF"; AddJobResponse addJobResponse = jobServiceClient.AddJob(addJobRequest); if (!String.IsNullOrEmpty(addJobResponse.Id)) Console.WriteLine(String.Format("The ID of the new job is {0}", addJobResponse.Id)); } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2