1. Brian O'Malley
  2. SnapDevelop
  3. Thursday, 4 February 2021 14:27 PM UTC

I am just starting to look into using SnapDevelop to possibly migrate our application.  I am using SnapDevelop 2019 R3 Build 2622. 

I have completed some of the tutorials, all of which seem to have only 1 dw that is imported and retrieved/updated/etc. I created a small app with 2 dws (d_department and d_employees) and used the dw convertor to import them both, and the scaffolding to create a service, iservice and controller for each.

I have a question of scale.  If I have an existing application with 100 dws, obviously I will need to convert 100 dws into SnapDevelop project, but does that mean I will need 100 individual services, iservices and controllers or is there any way to make it more generic?  For instance, I see that the scaffolding made something called PbServiceBase and IPbServiceBase but I am not clear what exactly they are for.

Thank you for your help!

Brian

 

Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 4 February 2021 16:29 PM UTC
  2. SnapDevelop
  3. # 1

Hi Brian,

 

Yes, you can have a single service which would retrieve all the DataWindows. You would just pass in the name of the DW and any parameters the DW might require. There is, in fact, a demo application that uses this technique (https://github.com/Appeon/.NET-DataStore-Example). It also includes a PB client demo app so that you can see how to consume the Web API.

 

public IDataStore Retrieve(string dataobject, params object[] keyValue)
{
   var datastore = new DataStore(dataobject, _context);

   datastore.Retrieve(keyValue);

   return datastore;
]

 

 

Regards,

Comment
There are no comments made yet.
Brian O'Malley Accepted Answer Pending Moderation
  1. Thursday, 4 February 2021 15:55 PM UTC
  2. SnapDevelop
  3. # 2

Looking for an example of what you said above "you could have a a single controller mapping to a single service and in that service multiple DataWindows are used".  As I mentioned above, I have a sample app I built with 2 dws which retrieve from 2 different tables.  No retrieval arguments, nothing fancy, just basic retrieve the contents of the table.

In DepartmentService.cs I have the following:

     

I have the exact same thing in EmployeesService, except all the references to <Department> are replaced with  <Employees>.  In order to use a single service, do I still need 2 retrieve methods defined:

public async Task<IDataStore<Department>> RetrieveAsync(CancellationToken cancellationToken)

public async Task<IDataStore<Employees>> RetrieveAsync(CancellationToken cancellationToken)

 

Or can I can a create a generic Retrieve which will take any dw passed in (not specifically Department or Employees)?

Thanks again for your help!

Brian

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 4 February 2021 14:49 PM UTC
  2. SnapDevelop
  3. # 3

Hi Brian,

How many services and controllers is really up to your what you are trying to accomplish and what is the best design for that.  There is no single answer to this.

For example, you could have a a single controller mapping to a single service and in that service multiple DataWindows are used.  As another example, you could have a single controller mapping to multiple services and in each of those services multiple DataWindows are used.

The templates in SnapDevelop for scaffolding the controllers and services are based on repository pattern of programming.  But you can create your own templates so SnapDevelop scaffolds your project the way you want.

Just to clarify, you will have a C# model for each DataWindow.  So 100 DataWindows means 100 C# models.  The C# model is basically the C# flavor of the DataWindow data object that is the definitions of the DataWindow.

Best regards,
Armeen

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.