ReportingService2005.CancelJob(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
작업 실행을 취소합니다.
public:
bool CancelJob(System::String ^ JobID);
public bool CancelJob (string JobID);
member this.CancelJob : string -> bool
Public Function CancelJob (JobID As String) As Boolean
매개 변수
반환
Boolean
값입니다. 작업이 성공적으로 취소되면 true
값이 반환됩니다.
예제
이 코드 예제를 컴파일하려면 Reporting Services WSDL을 참조하고 특정 네임스페이스를 가져와야 합니다. 자세한 내용은 코드 예제 컴파일 및 실행을 참조하세요. 다음 코드 예제는 사용자가 지정된 보고서 서버에서 실행 중인 모든 작업을 취소할 수 있도록 하는 콘솔 애플리케이션입니다.
Imports System
Imports System.Web.Services.Protocols
Class Sample
Public Shared Sub Main()
Dim rs As New ReportingService2005()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim jobs As Job() = Nothing
' Return a list of current jobs.
Try
jobs = rs.ListJobs()
' Provides a prompt to cancel current jobs.
If ListRunningJobs(jobs) Then
Console.Write("Do you want to cancel these jobs (Y/N)?")
Dim input As Integer = Console.Read()
If [Char].ToLower(CChar(input)) = "y"c Then
CancelRunningJobs(jobs, rs)
End If
End If
Catch e As SoapException
Console.WriteLine(e.Detail.InnerXml.ToString())
End Try
End Sub 'Main
' Method to send a list of current jobs and their properties
' to standard output.
Public Shared Function ListRunningJobs(jobs() As Job) As Boolean
Dim runningJobCount As Integer = 0
Console.WriteLine("Current Jobs")
Console.WriteLine(("================================" + Environment.NewLine))
Dim job As Job
For Each job In jobs
If job.Status = JobStatusEnum.Running Or job.Status = JobStatusEnum.New Then
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 += 1
End If
Next job
Console.Write("There are {0} running jobs. ", runningJobCount)
If runningJobCount > 0 Then
Return True
Else
Return False
End If
End Function 'ListRunningJobs
Public Shared Sub CancelRunningJobs(jobs() As Job, rs As ReportingService)
Try
Dim job As Job
For Each job In jobs
If job.Status = JobStatusEnum.Running Or job.Status = JobStatusEnum.New Then
rs.CancelJob(job.JobID)
End If
Next job
Console.WriteLine("All jobs successfully canceled.")
Catch e As SoapException
Console.WriteLine(e.Detail.InnerXml.ToString())
End Try
End Sub 'CancelRunningJobs
End Class 'Sample
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());
}
}
}
설명
다음 표에서는 이 작업에 대한 헤더 및 사용 권한 정보를 보여 줍니다.
SOAP 헤더 | (Out) ServerInfoHeaderValue |
필요한 권한 | CancelJobs |
매개 변수에 전달된 JobID
작업 ID를 찾을 수 없는 경우 오류가 반환됩니다. 이미 취소된 작업의 ID를 사용하여 이 메서드를 호출하는 경우 보고서 서버는 작업을 무시합니다.
메서드를 ListJobs 사용하여 보고서 서버에서 현재 실행 중인 작업 목록을 가져옵니다.