Disconnected Service Agent Callbacks

Topics: Mobile Client Software Factory
May 29, 2007 at 11:03 PM
Edited May 29, 2007 at 11:05 PM
First of all, I have only been using the mobile client factory for about a month, and so far very impressed !(though a bit of a learning curve).

I have a bit of an issue(confusion) with the DSA callbacks though. I would like to do something besides raise a message box. I would actually like to update my database with the values returned from the web service call. I could easily create a database object and do this, however I was wondering if there was any way to access objects in the class that made the original call to the disconnected service agent.

Particularly, I have a controller that has access to one of my repositories. I would like to use that repository if possible. I am still new to CAB, so apologies if my explanation is not on point.

Any help is appreciated.
May 30, 2007 at 2:35 PM
You could register the repository as a service and use it in the presenter or controller that handles the Callback return event.
I hope this helps.
May 30, 2007 at 4:19 PM
valdhorby, thank you for your reply.

I currently handle the callback return event in the callback method created by the DAS. I attempted to handle the callback in my controller that originally made the call, however the event doesn't fire (getting a file not found error).

I did try to register the repository as a service, however did not seem to be able to access it from my call back event. Ideally I would like the callback event handler to be able to send an event to the controller that called it.

Thanks for your help.
May 30, 2007 at 6:03 PM
Did you check the Disconnected ServiceAgent QuickStart solution?
It contains an example of just that: the presenter registers its event handlers to the events exposed by the Callback class (Restaurants.Module).
May 31, 2007 at 3:24 PM
Hey vladhorby,

Thanks again for your reply.

I don't have the Disconnected ServiceAgent QuickStart solution, and don't see where to DL it..if you could point me in the right direction that would be great. Is that for the Mobile Client Software Factory, or Smart Client perhaps?

For now I ended up creating static events in the Service Agent callback so I can notify other parts of my application when the call back has happened. Although this works, I don't feel it is the most elegant solution.

May 31, 2007 at 9:40 PM
If you have installed the May 07 release of Smart Client Software Factory, you should have a "Smart Client Software Factory Source Code Install" in its start menu->programs group. Install the source code and browse to the folder you selected -> you should see the various solutions files for quickstarts and the guidance package.
The quickstart uses static events in Callback too - I also find it not elegant.

To partially solve this problem and because I don't want to have the service entities referenced in the module project , I use this architecture:

Module - references only Module.Interface, not Module.ServiceAgents

interface IMyService - the interface for the service that is used in the Module

public class MyServiceImplementation : IMyService - , calls DSA.MyServiceReferenceClient.Agent, and registers its event handlers to the static DSA.MyServiceReferenceClient.Callback events, handles entity translation - both before calling the agent and in the Callback event handlers ; publishes events that can be consumed by presenters in Module, forwarding BusinessEntities

MyServiceReference - the service reverence

MyServiceReferenceClient - the DSA generated classes

This way I am able to change my service implementation without affecting the Module.

I hope I didn't confuse you more with this...