Пример #1
0
        public ICollection <ReportQueueItem> GetReportsInProgress()
        {
            // Get the Reports that are In Progress for the User.
            var reportsInProgress = UnitOfWork.GetEntityQuery <Report>()
                                    .Where(WorkflowSpecifications.InProgressForUser(IdentityId))
                                    .AsListOf <ReportQueueItem>();

            // Correlate each report with its creator.
            reportsInProgress.ForEach(i => MapReportCreators(i, _administrationUnitOfWork.GetEntityQuery <User>()));
            return(reportsInProgress);
        }
Пример #2
0
        public ICollection <ReportQueueItem> GetReportsPendingApproval()
        {
            // Get the Roles the User is Assigned to
            var userRoleIds = _administrationUnitOfWork.GetEntityQuery <AssignedRole>()
                              .Where(assignedRole => assignedRole.IdentityId == IdentityId)
                              .Select(assignedRole => assignedRole.RoleId)
                              .Distinct()
                              .ToList();

            // Get the Reports that are Pending Approval for the User.
            var reports = UnitOfWork.GetEntityQuery <Report>()
                          .Where(WorkflowSpecifications.PendingApprovalForUser(userRoleIds))
                          .AsListOf <ReportQueueItem>();

            // Correlate each report with its creator.
            reports.ForEach(i => MapReportCreators(i, _administrationUnitOfWork.GetEntityQuery <User>()));
            return(reports);
        }
Пример #3
0
        private IQueryable <Report> GetReportsByQueueType(QueueType queueType)
        {
            IQueryable <Report> reports = null;

            switch (queueType)
            {
            case QueueType.InProgress:

                reports = UnitOfWork.GetEntityQueryAndInclude <Report>(TrackingMode.Manual, x => x.Event,
                                                                       x => x.Officers)
                          .Where(WorkflowSpecifications.InProgressForUser(IdentityId));

                break;

            case QueueType.MyReports:

                var workflowInstanceIds = GetMyReportWorkflowIds();

                reports = UnitOfWork.GetEntityQueryAndInclude <Report>(TrackingMode.Manual, x => x.Event, x => x.Officers)
                          .Where(report => workflowInstanceIds.Any(id => id == report.Id));

                break;

            case QueueType.Approval:

                var userRoleIds =
                    _administrationUnitOfWork.GetEntityQuery <AssignedRole>()
                    .Where(assignedRole => assignedRole.IdentityId == IdentityId)
                    .Select(assignedRole => assignedRole.RoleId)
                    .Distinct()
                    .ToList();

                // Reports Pending Approval for the User.
                reports =
                    UnitOfWork.GetEntityQueryAndInclude <Report>(TrackingMode.Manual, x => x.Event, x => x.Officers)
                    .Where(WorkflowSpecifications.PendingApprovalForUser(userRoleIds));

                break;

            case QueueType.ReportAdministration:

                var identity = GetCurrentIdentity();

                RequiresReportsAdmin();

                var agenciesToAdmin =
                    ReferenceDataHelper.Agencies.Where(agency => identity.Permissions.ReportAdministrationGranted(agency.AgencyId))
                    .Select(agency => agency.AgencyId)
                    .ToList();

                reports =
                    UnitOfWork.GetEntityQueryAndInclude <Report>(TrackingMode.Manual, x => x.Event, x => x.Officers)
                    .Where(
                        report =>
                        agenciesToAdmin.Contains(report.AgencyId) &&
                        report.WorkflowInstance.ReportState != ReportState.Complete);

                break;
            }

            return(reports);
        }
Пример #4
0
        public void PendingApprovalForUser()
        {
            var result = WorkflowSpecifications.PendingApprovalForUser(lstGuid);

            result.Should().BeOfType(typeof(Expression <Func <Report, bool> >));
        }
Пример #5
0
        public void InProgressForUser()
        {
            var result = WorkflowSpecifications.InProgressForUser(Guid.NewGuid());

            result.Should().BeOfType(typeof(Expression <Func <Report, bool> >));
        }