public static void ProcessServiceFunctions(this ChartDataListItem chartData, bool svcComponents, bool resolverGroups, bool svcActivities, bool opProcs, string customerName, ServiceDomain deskDomain, List <List <DotMatrixListItem> > dotMatrix) { if (deskDomain.ServiceFunctions == null) { return; } foreach (var domainFunction in deskDomain.ServiceFunctions.OrderBy(x => x.DiagramOrder).ThenBy(x => x.FunctionType.FunctionName)) { var function = new ChartDataListItem { Id = domainFunction.Id, Title = domainFunction.AlternativeName ?? domainFunction.FunctionType.FunctionName, Type = DecompositionType.Function.ToString(), CenteredTitle = string.Empty, Units = new List <ChartDataListItem>(), }; if (svcComponents) { function.ProcessServiceComponents(resolverGroups, svcActivities, opProcs, customerName, domainFunction, dotMatrix); } else if (resolverGroups) { if (domainFunction.ServiceComponents != null) { foreach (var component in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1)) { function.ProcessResolvers(svcActivities, opProcs, customerName, component, dotMatrix); } } } else if (svcActivities) { if (domainFunction.ServiceComponents != null) { foreach (var component in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1)) { function.ProcessServiceActivities(opProcs, component, dotMatrix); } } } chartData.Units.Add(function); } }
public List <ChartDataListItem> Generate(int serviceDeskId, bool svcDomains = false, bool svcFunctions = false, bool svcComponents = false, bool resolvers = false, bool svcActivities = false, bool opProcs = false, string[] domainsSelected = null) { if (serviceDeskId == 0) { throw new ArgumentNullException(nameof(serviceDeskId)); } var diagram = new List <ChartDataListItem>(); var serviceDeskChart = new ChartDataListItem(); var serviceDesk = _serviceDeskService.GetById(serviceDeskId); if (serviceDesk != null) { var customerName = serviceDesk.Customer.CustomerName; serviceDeskChart.CreateServiceDeskWithInputs(serviceDesk); var serviceDomains = serviceDesk.ServiceDomains.ToList(); if (domainsSelected != null) { if (!domainsSelected.Contains("0")) { // Only render the selected Service Domains var selectedDomains = domainsSelected.ToList(); serviceDomains = serviceDomains.Where(x => selectedDomains.Contains(x.Id.ToString())).ToList(); } } if (serviceDomains.Any()) { var dotMatrix = _resolverService.GetDotMatrix(serviceDesk.CustomerId, true); if (svcDomains || domainsSelected != null && domainsSelected.Any()) { serviceDeskChart.ProcessServiceDomains(svcFunctions, svcComponents, resolvers, svcActivities, opProcs, customerName, serviceDomains, dotMatrix); } else if (svcFunctions) { foreach (var deskDomain in serviceDomains) { serviceDeskChart.ProcessServiceFunctions(svcComponents, resolvers, svcActivities, opProcs, customerName, deskDomain, dotMatrix); } } else if (svcComponents) { foreach (var domainFunction in serviceDomains.Where(deskDomain => deskDomain.ServiceFunctions != null).SelectMany(deskDomain => deskDomain.ServiceFunctions)) { serviceDeskChart.ProcessServiceComponents(resolvers, svcActivities, opProcs, customerName, domainFunction, dotMatrix); } } else if (resolvers) { foreach (var component in from deskDomain in serviceDomains where deskDomain.ServiceFunctions != null from domainFunction in deskDomain.ServiceFunctions where domainFunction.ServiceComponents != null from component in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1) select component) { serviceDeskChart.ProcessResolvers(svcActivities, opProcs, customerName, component, dotMatrix); } } else if (svcActivities) { foreach (var component in from deskDomain in serviceDomains where deskDomain.ServiceFunctions != null from domainFunction in deskDomain.ServiceFunctions where domainFunction.ServiceComponents != null from component in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1) select component) { serviceDeskChart.ProcessServiceActivities(opProcs, component, dotMatrix); } } } if (!serviceDeskChart.Units.Any()) { // Add Empty Unit var chartDataListItem = new ChartDataListItem { Id = 0, Title = string.Empty, CenteredTitle = string.Empty, Type = DecompositionType.EmptyForLayout.ToString(), Units = new List <ChartDataListItem>(), }; serviceDeskChart.Units.Add(chartDataListItem); } diagram.Add(serviceDeskChart); } return(diagram); }
public static void ProcessServiceComponents(this ChartDataListItem chartData, bool resolvers, bool svcActivities, bool opProcs, string customerName, ServiceFunction domainFunction, List <List <DotMatrixListItem> > dotMatrix) { if (domainFunction.ServiceComponents == null) { return; } foreach (var parentComponent in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1).OrderBy(x => x.DiagramOrder).ThenBy(x => x.ComponentName).ToList()) { var parentComponentListItem = new ChartDataListItem { Id = parentComponent.Id, Title = parentComponent.ComponentName, Type = DecompositionType.Component.ToString(), CenteredTitle = string.Empty, Units = new List <ChartDataListItem>() }; if (parentComponent.ChildServiceComponents != null && parentComponent.ChildServiceComponents.Count > 0) { foreach (var childComponent in parentComponent.ChildServiceComponents.OrderBy(x => x.DiagramOrder).ThenBy(x => x.ComponentName)) { // Add Child Component var childComponentListItem = new ChartDataListItem { Id = childComponent.Id, Title = childComponent.ComponentName, Type = DecompositionType.Component.ToString(), CenteredTitle = string.Empty, Units = new List <ChartDataListItem>() }; if (resolvers) { childComponentListItem.ProcessResolvers(svcActivities, opProcs, customerName, childComponent, dotMatrix); } else if (svcActivities) { childComponentListItem.ProcessServiceActivities(opProcs, childComponent, dotMatrix); } parentComponentListItem.Units.Add(childComponentListItem); } } else if (resolvers || svcActivities) { // Create A Dummy Child Component var childComponentListItem = new ChartDataListItem { Id = 0, Title = string.Empty, CenteredTitle = string.Empty, Type = DecompositionType.LineForDummyChildComponent.ToString(), Units = new List <ChartDataListItem>() }; if (resolvers) { childComponentListItem.ProcessResolvers(svcActivities, opProcs, customerName, parentComponent, dotMatrix); } else { childComponentListItem.ProcessServiceActivities(opProcs, parentComponent, dotMatrix); } if (childComponentListItem.Units.Any()) { parentComponentListItem.Units.Add(childComponentListItem); } } chartData.Units.Add(parentComponentListItem); } }