Skip to content

Commit

Permalink
fix: fixed installation when an older version was installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Airam Hernández Hernández committed Aug 2, 2023
1 parent 49ee1b4 commit c9532be
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 23 deletions.
50 changes: 36 additions & 14 deletions Components/FeatureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,50 @@ public string UpgradeModule(string version)
{
try
{
var task = DotNetNuke.Services.Scheduling.SchedulingController.GetSchedule().FirstOrDefault(x => x.TypeFullName == "Intelequia.Modules.DNNPulse.Tasks.PulseTask, DNNPulse");
if (task != null)
{
SchedulingController.DeleteSchedule(task.ScheduleID);
}

string fullName = "Intelequia.Modules.DNNPulse.Tasks.PulseTask, DNNPulse";
var fullName = "Intelequia.Modules.DNNPulse.Tasks.PulseTask, DNNPulse";
var startTime = DateTime.Now;
var timeLapse = 1;
var timeLapseMeasurement = "d";
var retryTimeLapse = 30;
var retryTimeLapseMeasurement = "m";
var retainHistoryNum = 0;
var attatchToEvent = "";
var catchUpEnable = false;
var enable = true;
var objectDependency = "";
var attachToEvent = "";
var catchUpEnabled = false;
var enabled = true;
var objectDependencies = "";
var servers = "";
var friendlyName = "DNN Pulse";
// Add the scheduled task
SchedulingController.AddSchedule(
fullName, timeLapse, timeLapseMeasurement, retryTimeLapse, retryTimeLapseMeasurement, retainHistoryNum, attatchToEvent, catchUpEnable, enable, objectDependency, servers, friendlyName, startTime);

var task = DotNetNuke.Services.Scheduling.SchedulingController.GetSchedule()
.FirstOrDefault(x => x.TypeFullName == fullName);

task = task ?? new ScheduleItem();

task.ScheduleStartDate = startTime;
task.TimeLapse = timeLapse;
task.TimeLapseMeasurement = timeLapseMeasurement;
task.RetryTimeLapse = retryTimeLapse;
task.RetainHistoryNum = retainHistoryNum;
task.AttachToEvent = attachToEvent;
task.CatchUpEnabled = catchUpEnabled;
task.Enabled = enabled;
task.ObjectDependencies = objectDependencies;
task.Servers = servers;
task.FriendlyName = friendlyName;

if (task.ScheduleID > 0)
{
SchedulingController.UpdateSchedule(task);
}
else
{
// Add the scheduled task
SchedulingController.AddSchedule(
fullName, timeLapse, timeLapseMeasurement, retryTimeLapse, retryTimeLapseMeasurement,
retainHistoryNum, attachToEvent, catchUpEnabled, enabled, objectDependencies, servers,
friendlyName, startTime);
}


return "Success";
}
Expand Down
3 changes: 2 additions & 1 deletion DNNPulse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,14 @@
<Folder Include="App_LocalResources\" />
</ItemGroup>
<ItemGroup>
<Content Include="Providers\DataProviders\SqlDataProvider\01.00.00.SqlDataProvider" />
<Content Include="Providers\DataProviders\SqlDataProvider\01.01.00.SqlDataProvider" />
</ItemGroup>
<ItemGroup>
<Content Include="Providers\DataProviders\SqlDataProvider\Uninstall.SqlDataProvider" />
</ItemGroup>
<ItemGroup>
<Content Include="web.config" />
<Content Include="Providers\DataProviders\SqlDataProvider\01.06.00.SqlDataProvider" />
<None Include="web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
Expand Down
15 changes: 10 additions & 5 deletions DNNPulse.dnn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="DNNPulse" type="Module" version="01.05.00">
<package name="DNNPulse" type="Module" version="01.06.00">
<friendlyName>DNNPulse</friendlyName>
<description>intelequia.com DNNPulse module</description>
<iconFile>~/Images/icon_extensions_32px.png</iconFile>
Expand Down Expand Up @@ -51,7 +51,7 @@
<attributes>
<businessControllerClass>Intelequia.Modules.DNNPulse.Components.FeatureController, DNNPulse</businessControllerClass>
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
<upgradeVersionsList>01.05.00</upgradeVersionsList>
<upgradeVersionsList>01.06.00</upgradeVersionsList>
</attributes>
</eventMessage>
</component>
Expand All @@ -61,13 +61,18 @@
<basePath>DesktopModules\dnnsimplearticle</basePath>
<script type="Install">
<path>Providers\DataProviders\SqlDataProvider</path>
<name>01.00.00.SqlDataProvider</name>
<version>01.00.00</version>
<name>01.01.00.SqlDataProvider</name>
<version>01.01.00</version>
</script>
<script type="Install">
<path>Providers\DataProviders\SqlDataProvider</path>
<name>01.06.00.SqlDataProvider</name>
<version>01.06.00</version>
</script>
<script type="UnInstall">
<path>Providers\DataProviders\SqlDataProvider</path>
<name>Uninstall.SqlDataProvider</name>
<version>01.00.00</version>
<version>01.06.00</version>
</script>
</scripts>
</component>
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("01.05.00.00")]
[assembly: AssemblyFileVersion("01.05.00.00")]
[assembly: AssemblyVersion("01.06.00.00")]
[assembly: AssemblyFileVersion("01.06.00.00")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN

DECLARE @DNNVersion TABLE
(
DNNVersion VARCHAR(50)
DNNVersion VARCHAR(100)
);

DECLARE @PortalAliases TABLE
Expand Down
93 changes: 93 additions & 0 deletions Providers/DataProviders/SqlDataProvider/01.06.00.SqlDataProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE LIKE 'PROCEDURE' AND ROUTINE_NAME LIKE 'int_GetDNNPulse')
BEGIN
    DROP PROCEDURE int_GetDNNPulse;
