Skip to content

Commit a49be37

Browse files
authored
Merge pull request #4 from solutionexchange/DOTNET-400
Add maintenance script for displaying content class templates in editing
2 parents 7c9afdc + b6ab0de commit a49be37

17 files changed

Lines changed: 426 additions & 129 deletions

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
about **SmartConsole for Web Site Management** (Release 16.0 and also 11.2).
44

5-
## v0.3.0 - 2020-01-14
5+
## v0.3.0 - 2020-02-19
66

77
### New Features
88

9-
- Added `Measure-PagePreviewPerformance.ps1` to get a list of pages in a project
9+
- Added `Measure-PagePreviewPerformance.ps1` and respective report to get a list of pages in a project
1010
and how they perform with and without cache (Be careful when using, since they
1111
delete the cache on the management server you configured)
12+
- Added `Get-AllContentClassesInEditing.ps1` and respective report to get a list of content classes
13+
which templates are being edited right now based on variant, time locked and locked by
14+
- Added `Get-AllContentClassesWithNElements.ps1` and respective report to
15+
get all content classes which surpass a given element count threshold
16+
- Added `Find-MSPages.ps1` to search for pages. Currently only supports Keywords
1217
- Added `Send-MaintenanceReport` which accepts a `ReportData` parameter to
1318
convert data to HTML and sent it to the recipients passed as argument. You can add
1419
custom templates to `Reports/Templates/$ReportName` folder which get merged with the
15-
base template
20+
base template. Check `mail.config.json.sample` for mail settings
1621
- Changed versioning to semantic versioning
1722

1823
### Overview
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Function Find-MSPages {
2+
<#
3+
.SYNOPSIS
4+
Find pages
5+
.DESCRIPTION
6+
Use this CMDlet to find all pages for specific criteria
7+
#>
8+
[Alias('Find-CMSPages')]
9+
[CmdletBinding(DefaultParameterSetName = 'byMSSession')]
10+
param(
11+
[Parameter(
12+
Position = 0,
13+
Mandatory = $false,
14+
ParameterSetName = 'byMSSession'
15+
)]
16+
[array] $CategorySearchConfiguration = $null
17+
)
18+
begin {
19+
Write-Debug -Message ("[ Enter => function {0} ]" -f $MyInvocation.MyCommand);
20+
}
21+
process {
22+
Write-Debug -Message ("[ Process => function {0} ]" -f $MyInvocation.MyCommand);
23+
Set-MSTimestamp;
24+
25+
$CategorySearchConfigurationString = ""
26+
27+
if ($null -ne $CategorySearchConfiguration)
28+
{
29+
foreach ($Configuration in $CategorySearchConfiguration)
30+
{
31+
$CategorySearchConfigurationString = ("<SEARCHITEM key='keyword' value='{0}' operator='{1}' />" -f $Configuration.CategoryGuid, $Configuration.Operator)
32+
}
33+
}
34+
35+
$Request = (
36+
"<IODATA loginguid='[!guid_login!]' sessionkey='[!key!]'>
37+
<PAGE action='xsearch'>
38+
<SEARCHITEMS>
39+
{0}
40+
</SEARCHITEMS>
41+
</PAGE>
42+
</IODATA>"
43+
) -f $CategorySearchConfigurationString;
44+
45+
$Request = Import-MSSessionProperties -Request ($Request);
46+
[xml]$Response = Invoke-MSRQLRequest -Request ($Request);
47+
48+
$Result = $Response.SelectNodes("IODATA/PAGES/PAGE");
49+
50+
Show-MSSessionWebServiceDebug;
51+
return $Result
52+
}
53+
end {
54+
Write-Debug -Message ("[ Leave => function {0} ]" -f $MyInvocation.MyCommand);
55+
}
56+
}

