Plugin Developer DiscussionDiscussion for FogBugz Plugin developers |
||
My plugin saves data as key/value pairs in CPluginKeyValueTable. I see that all data are cleared when the plugin is removed from the installation. Is there a place where to save data that will survive longer?
Data like activation keys, version of last installed build of the plugin... Thanks
This isn't really supported by the API right now, but here's a workaround:
The data in KeyValueTable isn't deleted when a plugin is deleted, it's just keyed on the ixPlugin which changes when a plugin is deleted and reinstalled. Since you can use a CSelectQuery to query any table in FogBugz, you could search for a previous installation in the KeyValueTable using something like a GUID: CSelectQuery query = api.Database.NewSelectQuery("PluginKeyValue"); query.AddSelect("ixPlugin"); query.AddWhere("sKey = 'a1783c96-846b-418e-942b-74fd15798023'); query.IgnorePermissions = true; DataSet ds = query.GetDataSet(); int ixPlugin = ds.Tables[0].Rows[0]["ixPlugin"]; Now you know the ixPlugin it was installed at last. You can use that to get the rest of its KeyValueTable: CSelectQuery query = api.Database.NewSelectQuery("PluginKeyValue") query.AddSelect("sKey"); query.AddSelect("sValue"); query.AddWhere("ixPlugin = @ixPlugin"); query.SetParamInt("ixPlugin", ixPlugin); ds = query.GetDataSet(); Unfortunately you won't be able to update the data. |
Powered by FogBugz