END
GO

CREATE PROCEDURE [dbo].[int_GetDNNPulse]
AS
BEGIN

DECLARE @DNNVersion TABLE
(
DNNVersion VARCHAR(100)
);

DECLARE @PortalAliases TABLE
(
HTTPALIAS VARCHAR(100)
);

DECLARE @ModulesVersions TABLE
(
ModuleName VARCHAR(100),
ModuleVersion VARCHAR(100)
);

DECLARE @DatabaseSize TABLE
(
Size VARCHAR(100)
);

DECLARE @DatabaseTier TABLE
(
Tier VARCHAR(100)
);
INSERT INTO @DNNVersion (DNNVersion)
SELECT TOP 1 CONCAT(major, '.' , minor, '.' ,build)
FROM Version
ORDER BY VersionId DESC;

INSERT INTO @PortalAliases (HTTPALIAS)
SELECT HTTPAlias
FROM PortalAlias
ORDER BY IsPrimary DESC, HTTPAlias;

INSERT INTO @ModulesVersions (ModuleName, ModuleVersion)
SELECT ModuleName, Version
FROM DesktopModules
ORDER BY ModuleName ASC, Version ASC;

INSERT INTO @DatabaseSize (Size)
SELECT SUM(size/128.0) AS DatabaseDataSpaceAllocatedInMB
FROM sys.database_files
GROUP BY type_desc
HAVING type_desc = 'ROWS'

BEGIN TRY
INSERT INTO @DatabaseTier (Tier)
EXEC ('SELECT service_objective FROM sys.database_service_objectives WHERE database_id = DB_ID();');
END TRY
BEGIN CATCH
INSERT INTO @DatabaseTier (Tier) VALUES ('Not Available');
END CATCH;


SELECT *
FROM (
SELECT 'DNNVersion' AS TYPE, DNNVersion AS NAME
FROM @DNNVersion

UNION ALL

SELECT 'PortalAlias' AS TYPE, HTTPALIAS AS NAME
FROM @PortalAliases

UNION ALL

SELECT 'Modules' AS TYPE, CONCAT(ModuleName, ' - ', ModuleVersion) AS NAME
FROM @ModulesVersions

UNION ALL

SELECT 'DatabaseSize' AS TYPE, Size AS NAME
FROM @DatabaseSize

UNION ALL

SELECT 'DatabaseTier' AS TYPE, Tier AS NAME
FROM @DatabaseTier
) AS DNNPulse

END
GO
6 changes: 6 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@
</p>
<p>Added new features:
- Now creates a GUID that can be used as the ID.
<br /><br /></p>
<p class="Owner">
<b>Version 1.6.0</b>
</p>
<p>Added new features:
- Fix: fixed installation when an older version was installed.
<br /><br /></p>
</div>

0 comments on commit c9532be

Please sign in to comment.