예제 #1
0
        protected override int QueryCount()
        {
            int count = -1;

            Platform.GetService(
                delegate(IOrderNoteService service)
            {
                var request = new QueryNoteboxRequest(_noteboxClassName, true, false);
                PrepareQueryRequest(request);
                var response = service.QueryNotebox(request);
                count        = response.ItemCount;
            });

            return(count);
        }
        public QueryNoteboxResponse QueryNotebox(QueryNoteboxRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.NoteboxClass, "request.NoteboxClass");

            var notebox = NoteboxFactory.Instance.CreateNotebox(request.NoteboxClass);
            var page    = new SearchResultPage(request.Page.FirstRow, request.Page.MaxRows);
            var nqc     = new NoteboxQueryContext(this, page, request.StaffGroupRef == null ?
                                                  null : PersistenceContext.Load <StaffGroup>(request.StaffGroupRef));

            IList results = null;

            if (request.QueryItems)
            {
                // get the first page, up to the default max number of items per page
                results = notebox.GetItems(nqc);
            }

            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 = notebox.GetItemCount(nqc);
                }
            }

            if (request.QueryItems)
            {
                var assembler = new OrderNoteboxItemAssembler();
                var items     = CollectionUtils.Map(
                    results,
                    (OrderNoteboxItem item) => assembler.CreateSummary(item, PersistenceContext));

                return(new QueryNoteboxResponse(items, count));
            }

            return(new QueryNoteboxResponse(new List <OrderNoteboxItemSummary>(), count));
        }
예제 #3
0
        protected override QueryItemsResult QueryItems(int firstRow, int maxRows)
        {
            QueryItemsResult result = null;

            Platform.GetService(
                delegate(IOrderNoteService service)
            {
                var request = new QueryNoteboxRequest(_noteboxClassName, true, true)
                {
                    Page = new SearchResultPage(firstRow, maxRows)
                };
                PrepareQueryRequest(request);
                var response = service.QueryNotebox(request);
                result       = new QueryItemsResult(response.NoteboxItems, response.ItemCount);
            });

            return(result);
        }
예제 #4
0
 protected virtual void PrepareQueryRequest(QueryNoteboxRequest request)
 {
     // nothing to do
 }
예제 #5
0
        protected override void PrepareQueryRequest(QueryNoteboxRequest request)
        {
            base.PrepareQueryRequest(request);

            request.StaffGroupRef = _groupRef;
        }