Example #1
0
        public void getGetBulkPayment()
        {
            EaglesoftPayment payment = es.getPayment(290082);

            Assert.IsInstanceOfType(payment, typeof(EaglesoftBulkPayment));
            EaglesoftBulkPayment esb = payment as EaglesoftBulkPayment;

            Assert.AreEqual(743.40, payment.Amount);
            Assert.AreEqual("bulk payment from Delta Dental Of Illinois (4413/11041,14586,12644,13957)", payment.Description);
            Assert.AreEqual("222960", payment.CheckNumber);
            Assert.AreEqual(4413, esb.BulkPaymentId);
            Assert.AreEqual(new EaglesoftBulkPayment()
            {
                BulkPaymentId = 4413
            }, esb);
        }
        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();
                }
            }
        }