Skip to content

Instantly share code, notes, and snippets.

@chrismckelt
Created June 1, 2019 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismckelt/a115c348284ec6261a5fe876def39702 to your computer and use it in GitHub Desktop.
Save chrismckelt/a115c348284ec6261a5fe876def39702 to your computer and use it in GitHub Desktop.
logic app cleanup
/*
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