Hi,
This might be one of these "oh sh.. how could I forget this" things, as I have implemented IUpgradeable quite often - and this time I am stuck for days.
I have to upgrade a site to DNN 7.4.2, and therefore modify some smaller stuff in a custom module (Search...). One thing is to remove two controls, and that could only be done in the UpgradeModule method by implementing the IUpgradeable interface. So here is what I have done:
I created a method in the BusinessController class (that implements IUpgradeable):
public string UpgradeModule(string version)
{
EventLog.AddLog("Upgrading myModule", string.Format("Version: {0}", version), EventLogController.EventLogType.ADMIN_ALERT);
if ((version == "02.00.02") || (version == "2.0.2"))
{
RemoveModuleControl("SomeStuffIDontNeedAnyMoreKey");
RemoveModuleControl("SomeOtherStuffIDontNeedAnyMoreKey");
}
return string.Format("Upgrading to version {0}", version);
}
private void RemoveModuleControl(string controlKey)
{
try
{
DesktopModuleInfo dmi = DesktopModuleController.GetDesktopModuleByModuleName("myModule", Null.NullInteger);
ModuleDefinitionInfo mdi = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(dmi.FriendlyName, dmi.DesktopModuleID);
ModuleControlInfo mci = ModuleControlController.GetModuleControlByControlKey(controlKey, mdi.ModuleDefID);
ModuleControlController.DeleteModuleControl(mci.ModuleControlID);
EventLog.AddLog("Upgrading myModule", string.Format("Module Control removed: {0}", controlKey), EventLogController.EventLogType.ADMIN_ALERT);
}
catch (Exception ex)
{
Exceptions.LogException(ex);
}
}
As it is easy to see: The new module version is 2.0.2.
As I did not change the database structure, there is no 02.00.02.SqlDataProvider file - I tried to force the call by adding this to the manifest (anyway it should be called once at the end of the process, or after the restart to be more precise):
<component type="Module">
<desktopModule>
<moduleName>myModule</moduleName>
[...]
<businessControllerClass>[...]</businessControllerClass>
<supportedFeatures>
<supportedFeature type="Searchable" />
<supportedFeature type="Upgradeable" />
</supportedFeatures>
<moduleDefinitions>
<moduleDefinition>
[...]
</moduleDefinition>
</moduleDefinitions>
<eventMessage>
<processorType>DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke</processorType>
<processorCommand>UpgradeModule</processorCommand>
<attributes>
<businessControllerClass>[...]</businessControllerClass>
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
<upgradeVersionsList>01.00.00,02.00.00,02.00.02</upgradeVersionsList>
</attributes>
</eventMessage>
[...]
When installing the upgrade, everything works fine, but this code never seems to get executed. I cannot even see the entries that should be created by the code in the event log.
Any ideas what I have forgotten?
Happy DNNing!
Michael