SSRS订阅,BatchHead参数

时间:2012-10-10 17:24:07

标签: reporting-services ssrs-2008

我正在尝试使用Web服务创建订阅,该方法不会抛出任何异常,但也不会创建订阅。

搜索我在大多数论坛和帮助文件中看到的信息,CreateSubscription方法不要求批处理标题,但是我的要求是这样,所以我认为这可能与我的安装有关。< / p>

这是我的代码。

Dim rs As New reportingReference.ReportingService2005SoapClient
    rs.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials
    'rs.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation


    rs.ClientCredentials.Windows.AllowedImpersonationLevel = New System.Security.Principal.TokenImpersonationLevel()

    Dim batchID As String = String.Empty
    Dim infoHeader As ServerInfoHeader = rs.CreateBatch(batchID)
    Dim bh As BatchHeader = New BatchHeader()

    bh.BatchID = batchID
    bh.AnyAttr = infoHeader.AnyAttr

    Dim report As String = "/reportParam1"
    Dim desc As String = "Send email from code to Hisham@comsoft.com"
    Dim eventType As String = "TimedSubscription"

    Dim scheduleXml As String = "<ScheduleDefinition><StartDateTime>2012-03-22T09:30:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Thursday>True</Thursday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
    '"<ScheduleDefinition><StartDateTime>2012-10-06T08:00:00-08:00</StartDateTime><WeeklyRecurrence>" & _
    '"<WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>" ' "<ScheduleDefinition xmlns:xsd=\""http://www.w3.org/2001/XMLSchema\"" xmlns:xsi=\""http://www.w3.org/2001/XMLSchema-instance\""><StartDateTime xmlns=\""http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\"">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>"

    Dim extensionParams(7) As ParameterValue

    extensionParams(0) = New ParameterValue()
    extensionParams(0).Name = "TO"
    extensionParams(0).Value = "rocha@costarricense.cr"

    extensionParams(1) = New ParameterValue()
    extensionParams(1).Name = "IncludeReport"
    extensionParams(1).Value = "True"

    extensionParams(2) = New ParameterValue()
    extensionParams(2).Name = "RenderFormat"
    extensionParams(2).Value = "MHTML"

    extensionParams(3) = New ParameterValue()
    extensionParams(3).Name = "Subject"
    extensionParams(3).Value = "@ReportName was executed at @ExecutionTime"

    extensionParams(4) = New ParameterValue()
    extensionParams(4).Name = "Comment"
    extensionParams(4).Value = "Here is your test report for testing purpose"

    'extensionParams(5) = New ParameterValue()
    'extensionParams(5).Name = "IncludeLink"
    'extensionParams(5).Value = "True"

    extensionParams(5) = New ParameterValue()
    extensionParams(5).Name = "Priority"
    extensionParams(5).Value = "NORMAL"

    Dim parameters(0) As ParameterValue

    parameters(0) = New ParameterValue()
    parameters(0).Name = "ReportParameter1"
    parameters(0).Value = "ReportParameter1"

    'parameters(1) = New ParameterValue()
    'parameters(1).Name = "UserName"
    'parameters(1).Value = "admin"

    'parameters(2) = New ParameterValue()
    'parameters(2).Name = "SupplierId"
    'parameters(2).Value = "0"

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

        Dim _sub As String = ""
        Dim SubID As ServerInfoHeader = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, _sub)

        rs.FireEvent(bh, "TimedSubscription", _sub)

    Catch ex As Exception
        Console.WriteLine(ex)
    End Try

1 个答案:

答案 0 :(得分:0)

我找到了一份工作。

相反,使用2005 WS我将其更改为2010,如本文所述

Automatically set up user's subscription in SSRS

它有效。

这是代码。

 Private Sub Suscription2010()
    Dim service As New ServiceReference1.ReportingService2010SoapClient()
    service.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials
    service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation

    Dim userHeader As New ServiceReference1.TrustedUserHeader()


    Dim desc As String = "Send to Document Library"
    Dim eventType As String = "TimedSubscription"
    Dim scheduleXml As String = "<ScheduleDefinition>" + _
    "   <StartDateTime>2010-11-30T08:00:00-08:00" + _
    "   </StartDateTime>" + _
    "   <WeeklyRecurrence>" + _
    "      <WeeksInterval>1</WeeksInterval>" + _
    "      <DaysOfWeek>" + _
    "         <Monday>True</Monday>" + _
    "      </DaysOfWeek>" + _
    "   </WeeklyRecurrence>" + _
    "</ScheduleDefinition>"

    Dim extensionParams(4) As ServiceReference1.ParameterValue

    extensionParams(0) = New ServiceReference1.ParameterValue()
    extensionParams(0).Name = "TO"
    extensionParams(0).Value = "my alias"

    extensionParams(1) = New ServiceReference1.ParameterValue()
    extensionParams(1).Name = "IncludeReport"
    extensionParams(1).Value = "FALSE"

    extensionParams(2) = New ServiceReference1.ParameterValue()
    extensionParams(2).Name = "IncludeLink"
    extensionParams(2).Value = "TRUE"

    extensionParams(3) = New ServiceReference1.ParameterValue()
    extensionParams(3).Name = "Subject"
    extensionParams(3).Value = "@ReportName was executed at @ExecutionTime"



    Dim matchData As String = scheduleXml
    Dim extSettings As New ServiceReference1.ExtensionSettings
    extSettings.ParameterValues = extensionParams
    extSettings.Extension = "Report Server Email"

    Dim id As String

    service.CreateSubscription(userHeader, "/reportname", extSettings, desc, eventType, matchData, Nothing, id)
End Sub