public QBDepositWorker(DailyDeposit dailyDeposit) { _dailyDeposit = dailyDeposit; DoWork += new DoWorkEventHandler(QBDepositWorker_DoWork); WorkerReportsProgress = true; WorkerSupportsCancellation = true; }
private void eaglesoftLoadDataWorker_Completed(object sender, RunWorkerCompletedEventArgs e) { LoadEaglesoftDataWorker worker = (LoadEaglesoftDataWorker)sender; if (e.Cancelled) { setStatus("Operation canceled..."); toolStripProgressBar1.Visible = false; setupDepositsToolStripMenuItem.Enabled = true; importDataToolStripMenuItem.Enabled = true; cancelImportToolStripMenuItem.Visible = false; return; } if (e.Error != null) { MessageBox.Show(e.Error.Message + "\n\n" + e.Error.StackTrace); toolStripProgressBar1.Visible = false; setupDepositsToolStripMenuItem.Enabled = true; importDataToolStripMenuItem.Enabled = true; cancelImportToolStripMenuItem.Visible = false; return; } if (e.Result == null) { processDepositQueue(); return; } DailyDeposit deposit = e.Result as DailyDeposit; if (deposit.Empty) { setStatus(String.Format("no payments or refund results for {0:MM/dd/yy}", worker.Date)); processDepositQueue(); } else { toolStripProgressBar1.Value = 0; toolStripProgressBar1.Visible = false; setStatus("starting export to quickbooks..."); QBDepositWorker qbWorker = new QBDepositWorker(deposit); qbWorker.ProgressChanged += new ProgressChangedEventHandler(workerProgressUpdate); qbWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(qbWorker_RunWorkerCompleted); qbWorker.RunWorkerAsync(); } }
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(); } } }
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(); } }