Esempio n. 1
0
        public IList <InvoiceBatch> LoadInvoiceBatchesForDateRange(int clientId, BatchType batchType, DateRange dateRange)
        {
            ArgumentChecker.ThrowIfNull(batchType, "batchType");
            ArgumentChecker.ThrowIfNull(dateRange, "dateRange");
            if (!batchType.IsDateRangeDependant)
            {
                throw new InvalidOperationException("Batch type is not date range dependent");
            }

            //start ref: mariper
            //we should be able to implement call back of event functions here to somehow tell the client that the DB is still fetching as this bit of code takes too long when records exceeds 2K+
            if (StartDataFetchEvent != null)
            {
                StartDataFetchEvent(this, (EventArgs)(new CEventArgs(200, "start")));
            }

            DataSet theDS = batches.LoadBatches(Action,
                                                batchType.Id,
                                                string.Empty,
                                                dateRange.StartDate.Value.DateTime,
                                                dateRange.EndDate.Value.DateTime,
                                                ref clientId,
                                                7);

            if (theDS == null)
            {
                return(null);
            }

            DataTableCollection tables = theDS.Tables;
            int rowCount = (tables == null)?0:(tables["Batches"] == null)?0:(tables["Batches"].Rows.Count);

            if (EndDataFetchEvent != null)
            {
                EndDataFetchEvent(this, (EventArgs)(new CEventArgs(rowCount, "stop")));
            }

            IList <InvoiceBatch> invoiceBatches = new InvoiceBatchBuilder().Build(tables["Batches"]);

            //end ref: mariper
            return(RecordLimiter.ReturnMaximumRecords(invoiceBatches));
        }