Wednesday, March 21, 2012

GetDataDrivenSubscriptionProperties vs GetSubscriptionProperties

Is there a similar method for Data Driven Subscriptions like there is for plain subscriptions ListSubscriptions. I would like to get SubscriptionID for use with the GetDataDrivenSubscriptionProperties just as I do for GetSubscriptionProperties. When I execute GetSubscriptionProperties for Data Driven Subscriptions there is no array of Subscriptions.

Here is an examole of the code which I execute using rs.exe:

Sub Main()
'Dim rs As New ReportingService()
'rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim DRPlan As DataRetrievalPlan
Dim extSettings As ExtensionSettings
Dim desc As String
Dim active As ActiveState
Dim status As String
Dim eventType As String
Dim matchData As String
Dim values As ParameterValue() = Nothing
Dim subscriptions As Subscription() = Nothing
Dim extensionParams As ParameterValueOrFieldReference() = Nothing

Try
subscriptions = rs.ListSubscriptions("/SecLend Monthly Statements/CLS0001-Client Statement Package V1", "MWDOMAIN\asingh")
' subscriptions = rs.ListSubscriptions("/Risk Management/ALD1701-AldStatistics", Nothing)


If Not (subscriptions Is Nothing) Then
Console.WriteLine("not subscriptions Is Nothing")

' Retrieve properties for the first subscription in the list.

Dim subx As Subscription

For Each subx In subscriptions

if subx.IsDataDriven = false then
Console.WriteLine("not IsDataDriven")
rs.GetSubscriptionProperties(subx.SubscriptionID, extSettings, desc, active, status, eventType, matchData, values)
else
Console.WriteLine("IsDataDriven")
rs.GetDataDrivenSubscriptionProperties(subx.SubscriptionID, extSettings, DRPlan, desc, active, status, eventType, matchData, values)
end if


Console.WriteLine("Description: {0}", desc)
Console.WriteLine("Status: {0}", status)
Console.WriteLine("EventType: {0}", eventType)
Console.WriteLine("matchData: {0}", matchData)
Console.WriteLine("Extension: {0}", extSettings.Extension)

extensionParams = extSettings.ParameterValues

If Not (extensionParams Is Nothing) Then
Dim extensionParam As ParameterValueOrFieldReference
For Each extensionParam In extensionParams
Console.WriteLine((CType(extensionParam, ParameterValue).Name + ": " + CType(extensionParam, ParameterValue).Value))
Next extensionParam
End If

If Not (values Is Nothing) Then
Dim pv As ParameterValue
For Each pv In values
Console.WriteLine("Name: {0}", pv.Name)
Console.WriteLine("Value: {0}", pv.Value)
Next pv
End If
Next subx
End If

Catch e As SoapException
Console.WriteLine(e.Detail.OuterXml)
End Try
End Sub 'Main

Please let me know if anybody has any ideas on how I can get GetDataDrivenSubscriptionProperties if I don't have the SubscriptionID.

Elias

ListSubscriptions will list all subscriptions of a report including data driven subscriptions. Check out the link below. Also, I'm not sure if I'm missing something here because you already have theSubscriptionId that you can use with GetDataDrivenSubscriptionProperties. Please let me know what I'm missing here.

http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.listsubscriptions.aspx

Thanks,
Sharmila

|||

Sharmila,

My experiance is when I do a rs.ListSubscriptions on a report that has Data driven Subscriptions then the statement "For Each subx In subscriptions" does not find any subscriptions and never falls into the for each loop. On a plain Subscriptions it does loop around for each subscription.

It seems that rs.ListSubscriptions does not work with Data driven Subscriptions.

Thanks

Elias

|||

It could be that the current user does not have sufficient permissions. From the link I sent earlier:

If only the Report parameter is submitted, the method returns all subscriptions for all users of the specified report that the current user has permission to view.

Can you check if the user that makes the ListSubscriptions API call has "View Reports" and "Manage All Subscriptions" permissions?

Thanks,
Sharmila

|||

I changed:

subscriptions = rs.ListSubscriptions("/SecLend Monthly Statements/CLS0001-Client Statement Package V1", "MWDOMAIN\asingh")

to

subscriptions = rs.ListSubscriptions("/SecLend Monthly Statements/CLS0001-Client Statement Package V1", Nothing)

Now I am getting subscriptions. But when it reaches a data driven subscription and executes the following line:

rs.GetDataDrivenSubscriptionProperties(subx.SubscriptionID, extSettings, DRPlan, desc, active, status, eventType, matchData, values)

it gets an error message of:

Unhandled exception:
Specified cast is not valid.

Any Ideas?

Thanks

Elias

