开发者

Add a Parameter Value in SSRS

I have a report already setup on the ReportServer. And its subscription as well. What I'm trying to do is add the ParameterValue "CC" and some email addresses then send the email out. It doesn't seem to work.

My code:

Dim emailReader As SqlDataReader = selCount.ExecuteReader
Dim emailsTest As List(Of String) = New List(Of String)
emailsTest.Add("test1@pen.com")
emailsTest.Add("test2@pen.com")
emailsTest.Add("test3@pen.com")
emailsTest.Add("test4@pen.com")
If emailReader.HasRows() Then 'checks to see if there any quotes in query

    For Each subscrp As rs.Subscription In subscr
        Dim allV开发者_StackOverflow社区alues = subscrp.DeliverySettings.ParameterValues
        Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()
        Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
        CCParameter.Name = "CC"
        CCParameter.Value = String.Empty
        allValuesList.Add(CCParameter)
        Dim toValue = CType(allValuesList.Item(7), ReportTriggerTemplate1.rs.ParameterValue)

        For Each testEmail As String In emailsTest
            Dim ownerEmail As String = testEmail
            If toValue.Value.Contains(ownerEmail) Then
                'skip
            ElseIf toValue.Value = String.Empty Then
                toValue.Value += ownerEmail
            Else
                toValue.Value += "; " & ownerEmail
            End If
        Next
        subscrp.DeliverySettings.ParameterValues = allValuesList.ToArray()
        Dim hello As String = "hi"
        tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent
    Next

What I'm adding to toValue.Value doesn't seem to be adding to the report's CC subscription field at all. So what am I missing?


http://msdn.microsoft.com/en-us/library/ms154020%28v=SQL.100%29.aspx

http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.getsubscriptionproperties.aspx

http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.setsubscriptionproperties%28v=SQL.105%29.aspx

 Try
        tr = New rs.ReportingService2005
        Dim extSettings As ExtensionSettings = Nothing
        Dim desc As String = Nothing
        Dim active As ActiveState = Nothing
        Dim status As String = Nothing
        Dim matchData As String = Nothing
        Dim values As ParameterValue() = Nothing
        Dim extensionParams As ParameterValueOrFieldReference() = Nothing

        Dim mainLogin As System.Net.NetworkCredential = New System.Net.NetworkCredential("ADUser", "Password", "NetworkName")
        If mainLogin Is Nothing Then
            tr.Credentials = System.Net.CredentialCache.DefaultCredentials
        Else
            tr.Credentials = mainLogin
        End If

'skip to relevant code

        For Each subscrp As rs.Subscription In subscr

                Dim allValues = subscrp.DeliverySettings.ParameterValues
                Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()

                If CType(allValuesList.Item(0), ReportTriggerTemplate1.rs.ParameterValue).Value = "test@pen.com" Then
                    Dim subsID = subscrp.SubscriptionID
                    'important code just below
                    tr.GetSubscriptionProperties(subsID, extSettings, desc, active, status, EventType, matchData, extensionParams)

                    ''''add change to CC here
                    Dim extSettingsList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = extSettings.ParameterValues.ToList()
                    If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Name = "CC" Then
                        If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = String.Empty Then
                            CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
                        Else
                            CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value += ";" & emailsTest.Item(0) & ";" & emailsTest.Item(1)
                        End If
                    Else
                        Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
                        CCParameter.Name = "CC"
                        CCParameter.Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
                        extSettingsList.Insert(1, CCParameter)
                        extSettings.ParameterValues = extSettingsList.ToArray
                    End If
                    'important code just below
                    tr.SetSubscriptionProperties(subsID, extSettings, desc, EventType, matchData, extensionParams)

                    tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent

                Else


                End If

         Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