void RefreshDataWorker_DoWork(object sender, DoWorkEventArgs e) { Quickbooks qb = new Quickbooks(); Eaglesoft es = new Eaglesoft(); try { Configuration configuration = UserSettings.getInstance().Configuration; checkCanceled(e); qb.Connect(); checkCanceled(e); ReportProgress(15, "Obtaining QB payment types"); _configuration.QuickbooksPaytypes = qb.getPaymentTypes(); checkCanceled(e); ReportProgress(30, "Obtaining QB Income accounts"); _configuration.QuickbooksIncomeAccounts = qb.getIncomeAccounts(); checkCanceled(e); ReportProgress(45, "Obtaining QB Bank accounts"); _configuration.QuickbooksBankAccounts = qb.getBankAccounts(); checkCanceled(e); ReportProgress(60, "Obtaining QB Customers"); _configuration.QuickbooksCustomers = qb.getCustomers(); checkCanceled(e); es.Connect(); checkCanceled(e); ReportProgress(75, "Obtaining ES payment types."); checkCanceled(e); _configuration.EaglesoftPaytypes = es.getPaytypes(); checkCanceled(e); ReportProgress(90, "Obtaining ES adjustment types."); _configuration.EaglesoftAdjustments = es.getAdjustmentTypes(); _configuration.normalizeConfiguration(); _configuration.LastRefreshTime = DateTime.Now; UserSettings.getInstance().Save(); ReportProgress(100, "Completes"); } catch (OperationCanceledException) { e.Cancel = true; return; } finally { qb.Disconnect(); es.Disconnect(); } }
public void setupEaglesoft() { es = new Eaglesoft("UID=dba;PWD=sql;host=10.37.129.3"); es.Connect(); Configuration c = new Configuration(); c.EaglesoftPaytypes.Add(new EaglesoftPaymentType() { Id = 9, Description = "Electronic Payment" }); c.EaglesoftPaytypes.Add(new EaglesoftPaymentType() { Id = 2, Description = "Check" }); c.EaglesoftPaytypes.Add(new EaglesoftPaymentType() { Id = 3, Description = "Insurance Check" }); es.Configuration = c; }
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(); } }