|||

You need to pass in "extensionParams " instead of "values" for GetDataDrivenSubscriptionProperties. See documentation below.

http://msdn2.microsoft.com/de-de/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.getdatadrivensubscriptionproperties.aspx

Hope this helps,

Sharmila

|||

Sharmila,

Sorry I didn't get back till now. but I was out of town.

I am still having a problem. My problem is with data driven Subscriptions.

I am getting the following error:

Unhandled exception:
Specified cast is not valid.

This error is only for Data Driven Subscriptions.

I get this error on either line of code

Console.WriteLine((CType(extensionParam, ParameterValue).Name + ": " + CType(extensionParam, ParameterValue).Value))

or

Console.WriteLine((CType(pv2, ParameterValue).Name + ": " + CType(pv2, ParameterValue).Value))

Here is the code:

Sub Main()
'Dim rs As New ReportingService()
'rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim DRPlan As DataRetrievalPlan
Dim extSettings As ExtensionSettings
Dim desc As String
Dim active As ActiveState
Dim status As String
Dim eventType As String
Dim matchData As String
Dim values As ParameterValue() = Nothing
Dim subscriptions As Subscription() = Nothing
Dim extensionParams As ParameterValueOrFieldReference() = Nothing
Dim values2 As ParameterValueOrFieldReference() = Nothing
Dim values2Params As ParameterValueOrFieldReference() = Nothing

Try
subscriptions = rs.ListSubscriptions("/SecLend Monthly Statements/CLS0001-Client Statement Package V1", Nothing)
' subscriptions = rs.ListSubscriptions("/Risk Management/ALD1701-AldStatistics", Nothing)

If Not (subscriptions Is Nothing) Then
Console.WriteLine("not subscriptions Is Nothing")

Dim subx As Subscription

For Each subx In subscriptions


if subx.IsDataDriven = false then
Console.WriteLine("not IsDataDriven")
rs.GetSubscriptionProperties(subx.SubscriptionID, extSettings, desc, active, status, eventType, matchData, values)
else
Console.WriteLine("IsDataDriven")
rs.GetDataDrivenSubscriptionProperties(subx.SubscriptionID, extSettings, DRPlan, desc, active, status, eventType, matchData, values2)
end if


Console.WriteLine("Description: {0}", desc)
Console.WriteLine("Status: {0}", status)
Console.WriteLine("EventType: {0}", eventType)
Console.WriteLine("matchData: {0}", matchData)
Console.WriteLine("Extension: {0}", extSettings.Extension)

extensionParams = extSettings.ParameterValues

If Not (extensionParams Is Nothing) Then
Dim extensionParam As ParameterValueOrFieldReference
For Each extensionParam In extensionParams
Console.WriteLine((CType(extensionParam, ParameterValue).Name + ": " + CType(extensionParam, ParameterValue).Value))
Next extensionParam
End If


if subx.IsDataDriven = false then
If Not (values Is Nothing) Then
Dim pv As ParameterValue
For Each pv In values
Console.WriteLine(pv.Name + ": " + pv.Value)
Next pv
End If
Else
If Not (values2 Is Nothing) Then
Dim pv2 As ParameterValueOrFieldReference
'Dim pv As ParameterValue
For Each pv2 In values2
Console.WriteLine((CType(pv2, ParameterValue).Name + ": " + CType(pv2, ParameterValue).Value))
Next pv2
End If
End If

Next subx
End If

Catch e As SoapException
Console.WriteLine(e.Detail.OuterXml)
End Try
End Sub 'Main

Elias

|||

Hi Elias,

Try the following for data driven subscriptions. I'm sure you can translate this to VB.

foreach (ParameterValueOrFieldReference extensionParam in extensionParams)

{

if (extensionParam is ParameterFieldReference)

{

Console.WriteLine(((ParameterFieldReference)extensionParam).ParameterName + ": " + ((ParameterFieldReference)extensionParam).FieldAlias);

}

else

{

Console.WriteLine(((ParameterValue)extensionParam).Name + ": " + ((ParameterValue)extensionParam).Value);

}

}

Hope this helps,

Sharmila

|||

Hi Sharmila,

I am having a problem figuring out how to test extensionParam if is ParameterFieldReference or ParameterValue in VB.

Please help.

Elias

|||

Hi Elias,

I think you need to use TypeOf: See http://msdn2.microsoft.com/en-us/library/0ec5kw18(VS.80).aspx for more info.

If TypeOf extensionParam Is ParameterFieldReference Then ....

Thanks,

Sharmila

|||

Sharmila,

Thanks, I finally got it to work. Your help was very much appreciated.

Elias

No comments:

Post a Comment