I should have known you’d have your hand in that too Sebastian ;)
Ok, the simple stuff first – [Portal:URL] does not work, and in the UDT manual it says [Portal:PortalAlias], which returns this error “RESX:TokenReplaceUnknownProperty.Text”. This is not a value in the Portals DB table, so I assume it is retrieved dynamically from somewhere. I checked the PortalAlias class in the source and it uses “HTTPAlias” – but I am afraid none of these work.
I have been trawling through the code for some time now and it’s still not entirely clear where it checks the property name – from what I can see it loads each object type into a hashtable? The fact that I am not too hot on VB.NET does not help ;)
Ok, for the SecurityLevel – I am not sure what Scope.SystemMessages does, but I set the User and the AccessingUser to the logged on user (in my business requirement, DisplayName is always visible, but yes, some other properties might not be) and now it works – thanks).
I need some advice on my class design please – I am battling to understand how best to achieve this (Stefan’s blog entry confused me a little with the different Object sources and when you would use the BaseTokenReplace:
An example is probably the easiest to start with: Basically when a user (UserA) RSVPs to an event, UserB (Event Creator) receives an email. I currently have the following info in my template:
- EventName (from EventInfo object)
- EventCreatedBy DisplayName (UserB)
- EventUser DisplayName (UserA)
- List value (the RSVP option Y/N/Maybe), based on EventUserRSVPID in the EventUser object
- and a couple of others….
So… there are at least 3 different bits of data here – the Event object, EventUser object and the custom bit where it passes the EventUserRSVPID into the core List functionality to get a listEntryInfo.Text property. Currently this is implemented (n a very inefficient String.Replace method –
private string ReplaceParams(SmartThinker_EventInfo smartThinker_EventInfo, SmartThinker_EventUserInfo smartThinker_EventUserInfo, string rsvpText, string text)
{
text = text.Replace("[Event.EventName]", smartThinker_EventInfo.EventName);
text = text.Replace("[Event.Location.City]", smartThinker_EventInfo.City.ToString());
text = text.Replace("[Event.Location.Country]", smartThinker_EventInfo.Country.ToString());
text = text.Replace("[EventUser.Comment]", smartThinker_EventUserInfo.Comment);
text = text.Replace("[EventUser.EventRSVPText]", rsvpText);
return text;
}
Now, from Stefan’s blog – it appears as though I have 2 options – I could either make a basic class that inherited from BaseTokenReplace and essentially does a switch statement to return the correct value based on the property name, and I would pass in the EventInfo, SmartThinker and any other data I need, or I could use the PropertyAccess method.
From what I can see, I could implement IPropertyAccess in my Event and EventUser Info classes – the bit that is confusing me is how it all fits together. I checked the core PortalInfo object and it does not seem to implement this interface, which I thought it would have to? Where does it actually retrieve the value from? Does it load it into a hash-table somewhere? I assume I am going to need 2 new TokenReplace types here – one for Event and one for EventUser, with their respective PropertyAccessors.
Another question is that the text = tokenReplace.ReplaceEnvironmentTokens(text) seems to process all the different types of objects. Will I need to inherit from and extend that class to add my new object type to it so I only have to call NewTokenReplace.ReplaceEnvironmentTokens(text) to have it process all the token objects?
The other problem is the fact that I am using 2 UserInfo objects – how would you suggets I get around this? I need to make a class exactly the same as the current “User” one, but it muct only replace “User2” objects.
Sorry Sebastian, I know this is quite a complex post and I really appreciate your time - I am battling to reverse engineer it and some pointers on class design would help a lot!
ps - please excuse the colours/formatting - I wrote it in Outlook and pasted it and spent more time trying to make it uniform than writing it!