Has() публичный Метод

Checks if token contains the claim requested.
public Has ( bool>.Func ClaimAccessor ) : bool
ClaimAccessor bool>.Func A lambda which validates the tokens
Результат bool
Пример #1
0
        private static List<string> FilterAllowedTypes(AuthorizationToken Authorization)
        {
            if (!Authorization.HasAll(Claims.Job.Types.ShowHMisc, Claims.Job.Types.ShowHNWar, Claims.Job.Types.ShowHWar, Claims.Job.Types.ShowSApp, Claims.Job.Types.ShowSImg, Claims.Job.Types.ShowSOS, Claims.Job.Types.ShowUMgmt))
            {
                // Must Filter
                List<string> allowedTypes = new List<string>(6);
                if (Authorization.Has(Claims.Job.Types.ShowHMisc))
                    allowedTypes.Add(JobType.JobTypeIds.HMisc);
                if (Authorization.Has(Claims.Job.Types.ShowHNWar))
                    allowedTypes.Add(JobType.JobTypeIds.HNWar);
                if (Authorization.Has(Claims.Job.Types.ShowHWar))
                    allowedTypes.Add(JobType.JobTypeIds.HWar);
                if (Authorization.Has(Claims.Job.Types.ShowSApp))
                    allowedTypes.Add(JobType.JobTypeIds.SApp);
                if (Authorization.Has(Claims.Job.Types.ShowSImg))
                    allowedTypes.Add(JobType.JobTypeIds.SImg);
                if (Authorization.Has(Claims.Job.Types.ShowSOS))
                    allowedTypes.Add(JobType.JobTypeIds.SOS);
                if (Authorization.Has(Claims.Job.Types.ShowUMgmt))
                    allowedTypes.Add(JobType.JobTypeIds.UMgmt);

                return allowedTypes;
            }
            return null;
        }
Пример #2
0
        public static JobTableModel MyJobsTable(AuthorizationToken AuthToken)
        {
            var openJobs = ManagedJobList.openJobs.Items.PermissionsFiltered(AuthToken).Cast<JobTableStatusItemModel>();
            IEnumerable<Tuple<JobTableStatusItemModel, byte, byte, DateTime?>> allJobs = null;

            if (AuthToken.Has(Claims.Job.Lists.MyJobsOrphaned))
            {
                allJobs = AwaitingTechnicianActionFilter(
                    openJobs.Where(i => i.ActiveJobQueues == null || i.ActiveJobQueues.Count() == 0)
                    ).Select(i => new Tuple<JobTableStatusItemModel, byte, byte, DateTime?>(i, (byte)JobQueuePriority.Normal, (byte)JobQueuePriority.Normal, null));
            }

            var usersQueues = JobQueueService.UsersQueues(AuthToken).ToDictionary(q => q.JobQueue.Id);

            var queueJobs = openJobs
                .Where(i => i.ActiveJobQueues != null && i.ActiveJobQueues.Any(jqj => usersQueues.ContainsKey(jqj.QueueId)))
                .Select(i => new Tuple<JobTableStatusItemModel, byte, byte, DateTime?>(
                    i,
                    (byte)i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId)).Max(q => (int)usersQueues[q.QueueId].JobQueue.Priority),
                    (byte)i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId)).Max(q => (int)q.Priority),
                    i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId) && q.SLAExpiresDate.HasValue).Min(q => q.SLAExpiresDate)
                    ));

            if (allJobs != null)
                allJobs = allJobs.Concat(queueJobs).ToList();
            else
                allJobs = queueJobs.ToList();
            
            var allJobsSorted = allJobs
                .OrderByDescending(i => i.Item2).ThenByDescending(i => i.Item3).ThenBy(i => i.Item4).ThenBy(i => i.Item1.OpenedDate).Select(q => q.Item1);

            return new JobTableModel()
            {
                ShowStatus = true,
                Items = allJobsSorted.ToList()
            };
        }