Showing posts with label programatically. Show all posts
Showing posts with label programatically. Show all posts

Friday, March 9, 2012

Deploying RDL file Programatically

Hi,

I am able to create a rdl file programatically.I want to deploy the RDL file programatically in Report Server.Any help is appreciated.

Thanks,

Prabu

Hi Prabu,

I came across this link previously concerning about your question. It is writtent in c# though, so you might need some time to "translate" it to VB. Other than that, it will teach ya to do what you need to do.

http://www.codeproject.com/sqlrs/SQLReportDeploy.asp

Good luck !

|||

Hi,

Thanks for you help.

I am using web application.Using that I am creating an RDL file.And I want to deploy the RDL file using Web application not through console application.

The link is having the information to deploy using Windows/Console application.

Please help me in this Regard.

Thanks,

Prabu

|||

Hi Prabu

Actually the link i posted here should show you the basics on deploying the report

regardless of what application you are writing.

Look under the function deploy and you will see what i mean. YOu will definitely need to modify some parts so that it points to the webserver. that link will help to get the information you need about the datasource and then deploy it from there. Other than that, it should work for what you are doing.

Just take a bit of tracing. good luck

|||

Hi,

Fine.I tried that code.If anyone is having code sample in web application is really helpfull.

Urgent!

Thanks,

Prabu

|||

Hi,

You can use the RS.EXE for deploying your reports programmatically. You have to create a .RSS file [Reporting Services Script

file] and use the functions available to deploy your reports.

Vasant.

|||

Hi,

I tried and how to call a exe in web application.If anyone is having any Idea about to deploy Report using webservice in Web application ...

I tried a lot and I need it urgent.

Thanks,

Prabu

|||Which of the web application are you using, It might have the functionality to execute a command. The rs.exe file is located in the

c:\program Files\Microsoft SQL Server\90\BINN\

folder. There are various parameters to the rs command. Just for your knowledge see below. At the bottom you will see how rs.exe is used. Njoy!!

Syntax

