Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client side communication with Windows application

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:

  1. Websockets. May be problematic with firewall issues since I don't have easy access to the system (geographical distance)
  2. 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.
  3. ActiveX control. Limited to IE and perhaps there'd be some security/setup issues with installing this on each PC.
  4. Leave the code as is. Gauge whether the load on the database server is too much or ok.
like image 483
Lee Taylor Avatar asked May 16 '26 07:05

Lee Taylor


2 Answers

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.

like image 84
kdojeteri Avatar answered May 17 '26 20:05

kdojeteri


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.

like image 24
GingerHead Avatar answered May 17 '26 20:05

GingerHead