public void Execute()
        {
            List <LogEntry> logEntries = ReadLogTableTask.Read(this.ConnectionManager, LoadProcessKey);

            CalculateEndDate(logEntries);
            LogHierarchyEntry hierarchy = CreateHierarchyStructure(logEntries);

            JSON = JsonConvert.SerializeObject(hierarchy, new JsonSerializerSettings
            {
                Formatting        = Formatting.Indented,
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            });
        }
Exemple #2
0
        private static LogHierarchyEntry CreateHierarchyStructure(List <LogEntry> entries)
        {
            LogHierarchyEntry root = new LogHierarchyEntry(new LogEntry()
            {
                TaskType = "ROOT"
            });
            var currentParent = root;
            var currentList   = root.Children;

            foreach (LogEntry entry in entries)
            {
                if (ContainerTypeNames.Contains(entry.TaskType) && entry.Action == "START")
                {
                    var newEntry = new LogHierarchyEntry(entry)
                    {
                        Parent = currentParent
                    };
                    currentList.Add(newEntry);
                    currentParent = newEntry;
                    currentList   = newEntry.Children;
                }
                else if (ContainerTypeNames.Contains(entry.TaskType) && entry.Action == "END")
                {
                    currentParent = currentParent.Parent;
                    currentList   = currentParent.Children;
                }
                else if (entry.Action != "END")
                {
                    var hierarchyEntry = new LogHierarchyEntry(entry)
                    {
                        Parent = currentParent
                    };
                    currentList.Add(hierarchyEntry);
                }
            }
            return(root);
        }