Generate PDF reports from SQL Server reports.rdl C# - c#

Let me start by asking for your patience as I am ignorant of SSRS and not so sharp on the WCF technology that I intend on using to perform the task I want.
I have a SQL Server Express instance with data I want to get daily reports out of. I can not schedule tasks on SQL Server (and the reports server I think I can in the full blown but not in Express) , but I can schedule via windows task.
So I am writing an application that will use predefined rdl's to generate my reports and send the reports back via email. I am not sure how rdl's data connection is set from my C# application - I created rdl's in its own project, but it looks like I need to do rdlc conversions for my application.
What I would like to do is query the database via the reports and then send those reports out in an email to a set group of recipients (pulled from their email field in the users=reports result table.
[FYI] I also have a web application that might need to generate these same reports.
Now on to my question:
I am not sure if I even need WCF to do anything here, as it looks like from this post Creating a PDF from RDLC report that I can simply run that code and point to my data source and the bytes will be returned to me (so far fine for a desktop quick and dirty getter - I think)
Now is the same functionality possible in a web application - it would be nice to reuse the same code.
Can some one provide me with some proper guidance for this kind of functionality with the technologies involved - so I can code something proper and maintain KISS principle.

Related

Replicating a Crystal Report created by an ERP and sending it from server to client

The company I work for has an ERP that generates Crystal Reports using data from the ERP Database (MS SQL Server).
Example: Mitch from sales (who we've purchased a very expensive ERP license for) wants to know how many hammers we have in stock. He goes into the ERP clicks the "Report" button, and a new window pops up with a crystal report showing him how many hammers are in stock.
My boss would like Jeremy (who does not have a very expensive ERP license) to be able to see these reports as well. Jeremy needs to be able to right click an item (e.g. hammer) in our document management software and generate a report from there.
I have spent more hours trying to figure out how to do this than I'd like to admit. I am successfully sending back a string of all the right info based on the selected item, but can't figure out how to get it sent back as a Crystal Report (which is absolutely necessary for some reason which has yet to be explained to me). The report can be in any file format (i.e. ttx, rpt, html) as long as its laid out just like the report generated by the ERP.
Additional info:
I can make Crystal Reports just fine in the Crystal Reports for Visual Studio SDK but can't successfully use an existing report as a template
I have access to everything on the server
My server side code is ASP.NET using C#
The reports are generated from stand-alone rpt files, rpt + vbscript files, and rpt + sql + ttx files
The report I'm currently trying to replicate uses a ttx and sql file to populate the data
The string I'm sending back is obtained using an altered version of the sql query that I've made into a stored procedure
I'm probably missing some crucial info that is needed to answer this question so feel free to ridicule me and ask for whatever you want. That's what my boss does.
thanks #BoldAsLove. In answer to your questions... 1) The goal is to generate the reports server side and send them back to the client (I'm thinking as a pdf or html). I'm trying to get it working on the client first and then transfer it over to the server because our server is running on Windows 7 and I can't figure out how to remote debug a program on that OS. 2) I've tried spinning up a report on my client application several different ways with different results (feel free to ask additional clarifying questions on this. I've been in and out of this project for the last couple of months and my brain is fragmented to the point where I might be saying something stupid or wrong). I can successfully get a report with the right data if I build it from scratch in Visual Studio and set the Data Source in Crystal Database Expert as a DataSet that I make within the project (with column names that match the ones in the ERP database). If I try to generate the report based off of an existing report I either get an error saying
Error in File CrystalReport1
Report GUID
Error in formula Object_Visibility:
formula = (Trim ({Hammer_Report_ttx.HammerID}) = '')
This Field is not known
Details: errorKind
or a login window pops up and I fail to login (and I've used every login credential combo on our server that I can think of).

Downloading SSRS report from report server using C# code

I have been working on a requirement to deploy and download SSRS reports programmatically from C# code.
I used the service exposed by SSRS (ReportingServices2010). I am able to deploy my reports from application server to report server successfully. I referred to "https://www.codeproject.com/Articles/43133/Deploying-Reports-in-Reporting-Services-Programmat" for this.
Meaning, the deployment portion is done and I am able to deploy the report using C# code. But now, I want a functionality to download reports from report server and place it to Application server somewhere. I want to achieve this in similar way, like I did for deploying (using C# code).
But I am unable to find any method exposed by service which can return content of the report deployed on report server.
As a work around I found a way to directly query on Report Server Database or Power shell script as well. But I would prefer a solution using C# code only.
Please suggest if we can download SSRS report from report server programmatically using C# code.
Thanks,
Ketan
You can look at the code for command Out-RsCatalogItem in ReportingServicesTools GitHub project to determine how to download using the SOAP Proxy. In order to create a Web Service Proxy in .NET, look at this page. If you are still not sure how to proceed, then leave a comment and I will try to hack up a quick sample.

Best practices for automated emails from web application

I have been working on a Lightswitch 2012 (HTML 5) project two of it key requirements are report generation and triggered based emails to users.
Since lightswitch does not support reports and best way is to use ASP.NET, i used to generate reports, But now i am kind of stuck about how can i generate triggered based emails meaning like each night at 00:00 there should be some query run against database to generate emails to users, some options that i have are,
1) SQL jobs
2) WCF RIA Services
3) Console Based separate application
But client wont allow me any where near their servers so need a solution with minimal configuration on server but it must be reliable as well.
So please some advice in this regard is needed. Thanks!
Server is running Windows Server 2012 and they have there own mail server that i have to utilize.

