ReportingService2010.CreateSubscription 方法

定义

创建报表服务器数据库或 SharePoint 库中指定项的订阅。 此方法适用于Report项类型。

public:
 System::String ^ CreateSubscription(System::String ^ ItemPath, ReportService2010::ExtensionSettings ^ ExtensionSettings, System::String ^ Description, System::String ^ EventType, System::String ^ MatchData, cli::array <ReportService2010::ParameterValue ^> ^ Parameters);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateSubscription", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
[System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")]
public string CreateSubscription (string ItemPath, ReportService2010.ExtensionSettings ExtensionSettings, string Description, string EventType, string MatchData, ReportService2010.ParameterValue[] Parameters);
[<System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateSubscription", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)>]
[<System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)>]
[<System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")>]
member this.CreateSubscription : string * ReportService2010.ExtensionSettings * string * string * string * ReportService2010.ParameterValue[] -> string
Public Function CreateSubscription (ItemPath As String, ExtensionSettings As ExtensionSettings, Description As String, EventType As String, MatchData As String, Parameters As ParameterValue()) As String

参数

ItemPath
String

项的完全限定 URL,其中包括文件名(在 SharePoint 模式下,还有扩展名)。

ExtensionSettings
ExtensionSettings

一个 ExtensionSettings 对象,该对象包含特定于传递扩展插件的设置的列表。

Description
String

向用户显示的贴切描述。

EventType
String

触发订阅的事件的类型。 有效值是 TimedSubscriptionSnapshotUpdated

MatchData
String

与指定 EventType 参数关联的数据。 此参数由事件使用,用来将订阅与已经激发的事件进行匹配。

Parameters
ParameterValue[]

一个 ParameterValue 对象的数组,该数组包含项的参数列表。

返回

一个订阅 ID,用来在报表服务器数据库或 SharePoint 库内唯一标识订阅。

属性

示例

using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Text;  
using System.Web;  
using System.Web.Services;  
using System.Web.Services.Protocols;  

class Sample  
{  
    static void Main(string[] args)  
    {  
        ReportingService2010 rs = new ReportingService2010();  
        rs.Url = "http://<Server Name>" +  
            "/_vti_bin/ReportServer/ReportService2010.asmx";  
        rs.Credentials =   
            System.Net.CredentialCache.DefaultCredentials;  

        string report = "http://<Server Name>" +  
            "/Docs/Documents/AdventureWorks Sample Reports" +  
            "/Sales Order Detail.rdl";  
        string desc = "Send to Document Library";  
        string eventType = "TimedSubscription";  
        string scheduleXml =  
           @"<ScheduleDefinition>" +  
            "   <StartDateTime>2003-02-24T09:00:00-08:00" +  
            "   </StartDateTime>" +  
            "   <WeeklyRecurrence>" +  
            "      <WeeksInterval>1</WeeksInterval>" +  
            "      <DaysOfWeek>" +  
            "         <Monday>True</Monday>" +  
            "      </DaysOfWeek>" +  
            "   </WeeklyRecurrence>" +  
            "</ScheduleDefinition>";  

        ParameterValue[] extensionParams = new ParameterValue[6];  

        extensionParams[0] = new ParameterValue();  
        extensionParams[0].Name = "RENDER_FORMAT";  
        extensionParams[0].Value = "EXCEL";  

        extensionParams[1] = new ParameterValue();  
        extensionParams[1].Name = "FILENAME";  
        extensionParams[1].Value = "Sales Order Detail";  

        extensionParams[2] = new ParameterValue();  
        extensionParams[2].Name = "FILEEXTN";  
        extensionParams[2].Value = "True";  

        extensionParams[3] = new ParameterValue();  
        extensionParams[3].Name = "PATH";  
        extensionParams[3].Value = "http://<Server Name>" +  
            "/Docs/Documents/AdventureWorks Sample Reports/";  

        extensionParams[4] = new ParameterValue();  
        extensionParams[4].Name = "WRITEMODE";  
        extensionParams[4].Value = "Overwrite";  

        extensionParams[5] = new ParameterValue();  
        extensionParams[5].Name = "AUTOCOPY";  
        extensionParams[5].Value = "False";  

        string matchData = scheduleXml;  
        ExtensionSettings extSettings = new ExtensionSettings();  
        extSettings.ParameterValues = extensionParams;  
        extSettings.Extension = "Report Server DocumentLibrary";  

        try  
        {  
            rs.CreateSubscription(report, extSettings, desc,   
                eventType, matchData, null);  
        }  

        catch (SoapException e)  
        {  
            Console.WriteLine(e.Detail.InnerXml.ToString());  
        }  
    }  
}  
Imports System  
Imports System.IO  
Imports System.Text  
Imports System.Web.Services  
Imports System.Web.Services.Protocols  

Class Sample  

    Public Shared Sub Main()  

        Dim rs As New ReportingService2010()  
        rs.Url = "http://<Server Name>" + _  
            "/_vti_bin/ReportServer/ReportService2010.asmx"  
        rs.Credentials = _  
            System.Net.CredentialCache.DefaultCredentials  

        Dim report As String = "http://<Server Name>/Docs/" + _  
            "Documents/AdventureWorks Sample Reports/" + _  
            "Sales Order Detail.rdl"  
        Dim desc As String = "Send to Document Library"  
        Dim eventType As String = "TimedSubscription"  
        Dim scheduleXml As String = _  
            "<ScheduleDefinition>" + _  
            "   <StartDateTime>2003-02-24T09:00:00-08:00</StartDateTime>" + _  
            "   <WeeklyRecurrence>" + _  
            "      <WeeksInterval>1</WeeksInterval>" + _  
            "      <DaysOfWeek>" + _  
            "         <Monday>True</Monday>" + _  
            "      </DaysOfWeek>" + _  
            "   </WeeklyRecurrence>" + _  
            "</ScheduleDefinition>"  

        Dim extensionParams(6) As ParameterValue  

        extensionParams(0) = New ParameterValue()  
        extensionParams(0).Name = "RENDER_FORMAT"  
       extensionParams(0).Value = "EXCEL"  

        extensionParams(1) = New ParameterValue()  
        extensionParams(1).Name = "FILENAME"  
        extensionParams(1).Value = "Sales Order Detail"  

        extensionParams(2) = New ParameterValue()  
        extensionParams(2).Name = "FILEEXTN"  
        extensionParams(2).Value = "True"  

        extensionParams(3) = New ParameterValue()  
        extensionParams(3).Name = "PATH"  
        extensionParams(3).Value = "http://<Server Name>" + _  
            "/Docs/Documents/AdventureWorks Sample Reports/"  

        extensionParams(4) = New ParameterValue()  
        extensionParams(4).Name = "WRITEMODE"  
        extensionParams(4).Value = "Overwrite"  

        extensionParams(5) = New ParameterValue()  
        extensionParams(5).Name = "AUTOCOPY"  
        extensionParams(5).Value = "False"  

        Dim matchData As String = scheduleXml  
        Dim extSettings As New ExtensionSettings()  
        extSettings.ParameterValues = extensionParams  
        extSettings.Extension = "Report Server DocumentLibrary"  

        Try  
            rs.CreateSubscription(report, extSettings, desc, _  
                eventType, matchData, Nothing)  
        Catch e As SoapException  
            Console.WriteLine(e.Detail.InnerXml.ToString())  
        End Try  

   End Sub  

End Class  

注解

下表显示了有关此操作的标头和权限信息。

SOAP 标头用法 (In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue
本机模式所需权限 ExecuteAndView AND (CreateAnySubscriptionCreateSubscription)
SharePoint 模式所需权限 <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> AND (<xref:Microsoft.SharePoint.SPBasePermissions.ManageAlerts> 或 <xref:Microsoft.SharePoint.SPBasePermissions.CreateAlerts>)

可以使用 GetExtensionSettings 方法检索传递扩展插件的必需设置列表。 必须在 参数中 ExtensionSettings 传递这些必需设置的值。 有关电子邮件传递设置的信息,请参阅Reporting Services传递扩展插件设置

参数的值 EventType 必须与为报表服务器配置的事件相对应。 用于创建订阅的两个事件是 TimedSubscriptionSnapshotUpdatedListEvents使用 方法可返回为报表服务器配置的所有事件的列表。

参数的值 MatchData 取决于事件类型。 如果该事件是事件 TimedSubscription ,则需要对象 ScheduleDefinition 作为 MatchData 参数。 必须先将 ScheduleDefinition 对象序列化为 XML,以便将其作为字符串值传递,并根据计划创建订阅。 XML 结构可能类似于以下示例中的结构:

<ScheduleDefinition>  
   <WeeklyRecurrence>  
      <StartDateTime>2004-06-24T09:00:00-08:00</StartDateTime>  
      <WeeksInterval>1</WeeksInterval>  
      <DaysOfWeek>  
         <Monday>True</Monday>  
         </DaysOfWeek>  
   </WeeklyRecurrence>  
</ScheduleDefinition>  

元素作为 XML 字符串传递时的值 StartDateTime 应对应于日期格式 ISO 8601。 此国际日期和时间标准是扩展格式 CCYY-MM-DDThh:mm:ss+/-Z,其中“CC”表示世纪,“YY”表示年份,“MM”表示月份和“DD”日。 字母“T”是日期和时间分隔符,“hh”、“mm”、“ss”分别表示小时、分钟和秒。 此表示形式可以紧跟“Z”,以指示协调世界时 (UTC) 。 为了指示时区(表示为本地时间与协调世界时之间的差),“Z”前面是一个“+”或“-”符号,后跟表示为 hh:mm 的 UTC 的差值。

如果 的计划 TimedSubscription 定义是共享计划,则必须将共享计划的计划 ID 作为 MatchData 参数传递。 计划 ID 作为 String传递,例如“4608ac1b-fc75-4149-9e15-5a8b5781b843”。 可以通过调用 ListSchedules 方法获取计划 ID。

可以使用 System.Xml.Serialization.XmlSerializer 类自动将对象类转换为 XML 字符串。

如果事件是 SnapshotUpdated 订阅,则 的值 MatchDatanull (或 Nothing Visual Basic) 中。

使用此方法时,它将订阅的 属性设置为 ,将订阅的 属性设置为 LastExecutedSpecifiednew subscription,并将订阅Active对象的所有属性设置为 falseStatusfalse 报表 ModifiedBy 的 和 ModifiedDate 属性也会更新。

参数中指定的 MatchData 任何计划都必须位于同一站点和 中 ItemPath

适用于