Beispiel #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));
        }
Beispiel #2
0
        public IList <InvoiceBatch> LoadInvoiceBatchesFor(int clientId, BatchType batchType)
        {
            ArgumentChecker.ThrowIfNull(batchType, "batchType");
            if (batchType.IsDateRangeDependant)
            {
                throw new InvalidOperationException("Batch type is date range dependent");
            }

            try
            {
                DataSet theDS = batches.LoadBatches(Action, batchType.Id, string.Empty, Date.MinimumDate.DateTime, Date.MinimumDate.DateTime, ref clientId, 7);
                if (theDS != null)
                {
                    DataTableCollection  tables         = theDS.Tables;
                    IList <InvoiceBatch> invoiceBatches = new InvoiceBatchBuilder().Build(tables["Batches"]);
                    return(RecordLimiter.ReturnMaximumRecords(invoiceBatches));
                }
            }
            catch { }
            return(null);
        }