Doing The Impossible

  • Thread starter Thread starter Greg Smith
  • Start date Start date
G

Greg Smith

Hello, I have been given a programming task that falls into the "impossible"
category with my current skill set. I am hoping somebody out there knows
how to do this and can save my b-t.



I work for a large University. I wrote a Windows-based database application
for my department that is used in purchasing. The University has just
released Web-base application that does the same thing using a sub set of
the data that my application uses. The people in my department hate it and
want to keep using my application, however, the University application MUST
BE USED to order. What my users have asked for is a way of doing a mass
copy and paste of the needed information from my Windows app to the Web app.
I have talked to the University's programmers and there is absolutely no
chance of them changing their application to facilitate this. It all has to
be done from the Windows app.



Obviously information could be cut and pasted a field at a time, but they
would like a massive copy and then go to the web form and paste, paste,
paste.



Is there a way to do this from the clip board? From a text file? Can I
assign a hot-key programmatically to paste things off the clipboard or text
file?



Any help is greatly appreciated.
 
Hi Greg,

It's not entirely clear to me what you want. I did some experiments
sending information to another program (PuTTY) from my C# program using
the clipboard, and it worked fine. I put some text on the clipboard, sent
a WM_PASTE message to PuTTY and restored whatever information was on the
clipboard to begin with.

However, this does not answer your question about mass copy.

I believe it can be done, but I don't know in what way the information
needs to be retrieved and pasted.


Happy coding!
Morten Wennevik [C# MVP]
 
Could you communicate with the web-based application using HTTP? ie request
the data-entry pages and then POST the values you want to store. Do this in
a bacth for each record.

Obviously that's a massive over-simplification but it might give you some
ideas.

Stu
 
hmmmm....

on the one hand i don't think the users should be allowed to dictate what
should be done

on the other, what they really want is shared data - not necessarily
copy/paste functionality

the solution is to look for another way to share the data between the 2
apps - definitely not the clipboard -at least not in my opinion

i would suggest looking at - .Net remoting - to have your desktop app grab
the data from the open Web form

- thats just a preliminary analysis with the little knowledge i have but you
for me, you cannot go with a copy/paste formula
thats a user perspective of how to fix what is primarily a software
engineering problem

you will probably have to develop a web service for this

key questions would be:

does the webApp use XML?
does it use .Net WebForms?
does it use ASP.Net?
how does it access and communicate with the data base?
how is the data stored in the browser? - HTML <Form> element? php, jsp etc?
....

as a worst case scenario where copy/paste is considered viable clipboard
sharing across domains is possible in .Net

hope this helps to at least give you a start
 
Hello Greg,

You could write a simple C# app hosting the IE Web Browser control (yes yes
it will be a simple specialized web browser). Your users would then open the
University's Web app in that browser, navigate to the page where data should
be pasted, and here comes the trick. Your existing app should be able to
copy all necessary data to the clipboard using some predetermined format
(say, CSV or even better - XML) - I hope this is not that hard to implement
.. The specialized browser, in turn, should be able to read the data from the
clipboard in that format and toss them to the Web page fields by using the
IE page object model.

Does this make sense?
 
Hi Greg,

What interface does the web application use? If you are lucky enough to have
a set of stored procs or web services that the web application uses then
maybe you could interface at a deeper level, and enable your users to do the
purchasing from the windows application.

A mass copy-paste scenario is a tricky and highly unreliable solution. Apart
from being incredibly difficult to implement, it doesn't solve the usability
problem of the web application. If you can interface at a deeper level then
you can still have your windows application feed data into the new web-based
system (but ofcourse you will skip the front-end altogether).

Tip: Check out the "'Auto-Complete" feature of the downloadable IE toolbar
offered by Google.

Good luck!
Luke Venediger
http://blogdotnet.blogspot.com
 
Come to think of it, since it's a web application you probably need to
send WM_PASTE to Internet Explorer, if that works.