rs {-?}
[-iinput_file=]
[-sserverURL]
{-uusername}
{-ppassword}
{-ltime_out}
{-bbatchmode}
{-vglobalvars=}
{-eendpoint}
{-ttrace}
Arguments
-?
(Optional) Displays the syntax of rs arguments.
-i input_file
(Required) Specifies the .rss file to execute. This value can be a relative or fully qualified path to the .rss file.
-s serverURL
(Required) Specifies the Web server name and report server virtual directory name to execute the file against. An example of a report server URL is http://examplewebserver/reportserver. The prefix http:// or https:// at the beginning of the server name is optional. If you omit the prefix, the report server script host attempts to use https first, and then uses http if https does not work.
-u [domain\]username
(Optional) Specifies a user account used to connect to the report server. If -u and -p are omitted, the current Windows user account is used.
-p password
(Required if -u is specified) Specifies the password to use with the -u argument. This value is case-sensitive.
-l time_out
(Optional) Specifies the number of seconds that elapse before the connection to the server times out. The default is 60 seconds. If you do not specify a time-out value, the default is used. A value of 0 specifies that the connection never times out.
-b
(Optional) Specifies that the commands in the script file run in a batch. If any commands fail, the batch is rolled back. Some commands cannot be batched, and those run as usual. Only exceptions that are thrown and are not handled within the script result in a rollback. If the script handles an exception and returns normally from Main, the batch is committed. If you omit this parameter, the commands run without creating a batch. For more information, see Batching Methods.
-e
(Optional) Specifies the SOAP endpoint against which the script should run. Valid values include: Exec2005, Mgmt2005, and Mgmt2000. If a value is not specified, the Mgmt2005 endpoint is used. Note that the Mgmt2000 value is deprecated in this release. For more information about the SOAP endpoints and deprecated features, see Report Server Web Service Endpoints and Deprecated Features in SQL Server 2005 Reporting Services.
-v globalvar
(Optional) Specifies global variables that are used in the script. If the script uses global variables, you must specify this argument. The value that you specify must be valid for global variable defined in the .rss file. You must specify one global variable for each –v argument.
The -v argument is specified on the command line and is used to set the value for a global variable that is defined in your script at run time. For example, if your script contains a variable named parentFolder, you can specify a name for that folder on the command line:
rs.exe -i myScriptFile.rss -s http://myServer/reportserver -v parentFolder="Financial Reports"
Global variables are created with the names given and set to the values supplied. For example, -v a="1" -v b="2" results in a variable named a with a value of "1" and a variable b with a value of "2".
Global variables are available to any function in the script. A backslash and quotation mark (\") is interpreted as a double quotation mark. The quotation marks are required only if the string contains a space. Variable names must be valid for Microsoft Visual Basic; they must start with alphabetic character or underscore and contain alphabetic characters, digits, or underscores. Reserved words cannot be used as variable names. For more information about using global variables, see Using Global Collections in Expressions (Reporting Services).
-t
(Optional) Outputs error messages to the trace log. This argument does not take a value. For more information, see Reporting Services Trace Logs.
Permissions
To run the tool, you must have permission to connect to the report server instance you are running the script against. You can run scripts to make changes to the local computer or a remote computer. To make changes to a report server installed on a remote computer, specify the remote computer in the -s argument.
Examples
The following example illustrates how to specify the script file that contains Visual Basic .NET script and Web service methods that you want to execute.

Copy Code

rs –i c:\scriptfiles\script_copycontent.rss -s http://localhost/reportserver

Deploying generated reports at runtime

Due to the requirements of my project I think I need to generate the RDL for
my reports programatically.
However, I think I also need to view them in the ReportViewer web control in
Remote processing mode. My question is, once my app has generated the RDL,
what's the best way of "getting it to SSRS" to that it can be processed.
In the following sequence, it is steps 3 & 4 that I am unsure about:
1. User requests report
2. App generates RDL based on user's config
3. App does something to give it to give the RDL to SSRS?
4. App sets ReportViewer.ServerReport.ReportPath to the path to the report
(what is the path?)
5. SSRS renders report and ReportViewer displays it to user.
I'd be grateful for any help
StuHello Stu,
You could use the Reporting Services Web Service to upload the report to
the report server.
Here is the sample code:
using System;
using System.IO;
using System.Web.Services.Protocols;
class Sample
{
public static void Main()
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
Byte[] definition = null;
Warning[] warnings = null;
string name = "MyReport";
try
{
FileStream stream = File.OpenRead("MyReport.rdl");
definition = new Byte[stream.Length];
stream.Read(definition, 0, (int) stream.Length);
stream.Close();
}
catch(IOException e)
{
Console.WriteLine(e.Message);
}
try
{
warnings = rs.CreateReport(name, "/Samples", false, definition,
null);
if (warnings != null)
{
foreach (Warning warning in warnings)
{
Console.WriteLine(warning.Message);
}
}
else
Console.WriteLine("Report: {0} created successfully with no
warnings", name);
}
catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
}
}
You could refer the following article for more information.
ReportingService2005.CreateReport Method
http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswe
bservice.rsmanagementservice2005.reportingservice2005.createreport(SQL.90).a
spx
http://msdn2.microsoft.com/en-us/library/bb326462(SQL.90).aspx
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Wei,
I have this set-up and working. Are there any performance issues when
multiple users are uploading reports to the reportserver?
-marv
"Wei Lu [MSFT]" wrote:
> Hi ,
> How is everything going? Please feel free to let me know if you need any
> assistance.
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||hi lu
i am getting invalidoperation exception. any ideas?
XmlSerializer serializer = new XmlSerializer(typeof(String));
using (MemoryStream memorystream = new MemoryStream())
{
serializer.Serialize(memorystream, GenerateRDL());
ReportService = new ReportingService2005();
//ReportService.Credentials =System.Net.CredentialCache.DefaultCredentials;
ReportService.Credentials =System.Net.CredentialCache.DefaultNetworkCredentials;
ReportService.Url = reportserverurl;
memorystream.Position = 0;
Byte[] bytes = memorystream.GetBuffer();
try
{
BAR.RS2005.Warning[] warnings =ReportService.CreateReport("AdHocReport", "/ServerReports", true, bytes,
null);
//BAR.RS2005.Warning[] warnings =ReportService.SetReportDefinition(reportpath, bytes);
}
catch (InvalidOperationException ee)
{
StringBuilder error = new StringBuilder();
error.Append(ee.Message);
error.Append(ee.Source);
error.Append(ee.InnerException);
error.Append(ee.Data);
Trace.WriteLine(error.ToString());
}
}
"Wei Lu [MSFT]" wrote:
> Hello Stu,
> You could use the Reporting Services Web Service to upload the report to
> the report server.
> Here is the sample code:
> using System;
> using System.IO;
> using System.Web.Services.Protocols;
> class Sample
> {
> public static void Main()
> {
> ReportingService2005 rs = new ReportingService2005();
> rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
> Byte[] definition = null;
> Warning[] warnings = null;
> string name = "MyReport";
> try
> {
> FileStream stream = File.OpenRead("MyReport.rdl");
> definition = new Byte[stream.Length];
> stream.Read(definition, 0, (int) stream.Length);
> stream.Close();
> }
> catch(IOException e)
> {
> Console.WriteLine(e.Message);
> }
> try
> {
> warnings = rs.CreateReport(name, "/Samples", false, definition,
> null);
> if (warnings != null)
> {
> foreach (Warning warning in warnings)
> {
> Console.WriteLine(warning.Message);
> }
> }
> else
> Console.WriteLine("Report: {0} created successfully with no
> warnings", name);
> }
> catch (SoapException e)
> {
> Console.WriteLine(e.Detail.InnerXml.ToString());
> }
> }
> }
> You could refer the following article for more information.
> ReportingService2005.CreateReport Method
> http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswe
> bservice.rsmanagementservice2005.reportingservice2005.createreport(SQL.90).a
> spx
> http://msdn2.microsoft.com/en-us/library/bb326462(SQL.90).aspx
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>

Wednesday, March 7, 2012

Deploying a report model programatically

Hi,
I would like to know how can I deploy a report model programatically in SQL
server 2005? Or if there is any other way to distribute report models.
Thanks in advance,
NiravI'm curious to find out as well...
Would it be possible to edit the RDLC files programmatically then
deploy them? RDLC files are basically XML files anyway. It would be
nice to customize a given report format based on the user that
requested it...|||You can use the CreateModel and SetModelDefinition methods of the
ReportingService2005 object to create or update a model on a ReportServer.
To get the definition from a server you would use the GetModelDefinition
method. Scripting and Transfering models are part of the features of v2 of
Reporting Services Scripter which should be available in the next few weeks
from my site
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Nirav" <Nirav@.discussions.microsoft.com> wrote in message
news:D5342964-33E3-42FC-8B1A-6DD23B8016B9@.microsoft.com...
> Hi,
> I would like to know how can I deploy a report model programatically in
> SQL
> server 2005? Or if there is any other way to distribute report models.
> Thanks in advance,
> Nirav|||So after I do my editing to the RDLC file a call to SetModelDefinition
would be just like replacing the currently deployed RDLC file on the
Reporting Services Report Server? and any further report render
requests for the report defined by the updated RDLC will be rendered
with the changes I just made?|||Ok, I could deploy both the model and the required datasource through the
ReportingService2005 web service. Now I need to link them (setting the
published datasource for the model), otherwise my report will not execute. I
tried to use SetItemDataSources web method, but that throws an exception for
the model. Any ideas?
Thanks in advance.
"Nirav" wrote:
> Hi,
> I would like to know how can I deploy a report model programatically in SQL
> server 2005? Or if there is any other way to distribute report models.
> Thanks in advance,
> Nirav

Sunday, February 19, 2012

Deploy Excel file that already exists on server - file isn't replaced

Dear all,

I am deploying programatically an Excel 2007 file to a SQL Server 2005 Reporting Server. The problem is that if a file with the same name already exists, that file isn't replaced. I would like the opposite to happen. I'm using the following code:

--Executable

set svr=http://w3sdwsqld1/reportserver
set src_fld="\\w3sdwsqld1\\deploy\\SAD\\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\"
set dest_fld="Associados"
set script="\\w3sdwsqld1\\deploy\\SAD\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\PublishReports.rss"
REM Sample: deploy.bat http://w3sdwsqld1/reportserver "\\w3sdwsqld1\\deploy\\SAD\\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\" "Associados" "\\w3sdwsqld1\\deploy\\SAD\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\PublishReports.rss"
for /R %src_fld% %%f in (*.xlsx) do rs -i %script% -s %svr% -v ParentFolder=%dest_fld% -v reportP="%%~nf" -v path=%src_fld%
PAUSE

--rss Code


'
' Script Variables
'
' Variables that are passed on the command line with the -v switch:
'
' (a) parentFolder - corresponds to the folder that the script creates and uses
' to contain your published reports

' (b) reportP - corresponds to the report to publish


Dim ROOT As String = "/SAD/Ecrans/Ecrans/AM"

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = ROOT + "/"+ parentFolder
Dim filePath As String = path
Dim report As String = reportP


Public Sub Main()

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

'Create the parent folder
Try
rs.CreateFolder(parentFolder, ROOT,Nothing)
Console.WriteLine("Parent folder {0} created successfully", parentFolder)
Catch e As Exception

Console.WriteLine(e.Message)

End Try

'Create shared data source
'CreateSampleDataSource("Solucao_Integrada", "OLEDB-MD", "Data Source=dwareas1;Initial Catalog=SAD_Solucao_Integrada")

'Publish the sample reports
PublishReport(report)


End Sub

Public Sub CreateSampleDataSource(name As String, extension As String, connectionString As String)
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
definition.ConnectString = connectionString
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = extension
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
'Use the default prompt string.
definition.Prompt = Nothing
definition.WindowsCredentials = False

Try
rs.CreateDataSource(name, parentPath, False, definition, Nothing)
Console.WriteLine("Data source {0} created successfully", name)

Catch e As Exception
Console.WriteLine(e.Message)
End Try

End Sub

Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".xlsx")
Console.WriteLine(reportName)

definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()

Catch e As IOException
Console.WriteLine(e.Message)
End Try

Try
rs.CreateResource(reportName + ".xlsx", parentPath, True, definition, "application/x-excel", Nothing)

Catch e As Exception
Console.WriteLine(e.Message)
Console.WriteLine("Failed to publish report")
End Try
End Sub
--

Any thoughts? Many thanks,

Pedro Martins

Portugal

Pedro,

Try

It looks like the paths may not be correct, use the "filePath" that you use to open the file in the below statement.

rs.CreateResource(reportName + ".xlsx", filePath, True, definition, "application/x-excel", Nothing)

I normally created my Rss script insert console write message to return values so that I can make sure I getting the corrent values.

Let me know if this helps.

Ham

|||

Ham,

The path is correct, if I deploy the file and there is no other file in the destination the file is uploaded successfully. However, If a file with the same name already exists, the new file doesn't replace the old one.

Pedro

|||

Pedro

Is the file you are trying to replace - "Open" by another application? You could use the System.IO to check on the status of this file before you try and replace.

Ham