I'd like to be able to fire off an SSRS Report from an ASP.Net application without pulling it up in the application and having to print it from there to a specified printer. This seems like it would be a highly desired feature, but I'm having trouble finding any good solutions online. Can anyone help me with this?
rFirst you will need to set up the report to render from an execution snapshot. You should find this under the reports property tab, execute, select the "Render this report from a report execution snapshot" radio button.
Next you will need to set up a subscription for whom you want it delivered to. Under the subscriptions tab, add new subscription, enter the e-mail information, etc. Under "Subscription Processing Options" select "when the report content is refreshed".
Now you need to be able to trigger a new snapshot programmatically. Fortunately, the reports service exposes a web service for this purpose. Add a service reference to:
http:// your_report_server:your_port/ReportServer/ReportService.asmx
Once you add the reference then you simply need to call the UpdateReportExecutionSnapshot method to cause you report to execute and mail out to your subscribers.
A simple c# command line app to this might look like:
static void Main(string[] args)
{
// The first argument should be the full report path
// and name. It is passed directly to the Ssrs web service
if (args.Length == 0)
{
throw new ArgumentException("Full report name must be the first parameter");
}
// create the endpoint
ReportingServiceSoapClient ssrs = new ReportingServiceSoapClient();
// Update the snapshot
ssrs.UpdateReportExecutionSnapshot(null,args[0]);
}
For the report name, you will need to specify the full report name including any sub folders you have. So if you have your reports say organized by division you would have to specify all the parent folders for example:
/DivisionName/DailyReports/SalesReport
From a Web Application standpoint, in modern prowsers, I don't believe you can specify a printer, and you certainly cannot "auto-start" printing. Reporting services used to have the ability to print unattended with an MS browser plugin, but that was removed a number of years ago as it's now considered a security risk.
The best you can do is "one-click" print, that is programmatically render the report using the Report Execution service from the ReportService.asmx web service and initiate a programmatic solution to print the rendered report.
Unfortunately, printing an SSRS report automatically is quite involved. You can read about How to Print Reports Programmatically here.
Related
I have a scenario where I would like to automate programmatically the following process:
Currently, I have to manually
Navigate to a webpage
Enter some text (an email) in a certain field on the webpage
Press the 'Search' button, which generates a new page containing a Table with the results on it.
Manually scroll through the generated results table and extract 4 pieces of information.
Is there a way for me to do this from a Desktop WPF App using C# ?
I am aware there is a WebClient type that can download a string, presumably of the content of the webpage, but I don't see how that would help me.
My knowledge of web based stuff is pretty non-existent so I am quite lost how to go about this, or even if this is possible.
I think a web driver is what you're looking for, I would suggest using Selenium, you can navigate to sites and send input or clicks to specific elements in them.
Well, I'll write the algorithm for you but you also need to some homework.
UseWebClient get the htm page with the form you want to auto fill and submit
Us regex and extract the action attribute of the form you want to auto submit. That gets you the URL you want to submit your next request to.
Since you know the fields in that form, create a class corresponding to those fields, let's call the class AutoClass
Create a new instance of your auto class and assign values you want to auto fill
Using WebClient to send your new request with the url you extracted from the form previously, attach your object which you want to send to the server either through serialization or any method.
Send the request and wait for feedback, then further action
Either use a web driver like Puppeteer (Selenium is kinda dead) or use HTTPS protocol to make web requests (if you don't get stopped by bot checks). I feel like your looking for the latter method because there is no reason to use a web driver in this case when a lighter method like HTTP requests can be used.
You can use RestSharp or the built in libraries if you want. Here is a popular thread of the ways to send requests with the libraries built in to C#.
To figure out what you need to send you should use a tool like Fiddler or Chrome Dev Tools (specifically the Network tab) to see what you need to send to acheive your goal as you would in a browser.
I have a parameter in my report that my user cannot know about for security reasons. But this report also has others parameters.
Is there a way to "feed" these reports without the user intervention? I plan to feed default values to the regular parameters and the appropriate value to the "secret one"...
Details:
-Using Report Viewer User control to display the report in a WinForms app
-Using SSRS 2008R2
-Report is not local
In SSRS you can set a parameter to be hidden in the general tab of Report Parameter Properties.
You can then set the parameter using a default value.
Problem Background
In my ASP.net MVC4 web application, we allow user to download data in an Excel workbook, wherein one of the cell contains a hyperlink to a report page. We prepare the link such that when user click the link in Excel, ReportController gets called with parameters, processes the request and return a report summary view i.e. .cshtml page. All works well...
I generate excel using SpreadSheetGear, code snippet that generate link:
rrid = (int.TryParse((string) values[row][column], out outInt) ? outInt : 0);
worksheet.Hyperlinks.Add(worksheet.Cells[row + 1, column],
PrepareProspectProfileLink((int) rrid, downloadCode),
string.Empty,
"CTRL + click to follow link",
rrid.ToString(CultureInfo.InvariantCulture));
Problem
I just noticed that when I click the link in excel, the same request is sent to the web server twice.
Analysis
I checked using Fiddler and placed a breakpoint in application code and its confirmed that the request is indeed sent twice.
In fiddler, Under Process column I found that first request is coming from "excel:24408" and second request is coming from "chrome:4028".
Also if I copy paste link in Outlook, it invokes request just once.
I understand this indicate, the first request is invoked by excel, when excel is served with html, it knows nothing about how to render it hence handover the request to default web browser which is Chrome on my system. Now Chrome fires the same request and on receiving html, it opens the html page.
Question
How can I stop this behavior? It puts unnecessary load on web server. And secondly when I audit user action, I get two entry :(
I'm not sure about excel, but you can handle this weird behavior on web server instead. You can create html page (without auditing) that will use javascript to redirect user to page with real report (and auditing stuff).
If you're concerned just about auditing, you can track requests for report in cache (or db) and consider making auditing entry only if same request for report wasn't fired let's say 5 seconds ago.
I have been publishing crystal Report and this is one of the most frequent error I get, if I close the tab which shows the report, my code keeps on running till the time report query (LINQ) runs in DAL.
Then my whole application freezes, is there a way by which I can stop the query of the closed tab report?
I just need a hint to do the same.
Thanks in advance, I was not able to search the solution on net as I was doubtful so as what should I ask.
You're asking for something unusual, so there is no usual way of doing it..
What I would try is to use jQuery and the unload event of the document to send a small REST request (if it's asp.net, then add an HTTP Handler -http://support.microsoft.com/kb/308001).
Add an identifier to the query string of the request and then at your server you can make sure the request was from the IP that matches the identifier of the client by checking Request.ServerVariables["REMOTE_ADDR"].
Then you're at your server, with an identifier and you made sure it's the client who sent it by unloading the page (closing the tab/browser).
As I'm not farmiliar with crystal resports, you should search for how it's possible to stop it: https://www.google.co.il/search?num=30&biw=1280&bih=699&q=stop+or+abort+a+crystal+report+asp.net&oq=stop+or+abort+a+crystal+report+asp.net
I have a web page.There is a link to generate pdf reports.When the user clicks on the link the pdf generation process should start.Since the file size of the generated pdf is huge(>15Mb) the user cannot wait & thus has to proceed ahead with his other activities.That means the following simultaneous things would be happening now
The PDF Generation process continues unabated
The user continues with browsing without any jolt
After the pdf generation is completed the user should receive an email containing the download link.
Basically the implementation is
User clicks on generate report button
Using AJAX I make a call to the c# function say generateReport()
The problem
When I do this the user is not allowed to perform anything unless & untill the entire process completes.Ofcourse he can click on different links but with no response because of the AJAX call still getting implemented
How do I achieve this.I am a dot net(framework 2.0) developer creating aspx web pages using C#.I use javascript & AJAX(AjaxPro) to get rid of the postback in typical ASP.NET web applications.
In cases like this, you might want to consider splitting your PDF generation code out into a separate service, which your AJAX code could interact with to kick off the PDF creation. Once the service has created the PDF file, the service can email the user with the relevant info.
The AJAX code would use remoting to communicate with the service.
The concept you have in creating the reports and having them emailed to the user is a good one.
The implementation of this should be quite simple on the client side, ie a basic call to indicate that a report needs to be created. ie save this to a table (report queue)
The actual creation of the report should not be triggered by any of the calls from the front-end directly, Create a service (Windows Service) that runs through the "report queue" generating the PDF files and sending the emails.
As an added option, assuming the PDF's are not destroyed (ie not an email only solution) an ajax popup could be created on the client where the user can then go to a reports page and download the already generated file.
You could try on a timer make an AJAX call to a Function isReportDone(), that in turn checks a repository for the PDF. For generating the PDF, I THINK you'll need to pass that task out of your normal Request-Response Thread. Either by calling a seperate Thread (Multi-threading is fun) to process it, or by passing the data out to a seperate service on the server.
These are just two ideas really I had a similar issue with generating a file from a DB that had to be forcibly downloaded. I ended up calling a seperate page, in a seperate window, that wrote the data to the response stream. It actually worked great until the customer's network blocked any and all popups.
User asks for report to be generated (clicks a button)
Page kicks off an async service call to GeneratePdf(args).
User sees a spinner of some sort while Pdf is being generated, that way they know something is happening.
Pdf is generated (iTextSharp might come in handy here).
Pdf is stored somewhere. Database blob field would be ideal, that way the webservice can just pass back the id of the new file. Failing that, pass a filename back to the ajax code.
Webservice async (see this one) complete event happens, ajax code throws up either a popup or redirects to a new page. Maybe you want to replace the spinner with a "Ready!" link.
Link to pdf report file is emailed to user.