locked
Subscription RRS feed

  • Question

  • Hello,

    is it possible to make a new subscription remote over a website and NOT in the Reportmanager?

    Has anybody done something like this and are there any examples?

     

    Thx

    Jo-Jo

    Thursday, December 7, 2006 8:18 AM

Answers

  • Yes,

    You can use the rs.exe with your VB script file save with a "rss" extension, for example mynewscript.rss.

    rs –i mynewscript.rss -s http://servername/reportserver

    Code sample:

          rs.Credentials = System.Net.CredentialCache.DefaultCredentials

          Dim report As String = "/SampleReports/Employee Sales Summary"
          Dim desc As String = "Send email to anyone@microsoft.com"
          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></ScheduleDefinition>"

          Dim extensionParams(7) As ParameterValue

          extensionParams(0) = New ParameterValue()
          extensionParams(0).Name = "TO"
          extensionParams(0).Value = "dank@adventure-works.com"

          extensionParams(1) = New ParameterValue()
          extensionParams(1).Name = "ReplyTo"
          extensionParams(1).Value = "reporting@adventure-works.com"

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

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

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

          extensionParams(5) = New ParameterValue()
          extensionParams(5).Name = "Comment"
          extensionParams(5).Value = "Here is your daily sales report for Michael."

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

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

          Dim parameter As New ParameterValue()
          parameter.Name = "EmpID"
          parameter.Value = "38"

          Dim parameters(1) As ParameterValue
          parameters(0) = parameter


         rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters)

    I hope this help.

     

    PS - The sample is not complete, its only showing you the scripting protential

     

    Ham

    Thursday, December 7, 2006 3:38 PM
  • Regarding your question about schedule XML:  generally you need to use XmlSerializer to convert ScheduleDefinition object into xml. This one looks like a good sample: http://www.odetocode.com/Articles/114.aspx

    Below are some working examples:

    <ScheduleDefinition>
    <StartDateTime>2006-10-01T16:00:00.000-07:00</StartDateTime>
    <EndDate>2006-10-02</EndDate>
    <MinuteRecurrence>
    <MinutesInterval>60</MinutesInterval>
    </MinuteRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2006-04-27T02:00:00-07:00</StartDateTime>
    <DailyRecurrence>
    <DaysInterval>1</DaysInterval>
    </DailyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2005-04-03T08:00:00.000-07:00</StartDateTime>
    <WeeklyRecurrence><WeeksInterval>1</WeeksInterval>
    <DaysOfWeek>
    <Monday>True</Monday>
    </DaysOfWeek>
    </WeeklyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2006-08-18T07:00:00.000-07:00</StartDateTime>
    <MonthlyRecurrence>
    <Days>1,15</Days>
    <MonthsOfYear>
    <January>true</January>
    <February>true</February>
    </MonthsOfYear>
    </MonthlyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2005-12-06T02:00:00.000-08:00</StartDateTime>
    <MonthlyDOWRecurrence>
    <WhichWeek>LastWeek</WhichWeek>
    <DaysOfWeek><Saturday>true</Saturday></DaysOfWeek>
    <MonthsOfYear>
    <January>true</January>
    <February>true</February>
    </MonthsOfYear>
    </MonthlyDOWRecurrence>
    </ScheduleDefinition>

     

     

    Tuesday, December 12, 2006 4:49 PM
    Answerer

