Created
June 1, 2019 12:48
-
-
Save chrismckelt/a115c348284ec6261a5fe876def39702 to your computer and use it in GitHub Desktop.
logic app cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Parse logic app json and reorder logically | |
*/ | |
string Json = string.Empty; | |
IList<string> Paths = new List<string>(); | |
IDictionary<string, string> RunAfter = new Dictionary<string, string>(); | |
void Main() { | |
string file = @"C:\dev\Sodexo.Integration.iFM\ifm-apps\templates\workorders\task-maximo-createworkorder.azuredeploy.json"; | |
Json = File.ReadAllText(file); | |
var data = JObject.Parse(Json); | |
foreach (var obj in data) | |
{ | |
if (obj.Key == "resources") | |
{ | |
obj.Value.Dump(); | |
var nodes = obj.Value?.Root["resources"][0]["properties"]["definition"]["actions"].Dump(); | |
WritePath(nodes); | |
} | |
} | |
Paths.Dump("Paths"); | |
RunAfter.Dump("RunAfter"); | |
} | |
void WritePath(JToken nodes) | |
{ | |
foreach (var node in nodes) { | |
Paths.Add(node.Path); | |
foreach (var child in node.Children()) { | |
WritePath(child); | |
} | |
foreach (JProperty prop in node.Children<JObject>().Properties()) | |
{ | |
//Console.WriteLine(prop.Name); | |
if (prop.Name == "runAfter") | |
{ | |
var arr = prop.Value; | |
if (arr != null) { | |
arr.GetType().Dump(); | |
} | |
RunAfter.Add(node.Path, prop.Value.ToString()); | |
//Console.WriteLine(prop.Value); | |
} | |
} | |
} | |
} | |
public class Logic | |
{ | |
public Object[] Actions {get;set;} | |
//public Logic[] Else {get;set;} | |
//public Object[] RunAfter {get;set;} | |
} | |
public Logic Root { get; set; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment