-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from UpendoVentures/tasks/themes-used
Adds a themes-used command
- Loading branch information
Showing
13 changed files
with
402 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#region License | ||
|
||
// Distributed under the MIT License | ||
// ============================================================ | ||
// Copyright (c) Upendo Ventures, LLC | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software | ||
// and associated documentation files (the "Software"), to deal in the Software without restriction, | ||
// including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or | ||
// substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#endregion | ||
|
||
using System; | ||
using System.Linq; | ||
using Dnn.PersonaBar.Library.Helper; | ||
using Dnn.PersonaBar.Library.Prompt; | ||
using Dnn.PersonaBar.Library.Prompt.Attributes; | ||
using Dnn.PersonaBar.Library.Prompt.Models; | ||
using DotNetNuke.Application; | ||
using DotNetNuke.Common; | ||
using DotNetNuke.Common.Utilities; | ||
using DotNetNuke.Entities.Controllers; | ||
using DotNetNuke.Entities.Host; | ||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.Entities.Profile; | ||
using DotNetNuke.Entities.Users; | ||
using DotNetNuke.Instrumentation; | ||
using Upendo.Modules.UpendoPrompt.Components; | ||
using Upendo.Modules.UpendoPrompt.Data; | ||
using Upendo.Modules.UpendoPrompt.Entities; | ||
using Constants = Upendo.Modules.UpendoPrompt.Components.Constants; | ||
|
||
namespace Upendo.Modules.UpendoPrompt.Commands | ||
{ | ||
[ConsoleCommand("themes-used", Constants.PromptCategory, "PromptThemeseUsed")] | ||
public class ThemesUsed : PromptBase, IConsoleCommand | ||
{ | ||
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(ThemesUsed)); | ||
|
||
#region Implementation | ||
|
||
public override void Init(string[] args, PortalSettings portalSettings, UserInfo userInfo, int activeTabId) | ||
{ | ||
// do nothing | ||
} | ||
|
||
public override ConsoleResultModel Run() | ||
{ | ||
try | ||
{ | ||
var dbAccess = new DataAccess(); | ||
var themesUsed = dbAccess.GetThemesUsed(); | ||
var recordCount = themesUsed.Count(); | ||
|
||
var output = string.Empty; | ||
|
||
if (recordCount > 0) | ||
{ | ||
output = LocalizeString(Constants.LocalizationKeys.RECORDS_SOME); | ||
} | ||
else | ||
{ | ||
output = LocalizeString(Constants.LocalizationKeys.RECORDS_NONE); | ||
} | ||
|
||
return new ConsoleResultModel | ||
{ | ||
Records = recordCount, | ||
Data = themesUsed, | ||
IsError = false, | ||
Output = output | ||
}; | ||
} | ||
catch (Exception e) | ||
{ | ||
LogError(e); | ||
return new ConsoleErrorResultModel(string.Concat(Constants.OutputPrefix, this.LocalizeString(Constants.LocalizationKeys.ErrorOccurred))); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Helpers | ||
|
||
protected override void LogError(Exception ex) | ||
{ | ||
if (ex != null) | ||
{ | ||
Logger.Error(ex.Message, ex); | ||
if (ex.InnerException != null) | ||
{ | ||
Logger.Error(ex.InnerException.Message, ex.InnerException); | ||
} | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#region License | ||
|
||
// Distributed under the MIT License | ||
// ============================================================ | ||
// Copyright (c) Upendo Ventures, LLC | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software | ||
// and associated documentation files (the "Software"), to deal in the Software without restriction, | ||
// including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or | ||
// substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#endregion | ||
|
||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using DotNetNuke.Data; | ||
using Upendo.Modules.UpendoPrompt.Components; | ||
using Upendo.Modules.UpendoPrompt.Entities; | ||
|
||
namespace Upendo.Modules.UpendoPrompt.Data | ||
{ | ||
public class DataAccess | ||
{ | ||
public IEnumerable<ThemeItem> GetThemesUsed() | ||
{ | ||
IList<ThemeItem> themesUsed; | ||
|
||
using (IDataContext db = DataContext.Instance()) | ||
{ | ||
themesUsed = db.ExecuteQuery<ThemeItem>(CommandType.StoredProcedure, Constants.Procedures.ThemesUsed).ToList(); | ||
} | ||
|
||
return themesUsed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#region License | ||
|
||
// Distributed under the MIT License | ||
// ============================================================ | ||
// Copyright (c) Upendo Ventures, LLC | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software | ||
// and associated documentation files (the "Software"), to deal in the Software without restriction, | ||
// including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or | ||
// substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#endregion | ||
|
||
namespace Upendo.Modules.UpendoPrompt.Entities.Interfaces | ||
{ | ||
public interface IThemeItem | ||
{ | ||
string Source { get; set; } | ||
string ThemePath { get; set; } | ||
int PortalId { get; set; } | ||
int TabId { get; set; } | ||
int ModuleId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#region License | ||
|
||
// Distributed under the MIT License | ||
// ============================================================ | ||
// Copyright (c) Upendo Ventures, LLC | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software | ||
// and associated documentation files (the "Software"), to deal in the Software without restriction, | ||
// including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or | ||
// substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#endregion | ||
|
||
using System; | ||
using Upendo.Modules.UpendoPrompt.Entities.Interfaces; | ||
|
||
namespace Upendo.Modules.UpendoPrompt.Entities | ||
{ | ||
[Serializable] | ||
public class ThemeItem : IThemeItem | ||
{ | ||
public string Source { get; set; } | ||
public string ThemePath { get; set; } | ||
public int PortalId { get; set; } | ||
public int TabId { get; set; } | ||
public int ModuleId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Modules/UpendoPrompt/Providers/DataProviders/SqlDataProvider/01.03.00.SqlDataProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
|
||
INSTALL/UPGRADE SQL PROVIDER SCRIPT | ||
|
||
Prompt Extension Suite for DNN by Upendo Ventures, LLC | ||
|
||
*/ | ||
|
||
IF EXISTS (SELECT * FROM sys.objects WHERE type = N'P' AND OBJECT_ID = OBJECT_ID(N'{databaseOwner}[{objectQualifier}uvm_Prompt_GetThemesUsed]')) | ||
DROP PROCEDURE {databaseOwner}[{objectQualifier}uvm_Prompt_GetThemesUsed]; | ||
GO | ||
|
||
CREATE PROCEDURE [uvm_Prompt_GetThemesUsed] | ||
AS | ||
BEGIN | ||
CREATE TABLE #ThemesUsed ( | ||
[Source] NVARCHAR(50) NOT NULL, | ||
[ThemePath] NVARCHAR (200) NOT NULL, | ||
[PortalId] INT, | ||
[TabId] INT, | ||
[ModuleId] INT | ||
); | ||
|
||
INSERT INTO #ThemesUsed ([Source], [ThemePath], [PortalId], [TabId], [ModuleId]) | ||
SELECT N'HostSettings' AS [Source],hs.[SettingValue] AS [ThemePath],-1 AS [PortalId],-1 AS [TabId],-1 AS [ModuleId] | ||
FROM {databaseOwner}[{objectQualifier}HostSettings] hs | ||
WHERE hs.[SettingName] LIKE N'%Container' OR hs.[SettingName] LIKE N'%Skin' | ||
ORDER BY hs.[SettingValue]; | ||
|
||
INSERT INTO #ThemesUsed ([Source], [ThemePath], [PortalId], [TabId], [ModuleId]) | ||
SELECT N'PortalSettings' AS [Source],ps.[SettingValue] AS [ThemePath],ps.[PortalID],-1 AS [TabId],-1 AS [ModuleId] | ||
FROM {databaseOwner}[{objectQualifier}PortalSettings] ps | ||
WHERE ps.[SettingName] LIKE N'%Container' OR ps.[SettingName] LIKE N'%Skin' | ||
ORDER BY ps.[SettingValue]; | ||
|
||
INSERT INTO #ThemesUsed ([Source], [ThemePath], [PortalId], [TabId], [ModuleId]) | ||
SELECT N'Page' AS [Source],t.[SkinSrc] AS [ThemePath],t.[PortalID],t.[TabID],-1 AS [ModuleId] | ||
FROM {databaseOwner}[{objectQualifier}Tabs] t | ||
WHERE NOT t.[SkinSrc] IS NULL | ||
ORDER BY t.[SkinSrc]; | ||
|
||
INSERT INTO #ThemesUsed ([Source], [ThemePath], [PortalId], [TabId], [ModuleId]) | ||
SELECT N'Page' AS [Source],t.[ContainerSrc] AS [ThemePath],t.[PortalID],t.[TabID],-1 AS [ModuleId] | ||
FROM {databaseOwner}[{objectQualifier}Tabs] t | ||
WHERE NOT t.[ContainerSrc] IS NULL | ||
ORDER BY t.[ContainerSrc]; | ||
|
||
INSERT INTO #ThemesUsed ([Source], [ThemePath], [PortalId], [TabId], [ModuleId]) | ||
SELECT N'Module' AS [Source],tm.[ContainerSrc] AS [ThemePath],-1 AS [PortalId],tm.[TabID],tm.[ModuleID] | ||
FROM {databaseOwner}[{objectQualifier}TabModules] tm | ||
WHERE NOT tm.[ContainerSrc] IS NULL | ||
ORDER BY tm.[ContainerSrc]; | ||
|
||
SELECT tu.[Source], tu.[ThemePath], tu.[PortalId], tu.[TabId], tu.[ModuleId] | ||
FROM #ThemesUsed tu | ||
ORDER BY tu.[Source], tu.[ThemePath], tu.[PortalId], tu.[TabId], tu.[ModuleId]; | ||
|
||
DROP TABLE #ThemesUsed; | ||
END | ||
GO | ||
|
||
/* | ||
|
||
END OF FILE | ||
|
||
*/ |
Oops, something went wrong.