private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { exportWorker.ReportProgress(0, ""); var exportSettings = (ExportSettings)e.Argument; // clear filesystem directories CcbApi.InitializeExport(); // export individuals if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); CcbApi.ExportIndividuals(exportSettings.ModifiedSince); if (CcbApi.ErrorMessage.IsNotNullOrWhitespace()) { this.Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting individuals: {CcbApi.ErrorMessage}"); }); } } // export contributions if (exportSettings.ExportContributions) { exportWorker.ReportProgress(30, "Exporting Financial Accounts..."); CcbApi.ExportFinancialAccounts(); if (CcbApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(31, $"Error exporting financial accounts: {CcbApi.ErrorMessage}"); } exportWorker.ReportProgress(35, "Exporting Contribution Information..."); CcbApi.ExportContributions(exportSettings.ModifiedSince); if (CcbApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(36, $"Error exporting financial batches: {CcbApi.ErrorMessage}"); } } // export group types if (ExportGroupTypes.Count > 0) { exportWorker.ReportProgress(54, $"Exporting Groups..."); CcbApi.ExportGroups(ExportGroupTypes.Select(t => t.Id).ToList(), exportSettings.ModifiedSince); if (CcbApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(54, $"Error exporting groups: {CcbApi.ErrorMessage}"); } } // export attendance if (exportSettings.ExportAttendance) { exportWorker.ReportProgress(75, $"Exporting Attendance..."); CcbApi.ExportAttendance(exportSettings.ModifiedSince); if (CcbApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(75, $"Error exporting attendance: {CcbApi.ErrorMessage}"); } } // finalize the package ImportPackage.FinalizePackage("ccb-export.slingshot"); // schedule the API status to update (the status takes a few mins to update) _apiUpdateTimer.Start(); }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { exportWorker.ReportProgress(0, ""); _apiUpdateTimer.Start(); var exportSettings = ( ExportSettings )e.Argument; // clear filesystem directories PCOApi.InitializeExport(); // export individuals if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); PCOApi.ExportIndividuals(exportSettings.ModifiedSince); if (PCOApi.ErrorMessage.IsNotNullOrWhitespace()) { this.Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting individuals: {PCOApi.ErrorMessage}"); }); } } // export contributions if (exportSettings.ExportContributions) { exportWorker.ReportProgress(30, "Exporting Financial Accounts..."); PCOApi.ExportFinancialAccounts(); if (PCOApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(31, $"Error exporting financial accounts: {PCOApi.ErrorMessage}"); } /* PCO Doesn't have pledges * * exportWorker.ReportProgress( 32, "Exporting Financial Pledges..." ); * * PCOApi.ExportFinancialPledges(); * if ( PCOApi.ErrorMessage.IsNotNullOrWhitespace() ) * { * exportWorker.ReportProgress( 33, $"Error exporting financial pledges: {PCOApi.ErrorMessage}" ); * } */ exportWorker.ReportProgress(34, "Exporting Financial Batches..."); PCOApi.ExportFinancialBatches(exportSettings.ModifiedSince); if (PCOApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(35, $"Error exporting financial batches: {PCOApi.ErrorMessage}"); } exportWorker.ReportProgress(36, "Exporting Contribution Information..."); PCOApi.ExportContributions(exportSettings.ModifiedSince, exportSettings.ExportContributionImages); if (PCOApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(37, $"Error exporting financial batches: {PCOApi.ErrorMessage}"); } } // export group types if (exportSettings.ExportGroupTypes.Count > 0) { exportWorker.ReportProgress(54, $"Exporting Groups..."); PCOApi.ExportGroups(ExportGroupTypes.Select(t => t.Id).ToList()); if (PCOApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(54, $"Error exporting groups: {PCOApi.ErrorMessage}"); } } // finalize the package ImportPackage.FinalizePackage("pco-export.slingshot"); _apiUpdateTimer.Stop(); }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { _workStarted = DateTime.Now; exportWorker.ReportProgress(0, ""); _apiUpdateTimer.Start(); var exportSettings = ( ExportSettings )e.Argument; // clear filesystem directories F1Api.InitializeExport(); // export individuals if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); exporter.ExportIndividuals(exportSettings.ModifiedSince); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { this.Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting individuals: {F1Api.ErrorMessage}"); }); } } // export companies if (exportSettings.ExportCompanies) { exportWorker.ReportProgress(1, "Exporting Companies..."); exporter.ExportCompanies(); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting companies: {F1Api.ErrorMessage}"); }); } } // export notes if (exportSettings.ExportNotes) { exportWorker.ReportProgress(1, "Exporting Notes..."); exporter.ExportNotes(); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting notes: {F1Api.ErrorMessage}"); }); } } // export contributions if (exportSettings.ExportContributions) { exportWorker.ReportProgress(30, "Exporting Financial Accounts..."); exporter.ExportFinancialAccounts(); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(31, $"Error exporting financial accounts: {F1Api.ErrorMessage}"); } exportWorker.ReportProgress(32, "Exporting Financial Pledges..."); exporter.ExportFinancialPledges(); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(33, $"Error exporting financial pledges: {F1Api.ErrorMessage}"); } exportWorker.ReportProgress(34, "Exporting Financial Batches..."); exporter.ExportFinancialBatches(exportSettings.ModifiedSince); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(35, $"Error exporting financial batches: {F1Api.ErrorMessage}"); } exportWorker.ReportProgress(36, "Exporting Contribution Information..."); exporter.ExportContributions(exportSettings.ModifiedSince, exportSettings.ExportContributionImages); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(37, $"Error exporting financial contributions: {F1Api.ErrorMessage}"); } } // export group types if (exportSettings.ExportGroupTypes.Count > 0) { exportWorker.ReportProgress(53, $"Exporting Groups..."); exporter.ExportGroups(ExportGroupTypes.Select(t => t.Id).ToList()); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(54, $"Error exporting groups: {F1Api.ErrorMessage}"); } } // export attendance if (exportSettings.ExportAttendance) { exportWorker.ReportProgress(61, "Exporting Attendance..."); exporter.ExportAttendance(exportSettings.ModifiedSince); if (F1Api.ErrorMessage.IsNotNullOrWhitespace()) { this.Dispatcher.Invoke(() => { exportWorker.ReportProgress(68, $"Error exporting attendance: {F1Api.ErrorMessage}"); }); } } exporter.Cleanup(); // finalize the package ImportPackage.FinalizePackage("f1-export.slingshot"); _apiUpdateTimer.Stop(); }