API
Version 7.x > API > Kentico 7 connector - detect data changes View modes: 
User avatar
Member
Member
david.mavin-sky - 9/5/2013 9:32:34 AM
   
Kentico 7 connector - detect data changes
Hi,

We have create a connector which works on an object such as user, however, I wish to detect when a specific field is changed - this will probably be an extended field on the object such as Order. Anyway, I cannot figure out how to use the DataChanged? For example I create a list of all columns from the user object and then remove the FirstName column from this list - this produces a list of all columns without FirstName. Therefore, I would assume that the exclusion list now included all fields except the FirstName so when I call infoObj.DataChanged("exclusion list") I would expect only it to return true when the FistName is changed BUT it is always true even when logging in.

Why is there not simply a method which stated infoObj.DataChanged("What Column") rather than exclusion which seems a bit odd. Anyway, I am yet to see this method actually work against anything - anyone used this or is there a alternative/better approach to what we are trying to achieve???

User avatar
Member
Member
kentico_sandroj - 9/7/2013 1:17:04 PM
   
RE:Kentico 7 connector - detect data changes
Hello,

We consulted this with the devs responsible for integration bus functionality and it turned out that the given method is not fully supported yet in our API. We are sorry for this inconvenience. It will be fully supported starting next version, which will be released in several months.

However, I asked for a workaround and the following seems to be the best available option: You can define a custom field for your user and every time the object is synchronized, you save serialized values of all current fields that you would like to check against, within this column. So, it gives you something like checksum. Then, every single time a synchronization is fired, you compare current values with this checksum and can see whether data has been modified since previous run or not.

You may also be able to create a custom subscription class and subscribe only to specific changes, if that would work in this case.

Best Regards,
Sandro

User avatar
Member
Member
david.mavin-sky - 9/8/2013 7:39:45 AM
   
RE:Kentico 7 connector - detect data changes
Hi,

That would explain why I could not get it to work then ;) What version will this be available in and for the work arounds could you give us any sample code - know this is a long shot but we are new to Kentico and we really need to get this working.

All the best
David

User avatar
Kentico Support
Kentico Support
kentico_radekm - 9/9/2013 5:37:45 AM
   
RE:Kentico 7 connector - detect data changes
David.

It should be supported starting Kentico CMS 8.

Best Regards,
Radek Macalik

User avatar
Member
Member
david.mavin-sky - 9/9/2013 9:23:47 AM
   
RE:Kentico 7 connector - detect data changes
Any chance of sample code for the work around's please?

P.S Also started looking at the scheduler, how does this work in Azure as it looks to me that tasks can be fired external, but your implementation utilizes a windows service - is there an implementation using an Azure worker role?

Many Regards

David

User avatar
Kentico Support
Kentico Support
kentico_radekm - 10/2/2013 1:37:20 AM
   
RE:Kentico 7 connector - detect data changes
Hello David.

Regrettably, we do not have any sample code for this. However, this task basically contains of several simple steps:

1. Create new custom field for your user in CMSSiteManager / Development / System tables / CMS.User.

2. Every time an object is synced, read its values from UserInfo object (you can get it via UserInfoProvider.GetUserInfo method, or from CMS.CMSHelper.CMSContext.CurrentUser class), serialize them using common .NET/C# code (http://stackoverflow.com/questions/10392268/serialize-deserialze-to-a-string-c-sharp) and save into that custom field.

3. During every future synchronization, compare this „checksum“ to current values.

Regarding your second query, I will consult it with our cloud specialist and get back to you. Thank you for your patience.

Best Regards,
Radek Macalik

User avatar
Member
Member
david.mavin-sky - 10/2/2013 3:04:53 AM
   
RE:Kentico 7 connector - detect data changes
OK will try the solution supplied.

With regards to the second question I created a multi threaded worker role, with thread monitoring and recovery to fire each task. This works quite well and gives us the ability to poll schedules, fire the smart search worker and execute custom assemblies also. This solution allows us to contain the system schedules and the smart search in a single worker role now and acts similar to the Windows service except it allows each task to be on its own threads and we can control the timing of each - took me about a week to write.

We could not use the NT service as we are using Azure as Paas.

Many Regards
David

User avatar
Member
Member
david.mavin-sky - 10/2/2013 10:34:04 AM
   
RE:Kentico 7 connector - detect data changes
As a side note I believe you can also add a configuration key to the Smart Worker to fire system scheduled tasks but we wanted more control over it.

Cheers
David

User avatar
Kentico Support
Kentico Support
kentico_filipl - 11/20/2013 6:32:17 AM
   
RE:Kentico 7 connector - detect data changes
Hello David,

Windows scheduler can be enabled even on worker roles. You just need to use the startup script which is located in ~\SmartSearchWorker\InstallService.cmd file.

Please follow these steps to enable it:
1. Open the ServiceDefinition.csdef file and uncomment the following code:
<Startup>
<Task commandLine="InstallService.cmd" executionContext="elevated" taskType="simple" />
</Startup>

2. Open the InstallService.cmd file from the SmartSearchWorker project and replace <YourAppGuid> with the value of the CMSApplicationGuid key. You can find the key in the appSettings section of the Web.config file in the CMSApp project.
SET _guid=<YourAppGuid>

3. The InstallService.cmd script creates a user with administrator rights on your Windows Azure machine, which will then register the services. Therefore, you need to choose a password for the new user and insert it into the script file.
SET _adminPassword=<YourPassword>

4. Open the Visual Studio's Properties Window (by selecting View -> Properties Window in the main menu or by pressing F4) and set the Copy to Output Directory property to Copy always for the following two files (both are located within the CMSApp project):

App_Data/CMSModules/WinServices/services.xml
Web.config


The solution is now ready to be deployed to the cloud. Once the application is deployed and starts for the first time, the InstallService.cmd script will register the services into the system.
Make sure both services are registered and running. (You can see them in Services (Windows -> Administration tools -> Services)), both services name begin with KenticoCMS prefix.

Best regards,
Filip Ligac

User avatar
Member
Member
david.mavin-sky - 11/21/2013 2:29:20 AM
   
RE:Kentico 7 connector - detect data changes
Hi,

Thanks for the information, but I do not believe this will work on Azure. I think it will work on Azure if you have dedicated VM's but not on Azure when it is dynamically allocating the VM's. I could be wrong here, but as said we created our own dedicated work role to do this and it is firing all of the systems tasks correctly.

Cheers
David

User avatar
Kentico Support
Kentico Support
kentico_filipl - 11/22/2013 5:24:33 AM
   
RE:Kentico 7 connector - detect data changes
Hi David,

It was tested on Azure for deployment of the application as a cloud service which is also your case I suppose, is that right?

Best regards,
Filip Ligac

User avatar
Member
Member
david.mavin-sky - 11/22/2013 11:37:37 AM
   
RE:Kentico 7 connector - detect data changes
Hi,

Your are probably correct here, but we wanted to absorb the SmartSearchWorker role and all schedule tasks into a single worker role (one VM) and also have the ability to execute custom assemblies within the worker role also.

To be honest, this is working out for us just fine, so we have a single worker role firing the Smart Search, all system tasks, custom tasks and any custom assemblies we wish to create.

So its not really an issue as such, just the way we have approached this. Its all using the Kentico API's except for the custom assemblies, so it works for us.

David