Wednesday, March 7, 2012

Report Server FileShare Subscription example

I write .net code to create subsciption instead of report manager. Is there
any example talking about Subscription using Report Server FileShare ? I
only find the example of Report Server Email subscription in Books online. I
try the following code and I successfully create subscription. But when I
try to edit it, error is shown - "Object reference not set to an instance of
an object"
The code is as follows:
Dim FileNamePara As New ParameterValue
FileNamePara.Name = "File Name"
FileNamePara.Value = "Invoice Summary "
extensionParams(0) = FileNamePara
Dim PathPara As New ParameterValue
PathPara.Name = "Path"
PathPara.Value = "\\shkg013devfs\temp\may"
extensionParams(1) = PathPara
Dim renderPara As New ParameterValue
renderPara.Name = "RenderFormat"
renderPara.Value = "PDF"
extensionParams(2) = renderPara
settings.ParameterValues = extensionParams
Dim datRptGenTime As Date
datRptGenTime = DateAdd(DateInterval.Day, 1, Now)
Dim eventType As String = "TimedSubscription"
Dim matchData As String = "<ScheduleDefinition>" & _
"<StartDateTime>" & datRptGenTime.Year & "-" & _
IIf(datRptGenTime.Month < 10, "0" & datRptGenTime.Month,
datRptGenTime.Month) & "-" & _
IIf(datRptGenTime.Day < 10, "0" & datRptGenTime.Day, datRptGenTime.Day) &
"T08:00:00" & _
"+08:00</StartDateTime>" & _
"</ScheduleDefinition>"
Try
mRSProxyUtil.rs.CreateSubscription(ReportName, settings, sEmaiDesc,
eventType, matchData, parameters)
Catch e As SoapException
Console.WriteLine(e.Detail.InnerText.ToString())
End TryI'm not sure why you are getting the object reference error. Is RS
returning it?
Anyway, you are not using the correct setting names. To find the correct
names call GetExtensionSettings. This will return a list of extension names
that the extension excepts. There is a flag that will tell you if the
setting is required or not.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"May Liu" <MayLiu@.discussions.microsoft.com> wrote in message
news:E022B2B3-B882-4E6D-A836-03CC0AE19675@.microsoft.com...
>I write .net code to create subsciption instead of report manager. Is
>there
> any example talking about Subscription using Report Server FileShare ?
> I
> only find the example of Report Server Email subscription in Books online.
> I
> try the following code and I successfully create subscription. But when I
> try to edit it, error is shown - "Object reference not set to an instance
> of
> an object"
> The code is as follows:
> Dim FileNamePara As New ParameterValue
> FileNamePara.Name = "File Name"
> FileNamePara.Value = "Invoice Summary "
> extensionParams(0) = FileNamePara
> Dim PathPara As New ParameterValue
> PathPara.Name = "Path"
> PathPara.Value = "\\shkg013devfs\temp\may"
> extensionParams(1) = PathPara
> Dim renderPara As New ParameterValue
> renderPara.Name = "RenderFormat"
> renderPara.Value = "PDF"
> extensionParams(2) = renderPara
> settings.ParameterValues = extensionParams
> Dim datRptGenTime As Date
> datRptGenTime = DateAdd(DateInterval.Day, 1, Now)
> Dim eventType As String = "TimedSubscription"
> Dim matchData As String = "<ScheduleDefinition>" & _
> "<StartDateTime>" & datRptGenTime.Year & "-" & _
> IIf(datRptGenTime.Month < 10, "0" & datRptGenTime.Month,
> datRptGenTime.Month) & "-" & _
> IIf(datRptGenTime.Day < 10, "0" & datRptGenTime.Day, datRptGenTime.Day) &
> "T08:00:00" & _
> "+08:00</StartDateTime>" & _
> "</ScheduleDefinition>"
> Try
> mRSProxyUtil.rs.CreateSubscription(ReportName, settings, sEmaiDesc,
> eventType, matchData, parameters)
> Catch e As SoapException
> Console.WriteLine(e.Detail.InnerText.ToString())
> End Try

No comments:

Post a Comment