ReportingService2005.CancelJob Method
SQL Server 2005
Cancels the execution of a job.
Namespace: Microsoft.WSSUX.ReportingServicesWebService.RSManagementService2005
Assembly: ReportService2005 (in reportingservice2005.dll)
Assembly: ReportService2005 (in reportingservice2005.dll)
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelJob", RequestNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] [SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out)] public bool CancelJob ( string JobID )
/** @attribute SoapDocumentMethodAttribute("http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelJob", RequestNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped) */
/** @attribute SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out) */
public boolean CancelJob (
String JobID
)
SoapDocumentMethodAttribute("http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelJob", RequestNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped) SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out) public function CancelJob ( JobID : String ) : boolean
Parameters
- JobID
The ID of the job that you want to cancel.
Return Value
A Boolean value. A value of true is returned if the job was successfully cancelled.To compile this code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see Compiling and Running Code Examples. The following code example is a console application that enables users to cancel all running jobs on a given report server:
using System; using System.Web.Services.Protocols; class Sample { public static void Main() { ReportingService rs = new ReportingService2005(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; Job[] jobs = null; // Return a list of current jobs. try { jobs = rs.ListJobs(); // Provides a prompt to cancel current jobs. if (ListRunningJobs(jobs)) { Console.Write("Do you want to cancel these jobs (Y/N)?"); int input = Console.Read(); if (Char.ToLower((char)input)== 'y') { CancelRunningJobs(jobs, rs); } } } catch (SoapException e) { Console.WriteLine(e.Detail.InnerXml.ToString()); } } // Method to send a list of current jobs and their properties // to standard output. public static bool ListRunningJobs(Job[] jobs) { int runningJobCount = 0; Console.WriteLine("Current Jobs"); Console.WriteLine("================================" + Environment.NewLine); foreach (Job job in jobs) { if (job.Status == JobStatusEnum.Running || job.Status == JobStatusEnum.New) { Console.WriteLine("--------------------------------"); Console.WriteLine("JobID: {0}", job.JobID); Console.WriteLine("--------------------------------"); Console.WriteLine("Action: {0}", job.Action); Console.WriteLine("Description: {0}", job.Description); Console.WriteLine("Machine: {0}", job.Machine); Console.WriteLine("Name: {0}", job.Name); Console.WriteLine("Path: {0}", job.Path); Console.WriteLine("StartDateTime: {0}", job.StartDateTime); Console.WriteLine("Status: {0}", job.Status); Console.WriteLine("Type: {0}", job.Type); Console.WriteLine("User: {0}" + Environment.NewLine, job.User); runningJobCount++; } } Console.Write("There are {0} running jobs. ", runningJobCount); if (runningJobCount > 0) return true; else return false; } public static void CancelRunningJobs(Job[] jobs, ReportingService rs) { try { foreach (Job job in jobs) { if (job.Status == JobStatusEnum.Running || job.Status == JobStatusEnum.New) { rs.CancelJob(job.JobID); } } Console.WriteLine("All jobs successfully canceled."); } catch (SoapException e) { Console.WriteLine(e.Detail.InnerXml.ToString()); } } }
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.Target Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.
