IE automation and SQL reporting services c# - c#

I'm working on a project for work that has me running a SQL reporting services report all day long. I would like to automate this process and have gotten pretty far in the process. I can navigate to the page, search for what I want, select the output of the file and click export. The problem I run into is the File Download dialog box that pops regardless of file type or mime settings. I am able to get around it now by using an AutoIt function but its flaky at best. I really want to just download the file to a specific location. My question.. Is there a way to intercept whatever clicking the export button does and get some sort of link to the file? Or is there a way to run the function that link does in asp programmaticly and grabbing the file that way? (Sorry if terminology is off not real familiar with ASP).
Edit... I know there are better ways of doing this with reporting services such as subscriptions etc (thanks for the responses btw :)... But this is what I'm stuck with until I can get the admin to fix a few things. In the company I'm at that involves getting about 20 different departments involved and it will most likely not get fixed. But ultimately my question is whether it is possible to do what im asking in C#. Can I intercept where the code is sending me when I click export and grab the file? Is that even possible?

Check if you can use URL Access directly against the Reporting Services server: http://msdn.microsoft.com/en-us/library/ms153586.aspx.
If you can modify the web application, try changing the value of ReportViewer.ExportContentDisposition (http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.reportviewer.exportcontentdisposition.aspx) to "AlwaysInline". Alternatively, you can use the Render method (http://msdn.microsoft.com/en-us/library/ms252199.aspx) of ReportViewer.ServerReport or ReportViewer.LocalReport to render into a Response OutputStream.
Otherwise, you need to peek into the JavaScript in the ReportViewer's IFRAME using IE Developer Tools (F12 in IE8). It needs to perform an additional callback to the server to have it render the report in the selected format. Adapt the actions this script performs.

Why not just use the report scheduling feature to automate it? You can enter subscriptions for the report and it can be delivered on a schedule. There are two delivery methods with SSRS out of the box - email and file share. You can even write your own custom delivery extension.

How much access do you have to SSRS? If you can get pretty much carte blanche, you could setup SSRS to export the report at intervals to a specific location. If SSRS can't hit that location, you could set up SSRS to email the report--from there it is an easy jump to making email dump to location. Either way, there are better angles than "auto click OK" screen-scraping UI automation.
I'd look into the web services. If they can't get scheduling right, they probably didn't get around to turning those off either. Setup a command line app to suck the reports off the services and life will be grand.

It sounds as if you need to treat the reporting service as if it is completely external. Perhaps WinBatch would help you script interaction with the windows? http://www.windowware.com/

Related

get HTML page sources from multiple sites

There several websites that use AJAX to update the contents periodically and I would like to monitor them. That's why it is necessary to keep multiple webpage windows always open and to grab page sources periodically.
I am searching for an approach for getting HTML sources from these webpages! Could you recommend something? I need it for statistical analysis.
Here are my thoughts so far:
approach. Opening separate Chrome windows manually. Using Handles to find the window. The problem is that it is nearly impossible to grab the HTML of the webpage.. (except the rich text)
Approach. writing an extension for Chrome/Firefox and a C# program. Program will send requests to extension and the extension will return HTML contents of the webpage. That's the theory. Google didn't put my hopes high so I am not sure if that is possible...
Approach. The most realistic one. Using the embed browser such as CefSharp, Awesomium, etc.. But as I mentioned - they have to support multiple opened windows! Any problems here?
So, these are my thought after hours of study..
Personally I would love to implement approach 2 because it is the most awesome.. but others will do too. What would be the easiest and most bulletproof?
Additionaly I would love a feature to do some input operations in these windows. ex: Login/navigate.
If IE browser is an option, look at implementing a managed add-on that will allow you to hook into notifications when document is loaded, access to live DOM of the document, possibly notifications when DOM changes, and so on. The same can be done in FF/Chrome. With IE, look into IObjectWithSite COM interface. This article seems to be a decent tutorial, though I'm not vouching for its accuracy.

ASP.NET Browser Cache causing issues

I have looked for answers to this question, but I am not sure if I am asking it right.
I am looking for what do developers do in this situation:
I am developing an ASP.NET C# applications. I have CSS and SCRIPT files, and I am using jQuery. I install my application to the Web Servers (or I have my customer install them). If I have made any changes to my script files by adding some new jQuery or something, my customers don't get that effect after I do an update. I assume that the reason is that their browsers cache the file on the local computer and they do now download the new file from the server.
In my development environment I clear the cache when I close the browser and on IE I tell it in options to always load from the server. That way when developing I never have cached data.
What is the best practice to make sure that if I do make changes, those files get refreshed on the client computers after I do an update? Is there something in Code I can do?
I really don't want to change the filename and update all my script references.
Thanks,
Cory
The traditional way is to append a query string argument to the end of the reference to the css/script file path. For example, if you append a build number as the query string, each version of the software will make its own request for the relevant resource.

How to set database connection of .rpt dynamically

I don't know how to ask this question thru google, i try but what i've got is not what I want so i decided to post it here.
Currently i'm developing a crystal report for a particular web application. Now i manage to display my report in my development environment, once i deploy the web app and i want to show my report it always display this window.
I don't want to modify those .rpt again to adjust on the current database i want to do it in code, specifically in c sharp. any idea?
If you're hosting the controls yourself -- this post should provide you what you're looking for. If not I'll need you to provide me a bit more information surrounding your solution.
http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/7345fc6c-9749-42a3-b866-509c57f3cc35/

How can I launch a windows application from a webpage?

We have a company intranet and the powers that be think it would be nice to have a collection of icons/links representing the applications that most reps use (Outlook, Excel, few other apps).
The idea would be that if the application is installed, clicking the link/icon would launch the application on the client machine.
Anyone ever had a requirement like that and been successful implementing it?
Wanted to reach out to everyone before I go back and say no. Thanks in advance for any replies.
Make each button be a link to download a company template file for the given application. For example, the "Excel" button would download and the user should be prompted to open it with Excel.
For instance, try clicking one of the links here:
http://www.google.com/#sclient=psy&hl=en&q=template+filetype:xls
Linking to static files on the web server should be sufficient, so long as your server sends the correct MIME-Type or Content-Type.
You will probably have to adjust browsers' security settings to allow them to follow the links, but you should be able to use URLs of the form file:///C:\\Program Files\\Notepad.exe (You might prefer to use normal slashes / instead, as you don't have to watch out for how many copies of \ are needed to get past quoted string interpretation in whatever you're using to design the web page(s).
Using IE on a local intranet we have implemented this in an ActiveX control. Josh Pearce's solution works for those types of apps with MIME types, but not all apps you may wish to open would work this way.

Printing from the web at client side

How can we print using print document so that we can control the printer paper size?
It must be controlled after web
hosting is done without the print
dialog popup or javascript popup.
It should print on the client's printer
after webhosting without the print
dialog option and setting the paper
size.
It should be done in C# .net
As a user I don't want that when I enter a site someone to change my printer's settings or to take control over my printer.
For security reasons I hope this is not possible.
Your best option is to generate PDF-files with the appropriate siez in it. A printer should choose the correct page-size based on that unless the user manually changes it in the print-dialog.
Cirrcumventing the print-dialog is a security-restriction, ActiveX or a firefox-extension is your only alternative then, which might be okay on an intranet-based webapplication.
The only way that I've been able to have this amount of control over the printer client side is to create an ActiveX component that would handling the printing interface and go from there. It's not cross-broswer not the cleanest solution; however, it's the only way that I've been able to manage paper size. I looked into a CSS #print options but was not able to find one that could truly control the size.
The only other possibility is to look to see what printing capabilities something like Flash or Silverlight have. I'm not familiar enough to say if they do or don't have what you're looking for; however, it may be another option.
I believe a Java applet has the ability to set paper size if you grant it the proper privileges. I think your users will almost certainly have to jump through hoops for this to work...
Maybe too late but I'm adding for future reference; you could use a kind of download/print manager utility. Imagine the torrent magnet links, you click a link and a .torrent file opened by torrent client, it reads the necessary info and do the rest at client site.
So you have to write a little utility which one recognizes these 'print jobs' from your web site. You click a [Print Invoice] link and browser downloads a unique .print file and the utility captures it.
The .print file has two parts: 1. Header and 2. The file (pdf/jpg/any). Header contains predefined printer/paper size/orientation/etc or just asks for user input. And then prints the file from 2. part/body.
You may also queue the print jobs and manage them as well.
You have to install that utility; define a protocol like http:// or ftp:// to capture print links from the utility. And set printers/papers/etc for specific jobs like invoices/color printings/etc.
These will be what I'll do when I port our winforms app to web. Plus If you are on a LAN environment then you would print the things from the web server to network printers.
I have looked into this before, and the only way to force things like portrait/landscape etc, is to get the user to install an ActiveX control (or similar).
Javascript or CSS alone cannot do it.

Categories

Resources