-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPutSequenceJobIntoFailureActionContainer.ps1
46 lines (35 loc) · 1.64 KB
/
PutSequenceJobIntoFailureActionContainer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Update the Path for the DLL! (This is a custom installation path)
Add-Type -Path "C:\Program Files\MVPSI\Modules\JAMS\JAMSSequenceShr.dll"
$seq = get-item JAMS::localhost\IIB\Seq-IIB_P_DOM_PKMS_ASNTYPEI_HOURLY_BXS
$termJobs = $seq.SourceElements | Where-Object { ( $_.ElementName -in @("UNX_P_DOM_PKMS_ASNTYPEI_BL_HOURLY", "UNX_P_DOM_PKMS_ASNTYPEI_RD_HOURLY", "UNX_P_DOM_PKMS_ASNTYPEI_JK_HOURLY") ) }
Foreach($jobTask in $termJobs) {
$jobTask.ElementName
# Get Curent Parent
$curParent = $seq.SourceElements | Where-Object { ( $_.ElementUid -eq $jobTask.ParentTaskID ) }
[int]$InsertIndex=$seq.SourceElements.IndexOf($jobTask)
#$InsertIndex
$newContainer = New-Object -TypeName MVPSI.JAMSSequence.FailureActionTask
$newContainer.CategorySortOrder=$jobTask.CategorySortOrder
$newContainer.ElementId=$jobTask.ElementId
$newContainer.FailureAction = [MVPSI.JAMS.FailureAction]::Fail
$newContainer.SortOrder=$jobTask.SortOrder
$jobTask.ParentTaskID = $newContainer.ElementUid
$newContainer.Tasks.Add($jobTask)
if($curParent -ne $null) {
$newContainer.ParentTaskID=$curParent.ElementUid
$curParent.Tasks.Add($newContainer)
foreach($newTask in $curParent.Tasks){
if($seq.SourceElements.Contains($newTask)){
#Do nothing
}
Else{ #Add new task
$seq.SourceElements.Insert($InsertIndex, $newTask)
}
}
}
else {
$seq.SourceElements.Insert($InsertIndex, $newContainer)
}
}
#$seq.CancelEdit()
$seq.Update()