I have a C# web application (MVC1, .NET 3.5) with a function to generate reports. I was wondering if anyone has suggestions for how to implement the following scenario:
Logged in user clicks on the report button and goes on to browse other parts of the website OR simply logs off
Once the report is finished generating, it is e-mailed to the user
Main question being - how can I start a separate thread on the server that will accomplish this? If multithreading is not the way to go, please feel free to make other suggestions. Typical time to generate a report can be upwards of 10 minutes. Also, this functionality will rarely be used by more than one user at a time so I am imagining something along the route of "queueing up" a function and letting it execute in the background.
Thanks for all your help!
I suggest creating a Windows Service that polls the database for reports to generate, generates them and emails them. The specifics of the report are entered by the user on the website and the website simply stores that information in a database.
Have you looked at utilizing Microsoft Windows HPC Server 2008.. It fits your use case perfectly or you can stick to the routine and write a windows service that does this for you. But if you can afford it I would recommend jumping on the HPC bandwagon..
You can start reading about it here
Related
I have a windows application that reads from a database and populates multiple Listview containers depending on what items the user selects. Some of the data in a particular Listview is right-clickable with a MenuItem option to ‘Write Data to Excel’. This may take around 10 minutes to complete.
I have the Excel Interop portion written in stand-alone code or can I incorporate it into the application project. The Excel Interop app takes only 1 parameter to do its thing.
My question is… should I incorporate it into the Windows App and use multithreading or run it as a standalone app (which seems more efficient), which is called from the Windows App? And what is a good way of doing that where the Windows app starts the process and then can forget about it.
I think that the answer for this one is answered by the question : "What should happen if the user closes the main application during those 10 minutes ?"
If the file should still be wrote, then a standalone application is perfect, cause your threads won't survive.
If the file creation should be interrupted, then I see no reason not to use multithreading, as it seems simpler by default, in particular debugging this part of the code is way easier if it's in the same application.
I would recommend for the below flow:
We can create our own queue which will be either maintained in database or file system.
Then we can write a scheduler which will fetch all the unprocessed request and with the respect to response mark appropriate status of queued item.
Now You application can just call the queuing process and move forward from there.
Use another thread to write it.
I'm working on a project, and the client wants the data in their sharepoint 2010 webpart to update automatically based on what time it is. We're using C# to write the code.
I've tried just about every way that the four corners of the internet have provided to come up with a good way to do this, however, I'm stumped. I'm aware that there are three different timers that come with visual studio 2010 (which is what I'm using). Is there any way at all to do this?
Here are some of the ways I've tried:
-create a timer job that runs on central admin (this method is covered in several web tutorials), I got the timer job to work, but I can't figure out if there is a way from this to refresh the web part with the new info. I was basically using the SPJobDefiniton class and a feature.
-tried to use the built in system timer, as covered here:
http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx
tried to adapt that to a web part, and that went nowhere. The web part built, but the timer never ran.
-tried it with System.Threading.Timer, and also went nowhere fast.
Is there any way that someone knows of to get the functionality I want? Thanks.
Looks like nothing to do with SharePoint for me...
You probably need client side timer in your JavaScript window.setTimeout and force update of whole page (easy, just change window.location) or partial (need some service to pull data from, update part of the page - harder, but better looking).
Server side just render data based on current time...
I have a web-based picking/packing solution for delivering orders (asp.net/c#). Orders are marked as packed in the browser and then immediately the label information is added to our database, ready for the next part...
The label printing is done via a Windows application (written in C#) and was done this way because I couldn't find a way of getting the browser to print the label automatically (i.e. without the user having to click Print/OK, etc.)
The problem:
The Windows application polls every 10 seconds (subject to change) to see if there are any new labels for that picker/packer. Now, if I could get the browser to communicate with the label application then the polling would be unnecessary, since the picker/packer would have just clicked "Ready to Ship" and the label data would be created.
The data that is pulled down by the polling process isn't vast, but I'm concerned that as we add more picker/packer stations the polling process could have a knock on effect to the web server/database (since all stations would be polling). Also, pickers/packers don't want to wait around waiting for labels, so extending the polling time isn't possible (if anything I'd like it as quick as possible)
Solutions?
So, ideally, I'd like a way of communicating between the browser and the application (if possible). Or any method that removes the need for polling. Perhaps something akin to Comet, that allows the server to send a message to the application when a new label is added.
Ideally, a solution that wouldn't require a specific browser. But this may be asking too much.
A long-term solution would be to move the web-based picking-packing solution into the label application, but that would be a lot of work!
I hope that's clear and not too wordy. Let me know if I can add any other details in here. Thanks in advance.
Edit
Am looking into websockets as an idea. Any advice will be more than welcome!
Update
Thanks for all comments. I've now got a few ideas on how to solve the problem:
Websockets. May be problematic with firewall issues since I don't have easy access to the system (geographical distance)
Read browser cookies from the application. Possible solution http://www.codeproject.com/Articles/330142/Cookie-Quest-A-Quest-to-Read-Cookies-from-Four-Pop. This covers all the browsers that are in use in the warehouse. I can poll the local cookie values and see if any new labels have been created, then download them. Therefore no polling on the database server.
ActiveX control. Limited to IE and perhaps there'd be some security/setup issues with installing this on each PC.
Leave the code as is. Gauge whether the load on the database server is too much or ok.
You could create a local WebSocket server in your C# application and then make the browser connect to it and send the data you need to print.
I'm not sure, though, that this is what you need. As I see it you need to pass graphical data to your application, which could be really tricky to do using only javascript.
The appropriate way to achieve the communication between a web application and a desktop application would be to go through a server both apps talk to.
You can get any web-server (e.g. node.js nodejs.org that will let you use the same javascript you use for the web-app on the server) and interact with it. How you talk with the server from the desktop app depends on its technology. However all languages have some way to do http communications like SOAP.
Or you can try to make:
Both apps talk to the server using socket.io. You can borrow code from the following project.
Create an MSMQ (or a queue implementation of your choice) and host a WCF service in your windows application that polls the MSMQ.
Have your ASP.NET application write any relevant information to this queue so that the WCF service in the windows app that pulls this information will know what to make of it and print your labels.
The reason I mention a queue is for reliability, if your windows app goes down for any reason, the queue will at least be preserved and waiting for you to bring the windows application back up.
Although there is a bit of polling involved, it is very quick and almost neglibible. Implementing it is automatic with NetMsmqBinding, it's all taken care of. All you need to do is configure it.
If you go for a non-MSMQ queue, then I don't know whether you can still use NetMsmqBinding, you may have to create your own.
I'm not sure, but it seems like your application is polling a filesystem for these new labels to print? Have you considered using a FileSystemWatcher in your application? You can set that to watch a directory and be notified of anything new.
I would like to record the actions of a user when they are using the base Operating System with my application open.
For example, Clicked Start, Clicked All Programs, Clicked Microsoft Office, Clicked Microsoft Word....
Can anyone suggest a sensible method to achieve this?
The idea is that the user's actions are only recorded when my application is open, its meant to be an alternative to the Microsoft recorder. It creates a written procedure that can be sent to a customer service department.
I guess you should ask yourself if your users will appreciate this! Maybe they care about their privacy.
Anyway you can do it using hooks (I think you're writing for Windows). Same task as a macro recorder.
If you are trying to do that, why not just use an existing program. We used AutoHotkey at my last job to do this for creating UI testing code.
You could ask the user to install AutoHotkey and have them record the script. It can then be sent to you. You can run the script yourself (although you may have to tweak the screen resolution and things like that), and see what was happening.
EDIT:
Another idea is have the user record a screen cast and send that to you. It might make it easier to debug.
I didn't know what Microsoft Recorder was, thought it was the sound recorder, didn't realize there is a Microsoft Problem Recorder bundled in Win7, which does the whole screen cast recording.
I have a ASP.NET website running on Server 2003 with SQL-Server as database.
I have two tasks that I want to automate on daily basis.
1) Update the Lucene search index file
2) Update the profile pic of all user from LDAP server
I have both codes in aspx pages but I want them to run daily at midnight or 4 am in the morning or something like that. I havent done any automation before so I am clueless. So
my question is...
What are my options?
Thank you :)
You've got some options:
There is this on Code Project Simulate a Windows Service using ASP.NET to run scheduled jobs
You can write your own Windows service.
You can go the commercial route and use a web based scheduler. Two popular ones are:
web.scheduler and web based cron
Another option is to create a Windows scheduled task. When the task fires off, you can have it hit a page that runs the logic you wish to perform. Here's a linked solution on SO: Recommended method for loading a URL via a scheduled task on Windows
If you're looking for automation within your asp.net web application, consider Quartz.net as a good free, open source solution. We've been using it to automate maintenance tasks and are quite happy with the results.