Skip to content

Commit

Permalink
Merge pull request #34 from stefanstranger/issue26-2
Browse files Browse the repository at this point in the history
Issue26 2
  • Loading branch information
stefanstranger committed Apr 2, 2024
2 parents c227017 + eb4ea10 commit bb534de
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ And finally some great PowerShell community members for their feedback and sugge

## Change Log

v1.1.4 - 2024-04-02
* Bug fixes
* [Fix for issue Length cannot be less than zero.](https://github.com/stefanstranger/logicappdocs/issues/26)

v1.1.3 - 2024-03-29
* Bug fixes:
* [Fix for actions that don't have a runafter property](https://github.com/stefanstranger/logicappdocs/issues/31)
Expand Down
76 changes: 68 additions & 8 deletions src/Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Function Sort-Action {
else {
# Search for actions that have the previous action's ActionName in the RunAfter property
# If there are multiple actions with the same RunAfter property, set the RunAfter property to the Parent property
# Why does this logic changes the RunAfter property to the Parent property for the action getCompany Try? It should be getSecrets.
# This is caused by the action get-atApiIntegrationCode that does not have an runafter property. This is la
if (($Actions | Where-Object { $_.RunAfter -eq $($currentAction.ActionName) } | Measure-Object).count -gt 1) {
$Actions | Where-Object { $_.RunAfter -eq $($currentAction.ActionName) } | ForEach-Object {
# Check if the action has a Parent Value
Expand Down Expand Up @@ -184,7 +186,7 @@ Function Sort-Action {
# Increment the indexNumber
$indexNumber++
}
# Current error is that there can be an newly created action that does not have a paret property.???
# Current error is that there can be an newly created action that does not have a parent property.???
elseif (($null -ne $currentAction.Parent) -and ($Actions | Where-Object { $_.RunAfter -eq $(('{0}-False') -f $(($currentAction.Parent).Substring(0, ($currentAction.Parent).length - 5))) } )) {
$Actions | Where-Object { $_.RunAfter -eq $(('{0}-False') -f $(($currentAction.Parent).Substring(0, ($currentAction.Parent).length - 5))) } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
Expand All @@ -206,14 +208,72 @@ Function Sort-Action {
$indexNumber++
}
else {
# When an action runs after a condition find orderid of last condition actionname
# When an action runs after a condition find orderid of last condition actionname.
# Fix issue when an async response is never used as a runafter property. Then use action that has same RunAfter propery as the current action.
if ($Actions | Where-Object { !($_ | Get-Member -MemberType NoteProperty 'Order') -and (![string]::IsNullOrEmpty($_.Parent)) }) {
$Actions | Where-Object { !($_ | Get-Member -MemberType NoteProperty 'Order') -and (![string]::IsNullOrEmpty($_.Parent)) } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
# Check there is only one action, if not then use action that has same RunAfter propery as the current action.
if (($Actions | Where-Object { !($_ | Get-Member -MemberType NoteProperty 'Order') -and (![string]::IsNullOrEmpty($_.Parent)) }).count -eq 1) {
$Actions | Where-Object { !($_ | Get-Member -MemberType NoteProperty 'Order') -and (![string]::IsNullOrEmpty($_.Parent)) } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
}
elseif ($Actions | Where-Object { $_.RunAfter -eq $($currentAction.RunAfter) -and $_.ActionName -ne $currentAction.ActionName } ) {
$Actions | Where-Object { $_.RunAfter -eq $($currentAction.RunAfter) -and $_.ActionName -ne $currentAction.ActionName } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
}
# Move up one parent level and check if there is an action that has the same RunAfter property as the current action.
else {
# Get curentAction parent's parent. #Find Action with RunAfter value getSecrets
# Why does the action getCompany Try as a RunAfter property? It should be getSecrets.
# Steps when currentaction is not used as runafter property for any actions.
# 1. Get parent of currentAction Name (getSecrets)
# 2. Check for action with runafter of parent of currentaction. (does not exists)
# 3. Get grandparent of currentaction's parent (try)
# 4. If not found check for Action with no order property and runafter and and parent having value of grandparent.
# $parentCurrentAction = $currentAction.Parent
if (!($Actions | Where-Object { $_.RunAfter -eq $currentAction.Parent -and !$($_ | get-member -Name 'Order') })) {
# Handle parent being True of false in name. Remove -True or -False from parent name.
$currentparent = $($currentAction.Parent).Replace("-True", "").Replace("-False", "")
$grandparent = ($Actions | Where-Object { $_.ActionName -eq $currentparent }).Parent
if ($Actions | Where-Object { $_.RunAfter -eq $grandparent -and $_.Parent -eq $grandparent -and !$($_ | get-member -Name 'Order') }) {
$Actions | Where-Object { $_.RunAfter -eq $grandparent -and $_.Parent -eq $grandparent -and !$($_ | get-member -Name 'Order') } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
}
else {
# Get overgrandparent of currentaction's parent.
if (($Actions | Where-Object { $_.ActionName -eq $grandparent }).Parent) {
$overgrandparent = ($Actions | Where-Object { $_.ActionName -eq $grandparent }).Parent
$Actions | Where-Object { $_.RunAfter -eq $overgrandparent -and $_.Parent -eq $overgrandparent -and !$($_ | get-member -Name 'Order') } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
}
else {
$Actions | Where-Object { $_.RunAfter -eq $grandparent -and !$($_ | get-member -Name 'Order') } |
Add-Member -MemberType NoteProperty -Name Order -Value $indexNumber
# CurrentAction
$currentAction = ($Actions | Where-Object { ($_ | Get-Member -MemberType NoteProperty 'Order') -and ($_.Order -eq $indexNumber) })
# Increment the indexNumber
$indexNumber++
}

}

}
}
}
}
}
Expand Down

0 comments on commit bb534de

Please sign in to comment.