All replies

  • Jo-Jo-

    You'll need to use the CreateSubscription method of the web service API. There is an example in the RS BOL in both C# and VB.Net. I currently use this method along with ListSubscriptions and DeleteSubscription methods to let end users manage their subscription through our web portal.

    HTH.

    Regards,

    Scott

    Thursday, December 7, 2006 3:31 PM
  • Yes,

    You can use the rs.exe with your VB script file save with a "rss" extension, for example mynewscript.rss.

    rs –i mynewscript.rss -s http://servername/reportserver

    Code sample:

          rs.Credentials = System.Net.CredentialCache.DefaultCredentials

          Dim report As String = "/SampleReports/Employee Sales Summary"
          Dim desc As String = "Send email to anyone@microsoft.com"
          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></ScheduleDefinition>"

          Dim extensionParams(7) As ParameterValue

          extensionParams(0) = New ParameterValue()
          extensionParams(0).Name = "TO"
          extensionParams(0).Value = "dank@adventure-works.com"

          extensionParams(1) = New ParameterValue()
          extensionParams(1).Name = "ReplyTo"
          extensionParams(1).Value = "reporting@adventure-works.com"

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

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

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

          extensionParams(5) = New ParameterValue()
          extensionParams(5).Name = "Comment"
          extensionParams(5).Value = "Here is your daily sales report for Michael."

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

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

          Dim parameter As New ParameterValue()
          parameter.Name = "EmpID"
          parameter.Value = "38"

          Dim parameters(1) As ParameterValue
          parameters(0) = parameter


         rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters)

    I hope this help.

     

    PS - The sample is not complete, its only showing you the scripting protential

     

    Ham

    Thursday, December 7, 2006 3:38 PM
  • Thanks a lot! It works fine!

    But now I have another point:

    How does the XML schema look like? For example that I can create a hourly or monthly schedule?

    Thanks again!

     

    Jo-Jo

    Tuesday, December 12, 2006 7:26 AM
  • JoJo,

     

    I happy it worked out for you. Can you mark this as answered so that other will use the post as a resource. On your last, yes you can create a schedule for hourly and monthly reports, it's part of the schedule definition but I'm not sure what the XSD file looks like, I have not create a schedule for myself. I use the rss file mainly for publishing SSRS reports.

     

    Ham

    Tuesday, December 12, 2006 2:29 PM
  • Regarding your question about schedule XML:  generally you need to use XmlSerializer to convert ScheduleDefinition object into xml. This one looks like a good sample: http://www.odetocode.com/Articles/114.aspx

    Below are some working examples:

    <ScheduleDefinition>
    <StartDateTime>2006-10-01T16:00:00.000-07:00</StartDateTime>
    <EndDate>2006-10-02</EndDate>
    <MinuteRecurrence>
    <MinutesInterval>60</MinutesInterval>
    </MinuteRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2006-04-27T02:00:00-07:00</StartDateTime>
    <DailyRecurrence>
    <DaysInterval>1</DaysInterval>
    </DailyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2005-04-03T08:00:00.000-07:00</StartDateTime>
    <WeeklyRecurrence><WeeksInterval>1</WeeksInterval>
    <DaysOfWeek>
    <Monday>True</Monday>
    </DaysOfWeek>
    </WeeklyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2006-08-18T07:00:00.000-07:00</StartDateTime>
    <MonthlyRecurrence>
    <Days>1,15</Days>
    <MonthsOfYear>
    <January>true</January>
    <February>true</February>
    </MonthsOfYear>
    </MonthlyRecurrence>
    </ScheduleDefinition>

    <ScheduleDefinition>
    <StartDateTime>2005-12-06T02:00:00.000-08:00</StartDateTime>
    <MonthlyDOWRecurrence>
    <WhichWeek>LastWeek</WhichWeek>
    <DaysOfWeek><Saturday>true</Saturday></DaysOfWeek>
    <MonthsOfYear>
    <January>true</January>
    <February>true</February>
    </MonthsOfYear>
    </MonthlyDOWRecurrence>
    </ScheduleDefinition>

     

     

    Tuesday, December 12, 2006 4:49 PM
    Answerer
  • Hi,

    I have two more questions:

    1.) Does anybody know how the xml schema for running the report only once does look like

    2.) Is there a possibility to delete the subscriptions over a website (I list the entered subsciptions, and over a button, the selected subscription should be deleted)

    Thanks again!

    Friday, December 15, 2006 9:26 AM
  • Not sure what you meant by "xml schema for running the report only once".

    For second question:  in Report manager you can list and delete subscriptions either via My Subscriptions (created by you) or via the report's subscriptions accessible via Subscriptions tab when you run report.

    Monday, December 18, 2006 6:30 PM
    Answerer
  • To answer xml schema for running the report only once.

    <ScheduleDefinition><StartDateTime>2007-02-05T08:00:00.000-08:00</StartDateTime></ScheduleDefinition>

    its easy to get this xml code. Manually create a subscription, goto ReportServer Database and select * from subscriptions

    look in ExtensionSettings and you will find the XML Code there, copy and paste that in your subscription code(.rss file).

     

     

     

    Monday, February 5, 2007 6:54 PM