Beispiel #1
0
        public override void Execute()
        {
            List <LogEntry> logEntries = ReadLogTableTask.Read(LoadProcessKey);

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

            JSON = JsonConvert.SerializeObject(hierarchy, new JsonSerializerSettings {
                Formatting        = Formatting.Indented,
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            });
        }
Beispiel #2
0
        private 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 (ContainerTypes.Contains(entry.TaskType.ToLower()) && entry.TaskAction == "START")
                {
                    var newEntry = new LogHierarchyEntry(entry)
                    {
                        Parent = currentParent
                    };
                    currentList.Add(newEntry);
                    currentParent = newEntry;
                    currentList   = newEntry.Children;
                }
                else if (ContainerTypes.Contains(entry.TaskType.ToLower()) && entry.TaskAction == "END")
                {
                    currentParent = currentParent.Parent;
                    currentList   = currentParent.Children;
                }
                else if (entry.TaskAction == "START" || entry.TaskAction == "LOG")
                {
                    var hierarchyEntry = new LogHierarchyEntry(entry)
                    {
                        Parent = currentParent
                    };
                    currentList.Add(hierarchyEntry);
                }
            }
            return(root);
        }