

In writing Vault Web View 2014, I came across a problem. I wanted to store a common configuration for some custom tab settings. The standard way to do this is with a Vault Option. The problem is that custom tabs are registered before Vault Explorer logs in to Vault. So how do I set up the custom tabs or custom commands if I can’t read the Vault Option?
A couple other people have run into this same problem, so I’d like to go over my solution. It’s nothing fancy or anything. It’s just a message telling the user to restart Vault Explorer. This technique works for custom commands, tabs and custom entity handlers.
Vault Web View deals with 2 copies of the config settings. One copy is kept locally as an XML file in the same folder as the extension DLL. The other copy is XML data stored in a Vault Option. When Vault Web View sets up the tabs, it does it based off of the local settings file.
|
public IEnumerable<DetailPaneTab> DetailTabs() { // local settings file read and deserialized to m_settings
List<DetailPaneTab> tabs = new List<DetailPaneTab>(); foreach (TabSettings tabSettings in m_settings.Tabs) { // configure tabs based on settings … }
return tabs; } |
Later on, when the user logs in to Vault, the extension reads the Vault Option and compares it to the local settings file. If they match, then the extenstion configured things correctly. If they don’t match, then the local settings file is updated and the user is prompted to restart.
|
public void OnLogOn(IApplication application) { Util.DoAction(delegate { CheckSettings(application.Connection); }); }
private void CheckSettings(Connection conn) { // read the Vault Option string xmlValue = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(
if (xmlValue == null) return;
// normalize the data // whitespace data may be altered when stored in Vault Option Settings tmp = Settings.Load(xmlValue); xmlValue = tmp.Save();
string settingsPath = System.IO.Path.Combine( string xmlValue2 = null;
// read the local settings if (System.IO.File.Exists(settingsPath)) { xmlValue2 = System.IO.File.ReadAllText(settingsPath); }
// compare the text values if (xmlValue != xmlValue2) { MessageBox.Show( System.IO.File.WriteAllText(settingsPath, xmlValue); } } |
And that’s it.


Leave a Reply