ReportingService2006.CreateSubscription(String, ExtensionSettings, String, String, String, ParameterValue[]) ReportingService2006.CreateSubscription(String, ExtensionSettings, String, String, String, ParameterValue[]) Method


在报表服务器数据库中创建对指定报表的订阅。 Creates a subscription for the specified report in the report server database.

 System::String ^ CreateSubscription(System::String ^ Report, ReportService2006::ExtensionSettings ^ ExtensionSettings, System::String ^ Description, System::String ^ EventType, System::String ^ MatchData, cli::array <ReportService2006::ParameterValue ^> ^ Parameters);
public string CreateSubscription (string Report, ReportService2006.ExtensionSettings ExtensionSettings, string Description, string EventType, string MatchData, ReportService2006.ParameterValue[] Parameters);


String String

报表的完全限定 URL,其中包括文件名和 .rdl 文件扩展名。 The fully qualified URL of the report including the file name and .rdl file name extension.

ExtensionSettings ExtensionSettings
ExtensionSettings对象,其中包含特定于传递扩展插件的设置的列表。 An ExtensionSettings object that contains a list of settings that are specific to the delivery extension.
String String

向用户显示的贴切描述。 A meaningful description that is displayed to users.

String String

触发订阅的事件的类型。 The type of event that triggers the subscription. 有效的值是TimedSubscriptionSnapshotUpdated The valid values are TimedSubscription or SnapshotUpdated.

String String

与指定的关联的数据EventType参数。 The data that is associated with the specified EventType parameter. 此参数由事件使用,用来将订阅与已经激发的事件进行匹配。 This parameter is used by an event to match the subscription with an event that has fired.


一个数组ParameterValue包含的报表的参数列表的对象。 An array of ParameterValue objects that contains a list of parameters for the report.


一个订阅 ID,该值用于唯一标识 SharePoint 库中的订阅。 A subscription ID that uniquely identifies the subscription in the SharePoint library.


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)  
        ReportingService2006 rs = new ReportingService2006();  
        rs.Url = "http://<Server Name>" +  
        rs.Credentials =   
        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>" +  
        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";  
            rs.CreateSubscription(report, extSettings, desc,   
                eventType, matchData, null);  
        catch (SoapException e)  
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 ReportingService2006()  
        rs.Url = "http://<Server Name>" + _  
        rs.Credentials = _  
        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>" + _  
        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"  
            rs.CreateSubscription(report, extSettings, desc, _  
                eventType, matchData, Nothing)  
        Catch e As SoapException  
        End Try  
    End Sub  
End Class  


下表显示了有关此操作的标头和权限信息。The table below shows header and permissions information on this operation.

SOAP 标头SOAP Headers (In) TrustedUserHeaderValue(In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue(Out) ServerInfoHeaderValue
所需的权限Required Permissions ViewListItems 和 (ManageAlertsCreateAlerts)ViewListItems AND (ManageAlerts OR CreateAlerts)

可以使用GetExtensionSettings方法来检索的列表所需的传递扩展插件的设置。You can use the GetExtensionSettings method to retrieve a list of required settings for a delivery extension. 您必须将值传递这些所需的设置中为ExtensionSettings参数。You must pass values for these required settings in the ExtensionSettings parameter. 有关电子邮件传递设置的信息,请参阅Reporting Services 传递扩展插件设置For information about e-mail delivery settings, see Reporting Services Delivery Extension Settings.

EventType参数必须对应于为报表服务器配置的事件。The value of the EventType parameter must correspond to an event that is configured for the report server. 用于创建订阅的两个事件都TimedSubscriptionSnapshotUpdatedThe two events that are used to create subscriptions are TimedSubscription and SnapshotUpdated. 使用ListEvents方法以返回为报表服务器配置的所有事件的列表。Use the ListEvents method to return a list of all events configured for the report server.

MatchData参数取决于事件类型。The value of the MatchData parameter depends on the event type. 如果该事件TimedSubscription事件,ScheduleDefinition对象是必需的因为MatchData参数。If the event is a TimedSubscription event, a ScheduleDefinition object is required as the MatchData parameter. 您必须首先进行序列化ScheduleDefinition对象作为 XML 以便将其作为一个字符串值传递并创建订阅基于计划。You must first serialize the ScheduleDefinition object as XML in order to pass it as a string value and create a subscription based on the schedule. XML 结构可能类似于下面的示例所示:The XML structure might resemble the one in the following example:


StartDateTime元素作为 XML 字符串传递时应该对应于 ISO 8601 的日期格式。The value of the StartDateTime element when it is passed as an XML string should correspond to the date format ISO 8601. 此国际日期和时间标准是扩展的格式 CCYY-MM-DDThh:mm:ss + /-其中"CC"表示世纪,"YY"年份"MM"每月的 Z 和"DD"一天。This international date and time standard is the extended format CCYY-MM-DDThh:mm:ss+/-Z where "CC" represents the century, "YY" the year, "MM" the month and "DD" the day. 字母"T"的日期和时间分隔符,"hh"、"mm"、"ss"表示小时、 分钟和分别的第二个。The letter "T" is the date and time separator and "hh", "mm", "ss" represent hour, minute and second respectively. 这种表示形式可以被其后紧接"Z"指示协调世界时 (UTC)。This representation can be immediately followed by a "Z" to indicate Coordinated Universal Time (UTC). 若要指示时区,表示为本地时间和协调世界时之间的区别"Z"的前面有"+"或"-"号后, 跟表示为 hh: mm 的与 UTC 的差异。To indicate the time zone, represented as the difference between the local time and Coordinated Universal Time, "Z" is preceded by a "+" or "-" sign, followed by the difference from UTC represented as hh:mm.

如果计划定义TimedSubscription是共享的计划,必须通过为该共享计划的计划 IDMatchData参数。If the schedule definition for a TimedSubscription is a shared schedule, you must pass the schedule ID of the shared schedule as the MatchData parameter. 作为传递 ID 的计划String,例如,"4608ac1b-fc75-4149-9e15-5a8b5781b843"。The schedule ID is passed as a String, for example, "4608ac1b-fc75-4149-9e15-5a8b5781b843". 可以通过调用获取 ID 的计划ListSchedules方法。The schedule ID can be obtained by calling the ListSchedules method.

可以使用System.Xml.Serialization.XmlSerializer类将自动转换为一个 XML 字符串的对象类。You can use the System.Xml.Serialization.XmlSerializer class to convert your object class to an XML string automatically.

如果该事件SnapshotUpdated订阅,值MatchDatanull(或Nothing在 Visual Basic 中)。If the event is a SnapshotUpdated subscription, the value of MatchData should be null (or Nothing in Visual Basic).

使用此方法时,它将设置LastExecutedSpecified到订阅的属性false,则Status到订阅的属性new subscription,和的订阅的所有属性Active对象传递给falseWhen this method is used, it will set the LastExecutedSpecified property of the subscription to false, the Status property of the subscription to new subscription, and all properties of the subscription’s Active object to false. ModifiedByModifiedDate也会更新报表的属性。The ModifiedBy and ModifiedDate properties of the report are also updated.

中指定任何计划MatchData参数必须是同一站点中和ReportAny schedule specified in the MatchData parameter must be in the same site and the Report.