Accessing SQL Reports server when url is only accessible by first using RDP

I have a client that needs me to set up a website that pulls sql reports from a separate server. Currently the only way to access the url to the reports server is to first rdp into that server. I tried creating a web services proxy class, but the url was unable to resolve due to the added protection.
Is there any way for me to pull the reports in my asp.net application from the other server without removing the rdp? This is my first time trying this, so im not sure if i am going about this the correct way or if it is even possible to access that server from the client web application with the rdp in place.
EDIT
All my application needs to do is display pre-made reports to specific clients/groups based on their login credentials. These clients/groups will not be creating or altering reports(at least not at this point in time).
I think you'll find its most likely not possible or probably very hard to do.
Perhaps you could obtain a copy of the database through replication or maybe a nightly bulk update and run the report against that, perhaps you could script a machine to remote desktop in and share the drives on it and get it to backup the db or similar.
In any case if you can't get a copy of the database I don't think you could feasibly generate any kind of report that allows user input to generate it.
EDIT:
It looks like this answer will get you started in connecting and triggering a file copy

SQL Server Layer for both Delphi and C#

I really don't like the concept of opening my SQL server(s) to the internet - even if I can lock down the firewall. However I've always been working directly with databases. I'm building a system now which involves 1 SQL Server database, a web application in ASP.NET/C#, and a few windows applications in Delphi XE2. But from the beginning, I'd like to put some sort of 'filter' around the database so I don't have to open it up.
I know there are many things out there for this, but don't know anything about them or what to get for my scenario. I'd like to keep it native to SQL Server; I don't plan on using any other type of database engine.
It needs to be connected from client to server by other means than the standard SQL connection, like a filter. It creates its own encrypted packets and transfers data its own way. I will have a wrapper class for both Delphi and C# which will pretty much be identical - and be able to stream its data into the DLL to interact with the DB.
Now there are three different ways I can go about this...
Complete SQL Server wrapper, most likely no source code, might even have its own language (I don't want to pick up another database language), and independent from my project as its own separate system.
Open-source wrapper, preferably in Delphi (XE2), or if not then C#, specific protocols for my system, entirely dedicated to my project, and in the final form of a DLL which can be used on both the Website (in C#) and the applications (in Delphi).
Web Service - however I only have 1 hosting spot (Paying for 1 site, 2nd site will be a double charge on me). I can't host any additional web services or windows services; it has to be integrated with the website. Otherwise, I would have done a web service for this.
I would much prefer the second option, and do not want to go anywhere close to the first one, and can't do the third one at all.
So any good libraries for database layers? And might there be some already installed in Delphi XE2? I'm thinking maybe an encrypted XML packet?
As an example, let's say I have a table for 'Customers'. In both my website and applications, I should never have any SQL script like select * from Customers or no SQL script in general. Instead, I will have a wrapper around the database. So I can call a function such as DBGetCustomers(Conditions: TGetCustomersConditions): TDBCustomers; where TGetCustomersConditions is some way of filtering the query, and TDBCustomers represents the results from the query.
There could also be a function DBAddCustomer(Item: TCustomerToAdd): TInsertSuccess; where TCustomerToAdd represents what to insert, and TInsertSuccess represents any result, such as error message(s) or rows affected. I do not intend for it to be working exactly like this, but just to explain the concept of any wrapper in general. When the app sends to request to the server, it still has not converted anything to a SQL Query. By the time the request gets to the server (which is able to connect to the database), then the server alone decodes everything to the SQL query.
What's the problem even if you have just one "hosting spot"? A web service is just a "site". And a web server can easily host multiple site even with a single IP address. Anyway, what you're looking for is an "application server" in a multi-tier design.
While Java invested heavily in that direction, MS did not. Delphi has Datasnap, which is a so-so framework, don't know if the new "restful" interface is easily callable from C#, it looks to have security flaws though. The .NET way of doing it is using WCF, as long as it uses a standard protocol you can call if from Delphi has well.
You could also look at RemObjects DataAbstract. It's not open source, but it is a mature library.
One of the 'traditional' ways to do this is via webservices (although this technique is now considered by some to be a bit dated).
One disadvantage is that it is not a generic wrapper you can throw around the database, but it has the advantage that you can limit access to the database easily to specific stored procedures for example, which will maximise security, and is a standard technique if you wish to provide limited authorised access to external applications.
If you already use a ASP.NET C# web application, you could also add a WCF (Windows Communication Foundation) based web service to your web site. This can provide database access to external applications, which need to connect the web service somehow. It should even be possible to use the same HTTP standard port for both the normal web site pages and the service, by mapping the web service to a specific context path like www.example.com/services/servicename
Kbmw allows you to make a ntier db architecture.
However since you have a web application involved, a better option would be WCF (as already suggested)

Categories

Resources