예제 #1
0
        public void TestGetCounts()
        {
            DailyTransactionRange range = es.getTransactionRangeFor(new DateTime(2013, 9, 18));
            Int32 paymentCount          = es.getPaymentCount(range);

            Assert.AreEqual(34, paymentCount);

            List <Int32> txnIds = es.getPaymentTransactionIds(range);

            Assert.AreEqual(34, txnIds.Count);
        }
        private void LoadEaglesoftDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Eaglesoft    es           = new Eaglesoft();
            DailyDeposit dailyDeposit = new DailyDeposit(Date);

            try
            {
                if (CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                es.Connect();
                DailyTransactionRange range = es.getTransactionRangeFor(Date);
                if (range == null)
                {
                    ReportProgress(100, "No data available");
                    return;
                }
                queryCount      = 0;
                totalQueryCount = es.getPaymentCount(range) + es.getRefundCount(range);

                List <EaglesoftBulkPayment> bulkPaymentsProcessed = new List <EaglesoftBulkPayment>();
                List <Int32> paymentTxnIds = es.getPaymentTransactionIds(range);
                List <Int32> refundTxnIds  = es.getRefundTransactionIds(range);
                e.Result = dailyDeposit;

                foreach (Int32 paymentTxnId in paymentTxnIds)
                {
                    EaglesoftPayment     payment     = es.getPayment(paymentTxnId);
                    EaglesoftBulkPayment bulkPayment = payment as EaglesoftBulkPayment;
                    queryCount++;

                    if (bulkPayment == null)
                    {
                        dailyDeposit.addPayment(payment);
                        ReportProgress(calculatePercentageComplete(), String.Format("{0}", payment));
                    }
                    else if (bulkPayment != null && bulkPaymentsProcessed.Contains(bulkPayment) == false)
                    {
                        dailyDeposit.addPayment(payment);
                        ReportProgress(calculatePercentageComplete(), String.Format("{0}", payment));
                    }

                    if (bulkPayment != null)
                    {
                        bulkPaymentsProcessed.Add(bulkPayment);
                    }

                    if (CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                }

                foreach (Int32 refundTxnId in refundTxnIds)
                {
                    EaglesoftRefund refund = es.getRefund(refundTxnId);
                    dailyDeposit.addRefund(refund);
                    queryCount++;
                    ReportProgress(calculatePercentageComplete(), String.Format("{0}", refund));
                    if (CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            finally
            {
                if (es != null)
                {
                    es.Disconnect();
                }
            }
        }