-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0e3ae
commit 8f1da23
Showing
15 changed files
with
178 additions
and
15 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
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
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,85 @@ | ||
using KenticoInspector.Actions.StagingServerSummary.Models; | ||
using KenticoInspector.Core; | ||
using KenticoInspector.Core.Constants; | ||
using KenticoInspector.Core.Helpers; | ||
using KenticoInspector.Core.Models; | ||
using KenticoInspector.Core.Services.Interfaces; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace KenticoInspector.Actions.StagingServerSummary | ||
{ | ||
public class Action : AbstractAction<Terms, Options> | ||
{ | ||
private readonly IDatabaseService databaseService; | ||
|
||
public override IList<Version> CompatibleVersions => VersionHelper.GetVersionList("12", "13"); | ||
|
||
public override IList<string> Tags => new List<string> { | ||
ModuleTags.Configuration, | ||
ModuleTags.Staging | ||
}; | ||
|
||
public Action(IDatabaseService databaseService, IModuleMetadataService moduleMetadataService) : base(moduleMetadataService) | ||
{ | ||
this.databaseService = databaseService; | ||
} | ||
|
||
public override ActionResults Execute(Options options) | ||
{ | ||
databaseService.ExecuteSqlFromFileGeneric(Scripts.DisableServer, new { ServerID = options.ServerId }); | ||
var result = ExecuteListing(); | ||
result.Status = ResultsStatus.Good; | ||
result.Summary = Metadata.Terms.ServerDisabled.With(new | ||
{ | ||
serverId = options.ServerId | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
public override ActionResults ExecutePartial(Options options) | ||
{ | ||
// All options are required for this action | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override ActionResults ExecuteListing() | ||
{ | ||
var servers = databaseService.ExecuteSqlFromFile<StagingServer>(Scripts.GetStagingServerSummary); | ||
var data = new TableResult<StagingServer>() | ||
{ | ||
Name = Metadata.Terms.TableTitle, | ||
Rows = servers | ||
}; | ||
|
||
return new ActionResults | ||
{ | ||
Type = ResultsType.Table, | ||
Status = ResultsStatus.Information, | ||
Summary = Metadata.Terms.ListSummary, | ||
Data = data | ||
}; | ||
} | ||
|
||
public override ActionResults GetInvalidOptionsResult() | ||
{ | ||
var result = ExecuteListing(); | ||
result.Status = ResultsStatus.Error; | ||
result.Summary = Metadata.Terms.InvalidOptions; | ||
|
||
return result; | ||
} | ||
|
||
public override bool ValidateOptions(Options options) | ||
{ | ||
var servers = databaseService.ExecuteSqlFromFile<StagingServer>(Scripts.GetStagingServerSummary); | ||
|
||
return options.ServerId > 0 && | ||
servers.Any(s => s.ID == options.ServerId) && | ||
servers.FirstOrDefault(s => s.ID == options.ServerId).Enabled; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
KenticoInspector.Actions/StagingServerSummary/Metadata/en-US.yaml
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,12 @@ | ||
details: | ||
name: Content Staging Server Summary | ||
shortDescription: Review and disable staging servers. | ||
longDescription: | | ||
Displays all staging servers, and allows you to disable them. | ||
Run the action without options to view the staging servers. To disable a server, re-run the action with the server ID below. Servers disabled by this action have the *.disabled* prefix applied to their name, so you can identify which servers were disabled by this action and which were disabled manually. | ||
terms: | ||
tableTitle: Content staging servers | ||
invalidOptions: Invalid server ID provided. Ensure that the server ID is listed in the results below, and the server is enabled. | ||
listSummary: Set the server ID you wish to disable and re-run | ||
serverDisabled: Server ID <serverId> was disabled |
7 changes: 7 additions & 0 deletions
7
KenticoInspector.Actions/StagingServerSummary/Models/Options.cs
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,7 @@ | ||
namespace KenticoInspector.Actions.StagingServerSummary.Models | ||
{ | ||
public class Options | ||
{ | ||
public int? ServerId { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
KenticoInspector.Actions/StagingServerSummary/Models/Results/StagingServer.cs
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,15 @@ | ||
namespace KenticoInspector.Actions.StagingServerSummary.Models | ||
{ | ||
public class StagingServer | ||
{ | ||
public int ID { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string Site { get; set; } | ||
|
||
public string Url { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
KenticoInspector.Actions/StagingServerSummary/Models/Terms.cs
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,15 @@ | ||
using KenticoInspector.Core.Models; | ||
|
||
namespace KenticoInspector.Actions.StagingServerSummary.Models | ||
{ | ||
public class Terms | ||
{ | ||
public Term InvalidOptions { get; internal set; } | ||
|
||
public Term TableTitle { get; internal set; } | ||
|
||
public Term ListSummary { get; internal set; } | ||
|
||
public Term ServerDisabled { get; internal 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,11 @@ | ||
namespace KenticoInspector.Actions.StagingServerSummary | ||
{ | ||
public static class Scripts | ||
{ | ||
public static string BaseDirectory => $"{nameof(StagingServerSummary)}/Scripts"; | ||
|
||
public static string GetStagingServerSummary => $"{BaseDirectory}/{nameof(GetStagingServerSummary)}.sql"; | ||
|
||
public static string DisableServer => $"{BaseDirectory}/{nameof(DisableServer)}.sql"; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
KenticoInspector.Actions/StagingServerSummary/Scripts/DisableServer.sql
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,2 @@ | ||
UPDATE Staging_Server SET ServerDisplayName = ServerDisplayName + N'.disabled', ServerEnabled = 0 | ||
WHERE ServerID = @ServerID |
3 changes: 3 additions & 0 deletions
3
KenticoInspector.Actions/StagingServerSummary/Scripts/GetStagingServerSummary.sql
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,3 @@ | ||
SELECT C.ServerID AS 'ID', C.ServerDisplayName AS 'Name', C.ServerEnabled AS 'Enabled', C.ServerURL AS 'Url', S.SiteDisplayName AS 'Site' | ||
FROM Staging_Server AS C | ||
JOIN CMS_Site AS S ON S.SiteID = C.ServerSiteID |
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
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