コード例 #1
0
        public IEnumerable <OperationalProcessTypeRefData> GetAllAndNotVisibleForCustomer(int customerId)
        {
            List <OperationalProcessTypeRefData> result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                result = OperationalProcessHelper.GetAllAndNotVisibleForCustomer(_operationalProcessRefDataRepository,
                                                                                 _operationalProcessTypeRepository,
                                                                                 customerId);
            });

            return(result);
        }
コード例 #2
0
        public List <List <DotMatrixListItem> > GetDotMatrix(int customerId, bool standard, int?serviceDeskId)
        {
            var result = new List <List <DotMatrixListItem> >();

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                // Get the Op Process reference data.
                var opRefs = standard ? OperationalProcessHelper.GetStandardAndSelectedForCustomer(_operationalProcessTypeRefDataRepository,
                                                                                                   _operationalProcessTypeRepository,
                                                                                                   customerId) : OperationalProcessHelper.GetAllAndNotVisibleForCustomer(_operationalProcessTypeRefDataRepository,
                                                                                                                                                                         _operationalProcessTypeRepository,
                                                                                                                                                                         customerId);

                // Get all the Resolvers and associated Op Processes for this customer. Need a left join here on Op Process Type just in case none are selected.
                var resolverOpProcs = _resolverRepository
                                      .Query(w => w.ServiceDesk.CustomerId == customerId &&
                                             (!serviceDeskId.HasValue || w.ServiceDesk.Id == serviceDeskId.Value))
                                      .Where(w => w.ResolverGroupType != null)
                                      .GroupJoin(_operationalProcessTypeRepository.Query(w => true),
                                                 p => p.Id,
                                                 c => c.Resolver.Id,
                                                 (p, g) => g
                                                 .Select(c => new
                {
                    ResolverId   = p.Id,
                    ResolverName = p.ResolverGroupType.ResolverGroupTypeName,
                    OpProcId     = c.OperationalProcessTypeRefData.Id
                })
                                                 .DefaultIfEmpty(new
                {
                    ResolverId   = p.Id,
                    ResolverName = p.ResolverGroupType.ResolverGroupTypeName,
                    OpProcId     = 0
                }))
                                      .SelectMany(g => g)
                                      .ToList();

                // Get the distinct list of Resolvers.
                var resolvers = resolverOpProcs
                                .GroupBy(g => g.ResolverId)
                                .Select(s => s.First())
                                .ToList();

                // Now build the dictionary such that we end up with a list of dictionaries. The dictionary
                // will be keyed by the column name and have the appropriate value.
                foreach (var resGrp in resolvers.OrderBy(o => o.ResolverName))
                {
                    var componentName =
                        _serviceComponentRepository.Query(c => c.Resolver.Id == resGrp.ResolverId)
                        .AsNoTracking()
                        .Select(s => s.ComponentName)
                        .FirstOrDefault();

                    if (!string.IsNullOrEmpty(componentName))
                    {
                        var d = new List <DotMatrixListItem>
                        {
                            new DotMatrixListItem
                            {
                                Name  = DotMatrixNames.ResolverId,
                                Value = resGrp.ResolverId
                            },
                            new DotMatrixListItem
                            {
                                Name  = DotMatrixNames.ResolverName,
                                Value = resGrp.ResolverName,
                            },
                            new DotMatrixListItem
                            {
                                Name  = DotMatrixNames.ComponentName,
                                Value = componentName,
                            },
                        };

                        foreach (var opRef in opRefs)
                        {
                            var has = resolverOpProcs
                                      .Any(x => x.OpProcId == opRef.Id &&
                                           x.ResolverId == resGrp.ResolverId);
                            d.Add(new DotMatrixListItem
                            {
                                Name        = string.Concat(DotMatrixNames.OpIdPrefix, opRef.Id),
                                DisplayName = opRef.OperationalProcessTypeName,
                                Value       = has
                            });
                        }

                        result.Add(d);
                    }
                }
            });

            return(result);
        }