Multiple Data Portals

Multiple Data Portals

Old forum URL: forums.lhotka.net/forums/t/1755.aspx


David posted on Monday, November 13, 2006

I have a Windows Forms application that normally runs off the network and therefore uses a local SQL Server database. However, when I connect to the network I need to save a BO to an external database on a web server.

To handle this I created a second class library within my solution with a single shared function that accepts the BO and saves it to the database on the web server. With everything running locally (the web server is currently on my LAN) it all works fine.

I then tried to configure the new class library to run remotely, but I can’t see how to configure the client so that my main class library is local and the new one is remote. When I add the following lines to app.config it always looks to the server for the data portal.

<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.RemotingProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://www.mysite.com/remotinghost/RemotingPortal.rem"/>

I guess I could create a second Windows forms app to handle the remote upload and call that from my main app. Not very elegant but it does give me separate app.config file and therefore solves the problem. Is this the only solution or is it possible to configure the class libraries to use different servers?

Sean D replied on Tuesday, November 14, 2006

Hi David,

I ran into a similar situation recently.

As long as the SQL Server is accessible locally to the WinForms application, then you can simply mark those objects as [RunLocal()]. Note: This means that the data access methods will be run on the clients' machine. So they must have access to the database server (via ADO.NET or Enterprise Library).

If you configure the main DataPortal to be remote, then the other business objects will be run on the remote server (which will require access to the database).

I hope this helps.

My situation, albeit similar, has yet another issue. My Winforms app doesn't have direct access to the database layer. Therefore the objects that I create on my client machine ([RunLocal()] call webservices methods in the DataPortal_XYZ calls, and the rest (run remotely) execute on the application server that is beside, and has access to, the database server.

This solution works OK.

See this thread for further details:

http://forums.lhotka.net/forums/thread/8972.aspx

 

Regards,

Sean

David replied on Tuesday, November 14, 2006

Sean - thanks for the suggestions. The problem with using RunLocal for me is that all of my objects bar one are required to RunLocal, so I could see this approach leading to maintenance issues that I would rather avoid.

I tried my earlier suggestion of creating a second WinForms application, but that didn't work either. I called it from the first app and passed it a copy of my object but it used the same dataportal as the main app.

In the end I read chapter 11 and wrote a web service to handle the remote requirement. This approach doesn't use the data portal at all so has removed my original problem. It was a lot more work than I had hoped as I discovered it is not that trivial to pass a complex BO to a web service. On the positive side it was an interesting learning experience and works like a charm.

David

Copyright (c) Marimer LLC