thygesteffensen / PowerAutomateMockUp

Skeleton to run Power Automate Flows from their JSON descriptions.
MIT License
7 stars 1 forks source link

Figure out how to get actionResult from #15

Closed github-actions[bot] closed 3 years ago

github-actions[bot] commented 3 years ago

Figure out how to get actionResult from

https://github.com/thygesteffensen/PowerAutomateMockUp/blob/1127c4f7acf55eaecbf30df2821fc7e4229e9c00/PowerAutomateMockUp/FlowParser/FlowRunner.cs#L92

                }

                // If an action failes inside a scope, and a suitable action isn't found inside the given scope, that 
                // actions status is transferred to be the scope status. This isn't the case atm

                // TODO: Figure out how to get actionResult from
                var actionDescName = currentAd.Name;
                var nextAction = actionResult.NextAction;
                var actionResultStatus = actionResult.ActionStatus;
                while (!DetermineNextAction(nextAction, actionResultStatus, out currentAd, actionDescName))
                {
                    nextAction = null;
                    var t = await _scopeManager.TryPopScope(actionResultStatus);
                    if (t == null)
                    {
                        currentAd = null;
                        break;
                    }

                    actionResultStatus = t.ActionStatus;
                    actionDescName = t.NextAction;
                }
            }
        }

        private bool DetermineNextAction(string nextAction, ActionStatus actionResultStatus,
            out JProperty currentActionDesc, string adName)
        {
            if (nextAction == null)
            {
                currentActionDesc = _scopeManager.CurrentActionDescriptions.FirstOrDefault(a =>
                    a.Value.SelectToken("$.runAfter").First?.ToObject<JProperty>().Name == adName &&
                    a.Value.SelectToken("$.runAfter.*").Values().Any(
                        x => x?.Value<string>() == actionResultStatus.ToString()));
            }
            else
            {
                currentActionDesc =
                    _scopeManager.CurrentActionDescriptions.First(a => a.Name == nextAction);
            }

            return currentActionDesc != null;

8e8ed17bda40c7c678dbc13b1370231c8c95a61d

github-actions[bot] commented 3 years ago

Closed in a773ff295bc115cfbccceeeafbd45b4f148d50da