Custom Event/News Data Providers

Posted by Community Admin on 03-Aug-2018 21:25

Custom Event/News Data Providers

All Replies

Posted by Community Admin on 16-Feb-2011 00:00

Afternoon all,

I'm trying to determine if this is feasible or possible.

My organization makes most of it's profit selling Education and Training classes to members, to that end, we've bought and developed a rad tool internally (built on sql server/.net) to house education events in some tables in SQL Server

We've been using Sitefinity 3.x since we rolled out our new system and I'd like to try to find ways to more tightly couple Sitefinity to our back end. Right now, all of our user controls simply consume the querystring/session/control state and emit markup based on calls to our backend tables.

I'd like to be able to:
1. Use the Sitefinity News/Events modules to manage my back end data
2. Use the Sitefinity News/Events user controls to present the data to the end users

Will this be a matter of:
1. Create models for my objects
2. inheriting from DataProviderBase to persist my models to my database
3. adding a provider to the news/events settings
3. disabling the openaccess data provider

I appreciate the time anyone takes to read and answer.

I'd just like to get the green light from someone here before I go down a very long road of code. Also, now I have time to research instead of hacking something together to meet an immediate need.

Thank you!
Joel

Posted by Community Admin on 23-Feb-2011 00:00

Hello Joel,

I can propose one solution, which should be easier than implementing a custom news/events provider.
You can change the model of the news, by adding custom fields - so the news match your previous data model. Than you can migrate your data with some SQL script or SQL data transformation services into the sf_news_items table, respectively sf_events table. And from this point you can continue working with our modules and front-end controls. Adding of custom fields automatically will allow data-entry in the backend and you need to customize the front end controls to show your fields.

The other option is implementing a custom news provider that persists NewsItem type objects(or their inheritors) in  a custom way. The complexity here is related to the transactional nature of our providers,e.g. you can create,delete and modify persistent items, but they are not persisted to the database until you call the CommitTransaction method. When we use OpenAccess the persistent obejcts are in an ObjectScope that automatically provides such a transaction, if you do not use OpenAccess for persistence you need to do your own transaction implementation and keep track which objects were added, deleted or modified. So for example overriding the Create and Delete items is easy, you can add the  passed objects to some transaction log collection. But we don't have Update method, so you need a way to track which objects are modified. First of all you need to put all returned items from Get. methods into some transactional collection. You will also need to override all the property setters and have some flag changed when a property is changed. Then on CommitTransaction you can check all the objects in the Get collection for this flag and update them, or another way is to update all objects disregarding which are changed and which are not. In our backed we usually update one item at a time, so this can be simplified. If you have further questions , please let me know.

Kind regards,
Nikolay Datchev
the Telerik team

This thread is closed