Public/Content-Pages-Elements/Get-MSPages.ps1

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
function Get-AllContentClassesInEditing
2+
{
3+
<#
4+
.SYNOPSIS
5+
Retrieves all content classes which are currently being edited
6+
.DESCRIPTION
7+
With this CMDlet you can get a report about which content classes are being edited and since when
8+
#>
9+
[CmdletBinding(DefaultParameterSetName = 'byMSSession')]
10+
param(
11+
[Parameter(
12+
Position = 0,
13+
Mandatory = $false,
14+
ParameterSetName = 'byMSSession'
15+
)]
16+
[string] $ContentClassFolderGUID
17+
)
18+
begin {
19+
Write-Debug -Message ("[ Enter => function {0} ]" -f $MyInvocation.MyCommand);
20+
21+
Register-MSConfigStore;
22+
23+
Set-MSConfigDebugMode -Value ($false); # $true oder $false
24+
25+
Register-MSSession -UseDefaults ($true);
26+
Select-MSSession -UseDefaults ($true);
27+
Enter-MSSession -UseDefaults ($true);
28+
29+
Enter-MSProject -ProjectGUID (Get-MSSessionProperty -Name ("ProjectGUID")) | Out-Null;
30+
}
31+
process {
32+
Write-Debug -Message ("[ Process => function {0} ]" -f $MyInvocation.MyCommand);
33+
34+
$AllContentClassesOfFolder = (Get-MSContentClasses -ContentClassFolderGUID ($ContentClassFolder.guid)).SelectNodes("IODATA/TEMPLATES/TEMPLATE");
35+
36+
$Result = @()
37+
foreach ($ContentClass in $AllContentClassesOfFolder) {
38+
$ContentClassProperties = Get-MSContentClassAllProperties -ContentClassGUID $ContentClass.guid
39+
$TemplateVariants = $ContentClassProperties.SelectNodes("IODATA/TEMPLATE/TEMPLATEVARIANTS")
40+
foreach ($TemplateVariant in $TemplateVariants)
41+
{
42+
if ($TemplateVariant.lock -eq "1")
43+
{
44+
foreach ($TemplateVariantAtom in $TemplateVariants.SelectNodes("TEMPLATEVARIANT"))
45+
{
46+
if ($TemplateVariantAtom.draft -eq "1")
47+
{
48+
# Using ordered so we can assure this is the correct order of attributes
49+
$ResultObject = [pscustomobject][ordered]@{
50+
ContentClassName = $ContentClass.name
51+
TemplateVariant = $TemplateVariantAtom.name
52+
Guid = $TemplateVariantAtom.guid
53+
Lockdate = $TemplateVariantAtom.changeddate | ConvertFrom-OADate
54+
Lockuser = $TemplateVariantAtom.changedusername
55+
}
56+
57+
$Result += $ResultObject
58+
}
59+
}
60+
}
61+
}
62+
}
63+
64+
return $Result
65+
}
66+
end {
67+
Write-Debug -Message ("[ Leave => function {0} ]" -f $MyInvocation.MyCommand);
68+
69+
Exit-MSSession -UseDefaults ($true);
70+
Unregister-MSSession -UseDefaults ($true);
71+
72+
Unregister-MSConfigStore;
73+
}
74+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
function Get-AllContentClassesWithNElements
2+
{
3+
<#
4+
.SYNOPSIS
5+
Retrieves all content classes which have more than a specific number of elements
6+
.DESCRIPTION
7+
Retrieves all content classes which have more than a specific number of elements
8+
#>
9+
[CmdletBinding(DefaultParameterSetName = 'byMSSession')]
10+
param(
11+
[Parameter(
12+
Position = 0,
13+
Mandatory = $false,
14+
ParameterSetName = 'byMSSession'
15+
)]
16+
[int] $ElementThreshold = 25
17+
)
18+
begin {
19+
Write-Debug -Message ("[ Enter => function {0} ]" -f $MyInvocation.MyCommand);
20+
21+
Register-MSConfigStore;
22+
23+
Set-MSConfigDebugMode -Value ($false); # $true oder $false
24+
25+
Register-MSSession -UseDefaults ($true);
26+
Select-MSSession -UseDefaults ($true);
27+
Enter-MSSession -UseDefaults ($true);
28+
29+
Enter-MSProject -ProjectGUID (Get-MSSessionProperty -Name ("ProjectGUID")) | Out-Null;
30+
}
31+
process {
32+
Write-Debug -Message ("[ Process => function {0} ]" -f $MyInvocation.MyCommand);
33+
34+
$AllContentClassesOfFolder = (Get-MsContentClasses -ContentClassFolderGUID ($ContentClassFolder.guid)).SelectNodes("IODATA/TEMPLATES/TEMPLATE");
35+
36+
$Result = @()
37+
foreach ($ContentClass in $AllContentClassesOfFolder) {
38+
$ContentClassProperties = Get-MSContentClassAllProperties -ContentClassGUID $ContentClass.guid
39+
$Elements = $ContentClassProperties.SelectNodes("IODATA/TEMPLATE/ELEMENTS/ELEMENT")
40+
41+
if ($Elements.Count -lt $ElementThreshold)
42+
{
43+
continue;
44+
}
45+
46+
$ContentClassData = [pscustomobject][ordered]@{
47+
ContentClassName = $ContentClass.name
48+
ContentClassGuid = $ContentClass.guid
49+
ElementCount = $Elements.Count
50+
}
51+
52+
$Result += $ContentClassData
53+
}
54+
55+
return $Result
56+
}
57+
end {
58+
Write-Debug -Message ("[ Leave => function {0} ]" -f $MyInvocation.MyCommand);
59+
60+
Exit-MSSession -UseDefaults ($true);
61+
Unregister-MSSession -UseDefaults ($true);
62+
63+
Unregister-MSConfigStore;
64+
}
65+
}

Scripts/Maintenance/Measure-PagePreviewPerformance.ps1

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
Mandatory = $true,
1414
ParameterSetName = 'byMSSession'
1515
)]
16-
[string] $ProjectGUID,
17-
[Parameter(
18-
Position = 1,
19-
Mandatory = $true,
20-
ParameterSetName = 'byMSSession'
21-
)]
2216
[string[]] $Tags
2317
)
2418
begin {
@@ -32,32 +26,40 @@
3226
Select-MSSession -UseDefaults ($true);
3327
Enter-MSSession -UseDefaults ($true);
3428

35-
Enter-MSProject -ProjectGUID ($ProjectGUID) | Out-Null;
29+
Enter-MSProject -ProjectGUID (Get-MSSessionProperty -Name ("ProjectGUID")) | Out-Null;
3630
}
3731
process {
3832
Write-Debug -Message ("[ Process => function {0} ]" -f $MyInvocation.MyCommand);
3933

40-
$ProjectPages = Get-MSPages -Tags $Tags
34+
$CategorySearchConfiguration = @()
35+
foreach ($Tag in $Tags)
36+
{
37+
$CategorySearchConfiguration += [pscustomobject][ordered] @{
38+
CategoryGuid = $Tag
39+
Operator = "eq"
40+
}
41+
}
42+
43+
$ProjectPages = Find-MSPages -CategorySearchConfiguration $CategorySearchConfiguration
4144
$PerformanceResults = @()
4245

4346
foreach ($ProjectPage in $ProjectPages) {
44-
$PerformanceResult = New-Object -TypeName PSObject
45-
Add-Member -InputObject $PerformanceResult -MemberType NoteProperty -Name Id -Value $ProjectPage.id
46-
Add-Member -InputObject $PerformanceResult -MemberType NoteProperty -Name Guid -Value $ProjectPage.GUID
47-
Add-Member -InputObject $PerformanceResult -MemberType NoteProperty -Name Headline -Value $ProjectPage.headline
48-
49-
Remove-MSPageCache -PageGuids ($PerformanceResult.Guid) | Out-Null
50-
51-
$PreviewTime = (Measure-Command {Get-MSPagePreview -PageGUID $ProjectPage.GUID})
52-
$PreviewTimeCached = (Measure-Command {Get-MSPagePreview -PageGUID $ProjectPage.GUID})
47+
Remove-MSPageCache -PageGuids ($ProjectPage.guid) | Out-Null
48+
$PreviewTime = (Measure-Command {Get-MSPagePreview -PageGUID $ProjectPage.guid})
49+
$PreviewTimeCached = (Measure-Command {Get-MSPagePreview -PageGUID $ProjectPage.guid})
5350

54-
Add-Member -InputObject $PerformanceResult -MemberType NoteProperty -Name Time -Value "$($PreviewTime.Seconds).$($PreviewTime.MilliSeconds)"
55-
Add-Member -InputObject $PerformanceResult -MemberType NoteProperty -Name TimeCached -Value "$($PreviewTimeCached.Seconds).$($PreviewTimeCached.MilliSeconds)"
51+
$PerformanceResult = [pscustomobject][ordered]@{
52+
Id = $ProjectPage.id;
53+
Guid = $ProjectPage.guid;
54+
Headline = $ProjectPage.headline;
55+
Time = "$($PreviewTime.Seconds).$($PreviewTime.MilliSeconds)";
56+
TimeCached = "$($PreviewTimeCached.Seconds).$($PreviewTimeCached.MilliSeconds)";
57+
}
5658

5759
$PerformanceResults += $PerformanceResult
5860
}
5961

60-
return $PerformanceResults.GetEnumerator() | Sort-Object -Property TimeCached -Descending
62+
return $PerformanceResults
6163
}
6264
end {
6365
Write-Debug -Message ("[ Leave => function {0} ]" -f $MyInvocation.MyCommand);

0 commit comments

Comments
 (0)