Example #1
0
        public ICorrelatedResSyncInfoEnumerator GetAll(string resourceKind)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                resultInfos = correlatedResSyncTableAdapter.GetAll(jetTransaction);

                jetTransaction.Commit();
            }

            return((null != resultInfos) ? new CorrelatedResSyncInfoEnumerator(resultInfos) : new CorrelatedResSyncInfoEnumerator(new CorrelatedResSyncInfo[0]));
        }
Example #2
0
        public CorrelatedResSyncInfo[] GetPaged(string resourceKind, int pageNumber, int itemsPerPage, out int totalResult)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                resultInfos = correlatedResSyncTableAdapter.GetAll(jetTransaction);

                jetTransaction.Commit();
            }

            // TODO: TO BE REVIEWED!!!
            totalResult = resultInfos.Length;
            if (totalResult == 0)
            {
                return(new CorrelatedResSyncInfo[0]);
            }

            int startIndex = ((pageNumber - 1) * itemsPerPage) + 1;

            if (totalResult < startIndex)
            {
                return(new CorrelatedResSyncInfo[0]);
            }

            int realItemsPerPage;

            if ((totalResult - startIndex) > itemsPerPage)
            {
                realItemsPerPage = itemsPerPage;
            }
            else
            {
                realItemsPerPage = totalResult - startIndex;
            }

            CorrelatedResSyncInfo[] destinationArray = new CorrelatedResSyncInfo[realItemsPerPage];

            Array.Copy(resultInfos, startIndex - 1, destinationArray, 0, realItemsPerPage);

            return(destinationArray);
        }