I have been breaking my head over this. I appreciate any help.
I have a custom PersonalizationProvider, custom WebPartManager and custom WePart class. I have custom data tables for storing the Personalization Data per user. My task is to programmtically loop through all the web parts added by each user so that I can set a personalizable attribute.
According to the documentation, FindState method returns a PersonalizationStateInfoCollection for a given PersonalizationStateQuery:
PersonalizationStateQuery pq = new PersonalizationStateQuery();
pq.PathToMatch = path;
pq.UsernameToMatch = userName;
int count;
CustomPersonalizationProvider provider= new CustomPersonalizationProvider();
PersonalizationStateInfoCollection pcol = provider.FindState(PersonalizationScope.User, pq, 0, Int32.MaxValue, out count);
PersonalizationProvider is an abstract class and I will have to provide my own implementation for the FindState method in my custom class. I have spent last 6 hours trying to find something and I don't know how to implement this method.
The PersonalizationData is blob. I could deserialize it to object array. But nothing further. I have no idea how to serialize/deserialize that blob in to PersonalizationStateInfoCollection.
String BlobString = Convert.ToBase64String(UserDataBlob);
ObjectStateFormatter formatter = new ObjectStateFormatter();
Object[] DeserializedObjects = (Object[])formatter.Deserialize(BlobString);
Does anyone know how WebPartManager serializes the UserPersonalizationData in to the byte array that is stored in the database?