Happy coding!
Morten Wennevik [C# MVP]
 
Greg Smith said:
What my users have asked for is a way of doing a mass
copy and paste of the needed information from my Windows app to the Web app.
I have talked to the University's programmers and there is absolutely no
chance of them changing their application to facilitate this.

Sounds rather like a data migration user requirement. How about discussing
the possibility of (you or the University's programmers) doing that?

Brad Williams
 
The way you describe the solution, I would look at it as doing the
impossible too, however, if you can convince the university programmers to
provide Web services on the server, you are back in business (tell them it
is cutting edge, that they will look important, etc, etc).
 
Greg said:
Hello, I have been given a programming task that falls into the "impossible"
category with my current skill set. I am hoping somebody out there knows
how to do this and can save my b-t.

I work for a large University. I wrote a Windows-based database application
for my department that is used in purchasing. The University has just
released Web-base application that does the same thing using a sub set of
the data that my application uses. The people in my department hate it and
want to keep using my application, however, the University application MUST
BE USED to order. What my users have asked for is a way of doing a mass
copy and paste of the needed information from my Windows app to the Web app.
I have talked to the University's programmers and there is absolutely no
chance of them changing their application to facilitate this. It all has to
be done from the Windows app.

Obviously information could be cut and pasted a field at a time, but they
would like a massive copy and then go to the web form and paste, paste,
paste.

Is there a way to do this from the clip board? From a text file? Can I
assign a hot-key programmatically to paste things off the clipboard or text
file?

Any help is greatly appreciated.

Couple of ways to do this:

- In your application, use the .NET web controls to create a POST response
that mimics the web response. You wouldn't even require that IE was running,
it could all be done behind the scenes. Caveats: if the web page POST format
changes, you will need to update your app; this method could be complicated if
there are cookies, logins, or navigation that is required before the POST will
be accepted.

- Instead of considering this one big copy/paste operation, look at it as a
series of single copy/paste operations. You could enable your application to:
open an instance of IE and navigate to the entry screen (or have the user
manually do that); then, text-box by text-box, iterate over the controls in
your application, copy the text, and paste into the corresponding text-box of
the web app. You would need to create a mapping between your text-box
identifiers and the text-box identifiers used in the web page, I'd recommend
using an external configuration file that can be quickly and easily modified if
the web page layout changes.

I'd consider the first option as the best solution as it can do the entire
operation behind the scenes and your users don't have to mess w/ the web
version at all.
 
Greg:
There are a few technical alternatives, and I think that the other posts
cover most of them. For any of those solutions, you will face maintenance
issues where you have to update your code to parallel changes made to the
web application, and depending upon how the application in implemented,
there might be a danger of posting the wrong value to the wrong field if the
web app is ever changed in a way that takes it out of sync from your
application.

However, this feels more like a project management problem than a technical
problem. You are dealing with 2 different departments -- yours, and
whatever department the web application came from (administration?
development?). In order for this to really work, your project is going to
need a sponsor. The sponsor would be someone who has authority over both
departments, such that they can arrange that the two groups work together to
create a solution.

The bare facts are that you have a project which will require some degree of
coordination between at least two departments in order to be successful.
The only way that you are likely to get that is if you have someone in
management to tell both of the departments to work together. This might be
accomplished through the cooperation of your two department managers, or it
might be accomplished with the help of someone who has authority over both
departments.
If you don't get cooperation between the departments, this project is likely
to fail.

You are going to need at least some level of cooperation with the owners of
the web application -- so that you can get the data exchange right, and so
that you can be aware of changes that you need to make to your system to
keep it in sync with updates to the web application. In order to get that,
you need for your department to be in collusion with the programmers, and
for that to happen, you are going to need someone with authority to create
that relationship -- your sponsor.

If the workers in your department are really behind your software, your best
ally will likely be the manager in charge of the purchasing group that uses
your application. Of course, you will ultimately need for your department
head to buy in to your idea. Indeed, you probably don't want to go looking
for a higher level sponsor if your department head doesn't agree with you --
that could be a bad political move.

If there has already been a University-wide decision to use this new web
application for purchasing, it might be that a decisions has already been
made at a high level. In that case, you are probably going to have a hard
time getting sponsorship. At this point, I'm making quite a few assumptions
about the situation. But to plunge on: If the University has already
decided at a high level that purchasing will be made through the web
application, administration will probably be disinclined to create an
exception to the rule for one department. Your goal will be to show how
providing interoperability with your application will add value (save money,
save labor, save time, reduce errors etc). The first person that you want
to convince will probably be your department head (assuming that there is no
manager between you and your head, if there is, make sure that this/these
individual(s) are involved as well).

If that sounds like a lot, it really might be. It depends upon what level
of involvement you need from the other department. And, that depends upon
what technology you use to accomplish the interoperability (I would be
thinking about the lower-level options that have been surfaced on this
thread: a web service interface if I could get the web programmers to build
one, or perhaps http posts from my application if I couldn't).

Whatever you do, have a good idea of what sort of cooperation you need from
the programmers: specs only, http support and change coordination, web
services, etc. Also, getting this project off the ground might be easier if
you can demonstrate how it will help outside of your department. How many
other departments use their own systems for purchasing? If the web
programmers created a general http or web service interface, it could assist
those other departments as well. You might not be the only ones who need to
integrate your operations with the new system.

Sorry for the long rant -- I've been through the bottom-up grass roots
project pattern before. The chances for success are pretty low if you don't
have mgmt behind you.
 
copy/pasting is an amateur's solution

you need to access the web apps datasource and do a programatic update of
the datasource and fire a reload of the data in the web app (a POST or GET
if it uses <form> elements) - or something similar

you absolutely have to know how the open web page data is stored on the page
if you try to do it any other way

like i said, is it ASP, JSP, PHP, HTML with <form> elements, .Net WebForms
or whatever

you have to know the data structures involved - if you don't then how will
your app know where to paste the multi-fielded data in the web page?

if you don't care to deal with the web apps client-side structures, and
theoretically, you should not - then modifying the datasource or directly
communicating between your app and the web using a SOAP or whatever
protocol - is the way to go

you can do this in .Net remoting

if the web app guys are not interested in opening up the app for
communication then you'll have to go with either moding the datasource with
your win app or at least knowing all of the structures used in the web app
and being able to copy the data directly to the web pages <input> element
fields

you could also create a Browser Extension (also supported in C#) or Plugin
that does this

but if i were u i would forget copy/paste solutions unless the management
forces it on you - simply cause it's not a professional or even a good
solution

;-)
 
Thank you for your response Julie.

Your first solution looks good but if do anything to by-pass any of their
web processes I will be shot.

Your second solution is EXACTLY what they asked for. It would make them
very happy. The only problem is that it is a bit over my head at this
stage. Can you point me to any examples, code snippets, etc. that would get
me going on this?

Once again, thank you fro your very helpful response.
 
ug. Doing cut and paste is a bit dirty. Sounds like a little reverse
screen scraping which is not any better. This screams for web services or
remoting. Note they don't need to re-tool the web app per se, they just
need to add a web services interface so your client app can talk to it.
This is what MS is spending billions on trying to get people to do. Not
sure why you would even need to sell this to them, they should want to do
this to allow flexible input from other client platforms. XML web services?
They never heard of it? Another hack would be if they allowed a file to be
passed (maybe xml format) and use ftp or other. They then read this dir on
a scheduled basis. You could do same thing with email. Talk to management
with some users. Does not sound like they care about the user's.
 
Just to clarify on Julie's response. Her first solution does not bypass any
of their web processes, what your application would in effect be doing is
acting as (for lack of a better term) a proxy to the web solution.

The flow of your program would be to collect the data as you are now, and
then pass it on to the web app in the same manner that a browser would using
the HttpRequest object. Granted there are drawbacks as have been previously
mentioned(cookie management, maintenance problems if the web interface
changes...).

All in all I have to agree with other peoples position that the other
departments programmers and yourself would be better served exposing the
same functionality that exists now through a set of webservices.

HTH
Chris Torgerson
 
Just to clarify on Julie's response. Her first solution does not bypass
any
of their web processes, what your application would in effect be doing is
acting as (for lack of a better term) a proxy to the web solution.

Hum .... I guess I'll have to take your word for it, I have been strickly a
Windows side developer so far. Can you point me to some examples on how to
do this? It is currently over my head.

Thanks.
 
these solutions assume that <FORM> elements are being used in the web app -
never assume anything

they also assume you don't really know what you are doing, 'cause if you
implemented it like this and the user input pages actually use java applets,
or something else, not only will it not work but it may cause the web app to
crash & burn

besides, like i and others keep repeating - any kind of copy/paste solution
is both unprofessional and very 'dirty' not to mention very poor informatics
analysis

make sure you know what the basics are before you even start thinking of a
solution ! once again - data structures, protocols, data access, COM
objects, ....... find out first, then pick a good stable professional
solution

go with .Net remoting
 
Greg,

I'll be honest with you, and I hope you don't take this as an insult at
all, but what they're proposing here, and I think it's probably your best
solution, is also fairly complex if you're not familiar with doing web
programming and I'm afraid may be more than you'll feel comfortable with. I
only say that based on your responses to what has been mentioned so far.

I'll try to make it simple and give you an idea of what they're
proposing, in a bit more detail.

A web-based app is a transactional type environment. Meaning, user is
presented with a form. User fills in form. User presses button and form data
is submitted. It's not very interactive, though.

What you'll be doing is acting in place of the web browser. You'll send
the data users typed into your forms, to the web application, encoded in the
same format that a web browser would encode it. So as far as the web app is
concerned, you're just another web browser using the app.

This is the part that I think will probably be most challenging for you
if you're not familiar with web apps. Essentially there is are a couple of
ways that web pages send data back to the web server. Via a POST command,
which is the most likely I think, or possibly a GET command. They basically
differ in the way that they send the data back to the web server and which
one you use will depend on the web app. You'll have to take a look at the
source for the pages and see.

You'll then take your data, encode it, and send it as if the user had
submitted the data in the online form.

Beyond things like the cookies and stuff that others mentioned, you could
also run into problems if they're using an ASP.NET web app. Short of
actually controlling a web browser control, it's very likely you would have
a very hard time mimicking an ASP.NET app.

Hope this clears it up a bit.

Pete





Wow, that was one long, run-on sentence, wasn't it?
 
Hi Greg,

Do you still have any concern on this issue? I think the community has
provided much information to you. As whole, there are 3 ways to get this
done: .Net Remoting, Web service, and leverage web browser control. Does
this make sense to you?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Jeffrey Tan[MSFT]" said:
Hi Greg,

Do you still have any concern on this issue? I think the community has
provided much information to you. As whole, there are 3 ways to get this
done: .Net Remoting, Web service, and leverage web browser control. Does
this make sense to you?

Not as much as I would like. I have been a Windows side only person. I was
hoping someone could point me to some example code to jump start me but I
think I just have a lot of reading to do.

Thanks for all your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top