public QueryWorklistResponse <ReportingWorklistItemSummary> QueryWorklist(QueryWorklistRequest request)
        {
            var assembler = new ReportingWorkflowAssembler();

            return(QueryWorklistHelper <ReportingWorklistItem, ReportingWorklistItemSummary>(
                       request,
                       item => assembler.CreateWorklistItemSummary(item, this.PersistenceContext)));
        }
        private bool IsWorklistUserDependent(QueryWorklistRequest req)
        {
            // check if the worklist has a dependency on the executing staff (eg current user)
            var worklist        = GetWorklist(req);
            var workingFacility = GetWorkingFacility(req);
            var probingWqc      = new ProbingWorklistQueryContext(this, workingFacility, req.Page, req.DowntimeRecoveryMode);

            // get the worklist to apply all of its criteria
            worklist.GetInvariantCriteria(probingWqc);
            worklist.GetFilterCriteria(probingWqc);

            // return value indicating dependency on executing staff
            return(probingWqc.DependsOnExecutingStaff);
        }
 private Worklist GetWorklist(QueryWorklistRequest request)
 {
     return(request.WorklistRef != null?
            this.PersistenceContext.Load <Worklist>(request.WorklistRef) :
                WorklistFactory.Instance.CreateWorklist(request.WorklistClass));
 }
 private Facility GetWorkingFacility(QueryWorklistRequest request)
 {
     return(request.WorkingFacilityRef == null ? null :
            PersistenceContext.Load <Facility>(request.WorkingFacilityRef, EntityLoadFlags.Proxy));
 }
        /// <summary>
        /// Helper method to query a worklist.
        /// </summary>
        /// <typeparam name="TItem"></typeparam>
        /// <typeparam name="TSummary"></typeparam>
        /// <param name="request"></param>
        /// <param name="mapCallback"></param>
        /// <returns></returns>
        protected QueryWorklistResponse <TSummary> QueryWorklistHelper <TItem, TSummary>(QueryWorklistRequest request,
                                                                                         Converter <TItem, TSummary> mapCallback)
        {
            IWorklist worklist = GetWorklist(request);

            IList results         = null;
            var   page            = new SearchResultPage(request.Page.FirstRow, request.Page.MaxRows);
            var   workingFacility = GetWorkingFacility(request);

            if (request.QueryItems)
            {
                // get the first page, up to the default max number of items per page
                results = worklist.GetWorklistItems(new WorklistQueryContext(this, workingFacility, page, request.DowntimeRecoveryMode));
            }

            var count = -1;

            if (request.QueryCount)
            {
                // if the items were already queried, and the number returned is less than the max per page, and this is the first page
                // then there is no need to do a separate count query
                if (results != null && results.Count < page.MaxRows && page.FirstRow == 0)
                {
                    count = results.Count;
                }
                else
                {
                    count = worklist.GetWorklistItemCount(new WorklistQueryContext(this, workingFacility, null, request.DowntimeRecoveryMode));
                }
            }

            return(new QueryWorklistResponse <TSummary>(
                       request.QueryItems ? CollectionUtils.Map(results, mapCallback) : null, count));
        }