diff --git a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.Tests.ps1 b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.Tests.ps1 index 1817345f..8e353ee4 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.Tests.ps1 +++ b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.Tests.ps1 @@ -112,13 +112,15 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { BeforeAll { $requestedMetadata = Set-IshRequestedMetadataField -IshSession $ishSession -Level Task -Name INPUTDATAID } - It "Pipeline IshObject with LogicalId IshObjectsWithLngRef" { + It "Pipeline IshObject with InputDataTemplate IshObjectsWithLngRef" { if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) { # Get-IshBackgroundTask is called to get the system field 'INPUTDATAID' - $backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectsWithLngRef | + $backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType $ishEventTypeToPurge -InputDataTemplate IshObjectsWithLngRef | Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata + $backgroundTask.INPUTDATAID -ge 0 | Should -Be $true - $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) + # inputData looks like ... + $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) $xml = [xml]$inputData $cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section' $rawCdataContent = $cdataNode @@ -126,6 +128,7 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { $ishObjectsFromInputData = [xml]$decodedContent $ishObjectsFromInputData.ishObjects -ne $null | Should -Be $true + $ishObjectsFromInputData.ishobjects.ChildNodes.Count | Should -Be $ishObjects.LngRef.Count # all language cards are passed $ishObjectsFromInputData.ishObjects.ishObject.Count -ge 0 | Should -Be $true $ishObjectsFromInputData.ishObjects.ishObject[0].ishtype -ne $null | Should -Be $true $ishObjectsFromInputData.ishObjects.ishObject[0].ishref -ne $null | Should -Be $true @@ -134,36 +137,39 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { $ishObjectsFromInputData.ishObjects.ishObject[0].ishlngref -ne $null | Should -Be $true } } - - It "Pipeline IshObject with LogicalId IshObjectWithLngRef" { + It "Pipeline IshObject with InputDataTemplate IshObjectWithLngRef" { if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) { # Get-IshBackgroundTask is called to get the system field 'INPUTDATAID' - $backgroundTask = Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectWithLngRef -IshObject $ishObjectTopic1_1 | + $backgroundTask = Add-IshBackgroundTask -IshSession $ishSession -EventType $ishEventTypeToPurge -InputDataTemplate IshObjectWithLngRef -IshObject $ishObjectTopic1_1 | Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata + $backgroundTask.INPUTDATAID -ge 0 | Should -Be $true - $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) + # inputData looks like or + $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) $xml = [xml]$inputData $cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section' $rawCdataContent = $cdataNode $decodedContent = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($rawCdataContent)) $ishObjectFromInputData = [xml]$decodedContent - $ishObjectFromInputData.ishObject -ne $null | Should -Be $true - $ishObjectFromInputData.ishObject.ishtype -ne $null | Should -Be $true - $ishObjectFromInputData.ishObject.ishref -ne $null | Should -Be $true + $ishObjectsFromInputData.ChildNodes.Count | Should -Be 1 # first-and-only IshObject will be passed + $ishObjectFromInputData.ishObject -ne $null | Should -Be $true + $ishObjectFromInputData.ishObject.ishtype | Should -Be "ISHModule" + $ishObjectFromInputData.ishObject.ishref | Should -Be "ISHREMOTE-LOGICALID-TOPIC-FORADDBT1" $ishObjectFromInputData.ishObject.ishlogicalref -ne $null | Should -Be $true $ishObjectFromInputData.ishObject.ishversionref -ne $null | Should -Be $true $ishObjectFromInputData.ishObject.ishlngref -ne $null | Should -Be $true } } - - It "Pipeline IshObject with LogicalId IshObjectsWithIshRef" { + It "Pipeline IshObject with InputDataTemplate IshObjectsWithIshRef" { if(([Version]$ishSession.ServerVersion).Major -ge 15 -or (([Version]$ishSession.ServerVersion).Major -ge 14 -and ([Version]$ishSession.ServerVersion).Revision -ge 4)) { # Get-IshBackgroundTask is called to get the system field 'INPUTDATAID' - $backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType "TESTBACKGROUNDTASK" -InputDataTemplate IshObjectsWithIshRef | + $backgroundTask = $ishObjects | Add-IshBackgroundTask -IshSession $ishSession -EventType $ishEventTypeToPurge -InputDataTemplate IshObjectsWithIshRef | Get-IshBackgroundTask -IshSession $ishSession -RequestedMetadata $requestedMetadata + $backgroundTask.INPUTDATAID -ge 0 | Should -Be $true - $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) + # inputData looks like ... + $inputData = $ishSession.BackgroundTask25.RetrieveDataObjectByIshDataRefs($backgroundTask.INPUTDATAID) $xml = [xml]$inputData $cdataNode = $xml.ishbackgroundtaskdataobjects.ishbackgroundtaskdataobject.'#cdata-section' $rawCdataContent = $cdataNode @@ -171,6 +177,7 @@ Describe "Add-IshBackgroundTask" -Tags "Create" { $ishObjectsFromInputData = [xml]$decodedContent $ishObjectsFromInputData.ishObjects -ne $null | Should -Be $true + $ishObjectsFromInputData.ishobjects.ChildNodes.Count | Should -Be ($ishObjects.IshRef | Select-Object -Unique).Count # all unique LogicalIds are passed $ishObjectsFromInputData.ishObjects.ishObject.Count -ge 0 | Should -Be $true $ishObjectsFromInputData.ishObjects.ishObject[0].ishtype -ne $null | Should -Be $true $ishObjectsFromInputData.ishObjects.ishObject[0].ishref -ne $null | Should -Be $true diff --git a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.cs b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.cs index b92dbf5a..d8c071ee 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.cs +++ b/Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/BackgroundTask/AddIshBackgroundTask.cs @@ -157,20 +157,9 @@ protected override void BeginProcessing() if (IshSession == null) { throw new ArgumentException(ISHRemoteSessionStateIshSessionException); } WriteDebug($"Using IshSession[{IshSession.Name}] from SessionState.{ISHRemoteSessionStateIshSession}"); - switch (ParameterSetName) + if ((IshSession.ServerIshVersion.MajorVersion < 13) || ((IshSession.ServerIshVersion.MajorVersion == 13) && (IshSession.ServerIshVersion.RevisionVersion < 2))) { - case "ParameterGroup": - if ((IshSession.ServerIshVersion.MajorVersion < 13) || ((IshSession.ServerIshVersion.MajorVersion == 13) && (IshSession.ServerIshVersion.RevisionVersion < 2))) - { - throw new PlatformNotSupportedException($"Add-IshBackgroundTask with the current parameter set requires server-side BackgroundTask API which is only available starting from 13SP2/13.0.2 and up. ServerIshVersion[{IshSession.ServerVersion}]"); - } - break; - case "IshObjectsGroup": - if ((IshSession.ServerIshVersion.MajorVersion < 14) || ((IshSession.ServerIshVersion.MajorVersion == 14) && (IshSession.ServerIshVersion.RevisionVersion < 4))) - { - throw new PlatformNotSupportedException($"Add-IshBackgroundTask with the current parameter set requires server-side DocumentObj API which is only available starting from 14SP4/14.0.4 and up. ServerIshVersion[{IshSession.ServerVersion}]"); - } - break; + throw new PlatformNotSupportedException($"Add-IshBackgroundTask with the current parameter set requires server-side BackgroundTask API which is only available starting from 13SP2/13.0.2 and up. ServerIshVersion[{IshSession.ServerVersion}]"); } base.BeginProcessing(); } @@ -290,7 +279,7 @@ protected override void EndProcessing() if (EventDescription.IsNullOrEmpty()) { - EventDescription = $"Executing {EventType} for {ishObjectsCount} ishObjects"; + EventDescription = $"Executing {EventType} for {ishObjectsCount} IShObjects"; } // Start event diff --git a/Source/ISHRemote/Trisoft.ISHRemote/Objects/Public/IshBackgroundTask.cs b/Source/ISHRemote/Trisoft.ISHRemote/Objects/Public/IshBackgroundTask.cs index 5c8f1957..fc65d811 100644 --- a/Source/ISHRemote/Trisoft.ISHRemote/Objects/Public/IshBackgroundTask.cs +++ b/Source/ISHRemote/Trisoft.ISHRemote/Objects/Public/IshBackgroundTask.cs @@ -123,7 +123,7 @@ public string TaskRef /// public string HistoryRef { - get { return _backgroundTaskRef[Enumerations.ReferenceType.BackgroundTaskHistory]; } + get { return (_backgroundTaskRef.ContainsKey(Enumerations.ReferenceType.BackgroundTaskHistory)) ? _backgroundTaskRef[Enumerations.ReferenceType.BackgroundTaskHistory] : string.Empty; } } } }