mawtex wrote:
I didn't get it to work. Here is my code. As you see I want to get the page content's that I just updated and published. What am I doing wrong?
The OnStoreChanged and its storeEventArgs are intended for reacting in situations where out-of-process changes were made to data and here you do not get the individual data items handed to you.
If you need to react to detailed data events you should hook on to "data changes", like OnAfterAdd and OnAfterUpdate. These will fire in the same process where the data changes is happening.
For all the available events see DataEvents<T>.
I didn't get it to work. Here is my code. As you see I want to get the page content's that I just updated and published. What am I doing wrong?
public static void RegisterEvents()
{
//Events
DataEvents<IPage>.OnAfterUpdate += new DataEventHandler(IPage_OnAfterUpdate);
return;
}
static void IPage_OnAfterUpdate(object sender, DataEventArgs dataEventArgs)
{
using (DataConnection connection = new DataConnection(PublicationScope.Published))
{
var page = connection.Get<IPage>().Where(x => x.DataSourceId.DataId.Equals(dataEventArgs.Data.DataSourceId.DataId)).FirstOrDefault();
//testing..
var titel = page.Title;
var description = page.Description;
}
return;
}