예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }