I was tasked with making a Webpage (aspx), which automaticly reads rdlcs, and generates a webpage, with the parameters at the top as webelements and the report as the main part of the page.
So far, I have tried reading the file as an XML-Doc, and just parsing the info out of there. But this may be done simpler. (I have no expirience with reports or rdl(c) files).
I have seen that there is a DataSets/DataSet/Query/CommandText-Tag, which can hold an SQL-Statement. Now this let's my boss and myself assume, that it is possible to make it already deliver this info by itself, which me coding this. On the other hand, I see nowhere any example for that.
My current code looks like this:
private string rdlcFilepath = "some/path/to/file.rdlc";
protected void Page_Load(object sender, EventArgs e) {
string sql = GetSqlStatementFromRdlcFile(rdlcFilepath);
DataTable dtTest = DatabseFacade.Execute_SQL(sql);
MainReportViewer.LocalReport.ReportPath = Server.MapPath(rdlcFilepath);
MainReportViewer.ProcessingMode = ProcessingMode.Local;
MainReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtTest));
MainReportViewer.LocalReport.Refresh();
}
So, I have 2 theories:
The CommandText-Tag tag is a ment for a "report server" and should be used only in ProcessingMode.Remote, and is not relevant when in Local mode.
I'm approaching this whole thing wrong.
If 2 is true, then probably the problem is manually adding the dtTest, and it should have some other instruction to make the report-element "pull" the data by itself.
My questions:
Is one of my assumptions correct, or what is going on?
Any other hints/links that may help?
I may note, that every tutorial/example I saw on the internet, that used ProcessingMode.Local, used an "external" datatable, and the LocalReport.DataSources.Add way.
Just for clearification, our (my boss' and my) ideal solution, would be some "magic" command, that makes the ReportViewer, use the information in the rdlc file, to connect to the database, and display the result. After all it contains all of the info, from connection-string to SQL-statement.
Please note that the rdl file is the Native SSRS report version, which is faster and easier to develop. The type of Project needed here is "Reporting Services Project", while the rdlc is the client side of the rdl file which is usually developed in normal visual studio web or desktop project, which is of course used as local report and usually takes more time to develop and you have to provide all DataSources, DataSets and Parametrs if there is any.
In my opinion, there is much simpler solution to your problem. You can actually setup remote or local SSRS reporting services server and this will enable you to work on the reports(rdl files) natively, which is basically cleaner and faster. In terms of performance too, I think that native mode scales out and outperform the local or client report option (.rdlc). Using this approach, you don't have to add DataSources or Datasets or Parametrs as all of this you will configure natively and use the configuration manager to configure Shared DataSources and Datasets. You will only have to authinticate the use in your page and provide the URI of your SSRS server, User name, password and report path.
To know more about configuring SSRS Server use this link please:
SQL Server Reporting Service Configuration Manager
there are also a lot of links online.
You can authinticate the user like the below code sample shows:
// Set the processing mode for the ReportViewer to Remote
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials("username", "password", "domain/Ip");
serverReport.ReportServerUrl =
new Uri("http://xx.xxx.xxx.222/ReportServer_MSSQLSERVER2016");
serverReport.ReportPath = "/Reports/Report3";
ReportViewer1.ServerReport.Refresh();
Here is a good link about Passing Credentials to Sql Report Server 2008
Passing Credentials to Sql Report Server 2008
That's all you need to do. just drag a report viewer and authenticate the user and that's it. hopefully this is helpful for you.
Related
Until now, I have been using ReportViewer.LocalReport to generate PDF outputs of locally embedded SSRS Reports, which use predefined datasources that get overridden in my C# application by run-time generated data...
// Set the DataSources
report.LocalReport.DataSources.Add(new ReportDataSource("MilkSolids", this.MilkSolidsTable));
report.LocalReport.DataSources.Add(new ReportDataSource("Ingredients", this.IngredientsTable));
The drawback of course, is that I have to use older versions of BIDS to design the report in. But now I have a new option of using a web reference from our SQL Server 2008 Report Server. This way, I could use BIDS 2008 to write my report in, and then make the report server do the rendering. This works like a charm for the pre-defined datasource; HOWEVER, I cannot find any information on how to override predefined datasources in the ReportExecutionService class.
Is this even possible?
If not, does anyone have another suggestion?
We are looking into replacing Crystal with SSRS.
I would like to know if it is at all possible to load the .rdl or .rdl.data file in C# and generate the report to a memory stream.
I have seen some examples using the LocalReport, but this seems to be part of either the WinForms or WebForms assemblies.
So what I would like to know is:
Is it possible to load the report from file as part of our service.
Can we then generate the report to a Stream (lets say a memory
stream)
Can I do this without using the WebForms/WinForms assemblies in my
service
Can we achieve this without using the webservice for SSRS
I'm not sure that this is an answer, but lets call it supporting material.
I have this code example from msdn that shows how you can do this by creating a service client and calling a given report as a PDF and saves it to file stream.
http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx
The problem I'm currently having is finding the correct client object to interact with after pointing VS to the SSRS service. The object I'm using to interact with the service is:
ReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient();
However, the interface doesn't match my code example. So this is a little closer, but not an answer.
UPDATE: The correct Proxy class generator
Here's the link to how to generate the proxy correctly. You'll need the windows sdk installed (current is 7.1). You can find that on microsoft.com, like I did. Execute the command line and it'll generate a file for you. Include in project:
http://msdn.microsoft.com/en-us/library/ms155134%28v=SQL.110%29.aspx
UPDATE: Got the thing workin
I just had to generate the correct proxy. Ok, so for SSRS 2010, apparently they split report execution and management out into two services. The only one I needed to generate my report from a C# console app was the execution service. Maybe that's totally obvious to everyone but me :) ?
Ok so open up a Windows SDK command shell and put this stuff in it for the execution service:
wsdl /language:CS /n:"Microsoft.SqlServer.ReportExecution" http://<Server Name>/reportserver/reportexecution2010.asmx?wsdl /o:"ReportExecution.cs"
Go to C:\Program Files\Microsoft SDKs\Windows\v7.1 and pick up your ReportExecution.cs file. Copy and paste it in your project.
Then you just have to say this:
Microsoft.SqlServer.ReportExecution.ReportExecutionService rsExec =
new Microsoft.SqlServer.ReportExecution.ReportExecutionService();
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Url = #"http://<ServerName>/reportserver/ReportExecution2005.asmx";
Follow along the example from this link, which is the same one as above, and you should be generating some pretty awesome reports from your handy C# app.
I am working on integrating my company's product with Jira so users can log bug reports directly from the application. Everything was wqorking smoothly so i decided to import the data from our live Jira system into my development system so that i had some real world data to play with. Since then when i try to get an authtication token it throws the following exception "com.atlassian.crowd.exception.PasswordEncoderNotFoundException: The PasswordEncoder 'atlassian-security' was not found in the Internal Encoders list by the PasswordEncoderFactory". I have checked and the Atlassian Security Password Encoder is enabled in the Crown Password Encoders plugin.
My code is super simple just an ASP.net based text based issues search with the results wired to a grid view code as below:
JiraSoapServiceService service = new JiraSoapServiceService();
string token = service.login("integration", "test");
if (!string.IsNullOrEmpty(txtSearch.Text))
{
RemoteIssue[] issues = service.getIssuesFromTextSearchWithLimit(token, txtSearch.Text, 0, 100);
gvwIssues.DataSource = issues;
gvwIssues.DataBind();
}
I get the error on the call to service.login, it worked fine before I imported the live data. And yes i did add the integration user again after i had imported the data.
Anyone any ideas on this.
No idea what was causing this but rebooting the PC that the dev Jira was installed on fixed it.
EDIT
I have had this a few times now. It tends to happen when you do something like restart the SQL server, restore the jira database via SQL server, restore jira via the inbuilt XML file import method or similar. You don't have to restart the machine just the jira windows service. No idea if this is a problem with other DBs or server types.
I have been working in a business writing advanced software apps, and obviously im provided with access to our SQL server and all the connection strings needed.This is fine for my job now - but what if i wanted to do this for a new (very small) business... If i wanted to purchase a small database server and set up a piece of software that talks to the databases on this server, how would i go about a) Talking and connecting to the server in code (c#) and b)What would i need regarding things like internet/phone connections etc to make this possible.
Edit: the reason it would need a server is because it would need to be accessed from 2 or 3 different computers in different locations?
Actually there are quite a few ways to create a database connection, but I would say one of the easiest ways is to utilize the methods and classes found in System.Data.SQLClient. A basic connection would look something like the following:
using System.Data.SQLClient;
namespace YourNamespace
{
public class DatabaseConnect
{
public DataType getData()
{
DataType dataObj = new DataType();
SqlConnection testConn = new SqlConnection("connection string here");
SqlCommand testCommand = new SqlCommand("select * from dataTable", testConn);
testConn.Open()
using (SqlDataReader reader = testCommand.ExecuteReader())
{
while (reader.Read())
{
//Get data from reader and set into DataType object
}
}
return dataObj;
}
}
}
Keep in mind, this is a very, very simple version of a connection for reading data, but it should give you an idea of what you need to do. Make sure to use a "using" or "try/catch" statement to ensure that the connection is closed and resources are freed after each use (whether it successfully gets data or not).
As for your other question about what equipment you may require. In the beginning I would suggest just creating the database on your local machine and running tests from there. Once you are confident with trading data back and forth, feel free to move the database to another box or an online server. Any internet connection type should suffice, though I can't vouch for dial-up, haven't used it in years.
One final note, if you do happen to decide to move to an online server system, make sure that the service you use allows for outside connections. Certain services use shared server systems, and force users to use their internal database interfaces to manage and write to the database.
--- EDIT ---
As for the server system itself, build up a separate box on your local network that you can see, and load up the database software of your choice. Since you are using C#, it would probably be easiest to go with Microsoft SQL Server 2005 / 2008. The installation is rather straightforward, and it will prompt you to automatically create your first database while installing.
After installation it will be up to you to add in the tables, stored procedures, custom functions, etc... Once your base structure is created, go ahead and use the above code to make some simple connections. Since you are familiar with the above practices then I'm sure you know that all you really need to do is target the server machine and database in the connection string to be on your way.
In case your application is small (by small I mean the usage of resources like CPU and memory) then your SQL Server can reside on the same box.
Else you need to have a separate server box for your database and connect to that from your application. In this case, preferably your database box and application box would be on the local area network.
Check this link for having a connection to SQL Server from C# code - http://www.codeproject.com/KB/database/sql_in_csharp.aspx
cheers
You should probably expose your database with an xml web services layer, so that your architecture will be scalable. The general idea is host your sql server and webservices, using Native SQL Server XML Web Services you can make this available to your remote clients. When in your clients you simply add a service reference in Visual Studio and your data will now be available in your client app.
Hope this helps some.
Cheers
You may find the connectionstrings website useful - worth bookmarking.
I have a developer tool that I want to run from an internal site. It scans source code of a project and stores the information in a DB. I want user to be able to go to the site, chose their project, and hit run.
I don't want the code to be uploaded to the site because the projects can be large. I want to be able to run my assembly locally on their machine. Is there an easy way to do this?
EDIT: I should note, for the time being, this needs to be accomplished in VS2005.
EDIT 2: I am looking for similar functionality to TrendMicro's Housecall. I want the scan to run locally, but the result to be displayed in the web page
You could use a ClickOnce project (winform/wpf) - essentially a regular client app, deployed via a web-server. At the client, it can do whatever it needs. VS2005/VS2008 have this (for winform/wpf) as "Publish" - and results in a ".application" file that is recognised by the browser (or at least, some browsers ;-p).
You might be able to do the same with Silverlight, but that has a stricter sandbox, etc. It would also need to ask the web-server to do all the db work on its behalf.
I want to be able to run my assembly
locally on their machine
Sounds like you want them to download the tool and run it from their local machine, does that work for you?
Any code can scan files given the location and permissions. For a website to open an exe on a different machine and permit that to run and get access to the files contained on the web server would require a horrifically low level of security that would mean the entire system is practically completely open to attack. If your system is completely behind a firewall and hence protected from outside intererance then you want to look more at the permissions and less at the code.
To run an exe on a machine try following notepad example, though you may have to use a specified directory as well
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(ExitHandlerToKillProcess);
p.StartInfo = psi;
p.Start();
and when done dont forget to kill the Process. Alternately use javascript. Either way watch the security permissions and remember the risks of doing this.
I would probably write some sort of command line tool or service that does the processing and extraction of project data. Then I would use a page to update/register projects that the web server and the command line tool both have common access to. then at specified times either manually or via cron or similar mechanisms extract the data to your database. once you have this, you just use the website to display last extraction times and the extracted data.
if the projects/end users are on a different subnet etc, then you will need the end users to run the tool and then have it post the data into the database.