private void btnLogin_Click(object sender, RoutedEventArgs e) { lblMessage.Text = string.Empty; if (txtApiKey.Text != string.Empty && txtApiToken.Text != string.Empty) { TheCityApi.Connect(txtApiKey.Text, txtApiToken.Text); if (TheCityApi.IsConnected) { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } else { lblMessage.Text = $"Could not login with the information provided. {TheCityApi.ErrorMessage}"; } } else { lblMessage.Text = "Please provide the information needed to connect."; } }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { exportWorker.ReportProgress(0, ""); _apiUpdateTimer.Start(); var exportSettings = ( ExportSettings )e.Argument; // clear filesystem directories TheCityApi.InitializeExport(); // export individuals if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); TheCityApi.ExportIndividuals(exportSettings.ModifiedSince); if (TheCityApi.ErrorMessage.IsNotNullOrWhitespace()) { this.Dispatcher.Invoke(() => { exportWorker.ReportProgress(2, $"Error exporting individuals: {TheCityApi.ErrorMessage}"); }); } } // export contributions //if ( exportSettings.ExportContributions ) //{ // exportWorker.ReportProgress( 30, "Exporting Financial Accounts..." ); // TheCityApi.ExportFinancialAccounts(); // if ( TheCityApi.ErrorMessage.IsNotNullOrWhitespace() ) // { // exportWorker.ReportProgress( 31, $"Error exporting financial accounts: {TheCityApi.ErrorMessage}" ); // } // exportWorker.ReportProgress( 32, "Exporting Financial Pledges..." ); // TheCityApi.ExportFinancialPledges(); // if ( TheCityApi.ErrorMessage.IsNotNullOrWhitespace() ) // { // exportWorker.ReportProgress( 33, $"Error exporting financial pledges: {TheCityApi.ErrorMessage}" ); // } // exportWorker.ReportProgress( 34, "Exporting Financial Batches..." ); // TheCityApi.ExportFinancialBatches( exportSettings.ModifiedSince ); // if ( TheCityApi.ErrorMessage.IsNotNullOrWhitespace() ) // { // exportWorker.ReportProgress( 35, $"Error exporting financial batches: {TheCityApi.ErrorMessage}" ); // } // exportWorker.ReportProgress( 36, "Exporting Contribution Information..." ); // TheCityApi.ExportContributions( exportSettings.ModifiedSince, exportSettings.ExportContributionImages ); // if ( TheCityApi.ErrorMessage.IsNotNullOrWhitespace() ) // { // exportWorker.ReportProgress( 37, $"Error exporting financial batches: {TheCityApi.ErrorMessage}" ); // } //} // export group types //if ( exportSettings.ExportGroupTypes.Count > 0 ) //{ // exportWorker.ReportProgress( 54, $"Exporting Groups..." ); // TheCityApi.ExportGroups( ExportGroupTypes.Select( t => t.Id ).ToList() ); // if ( TheCityApi.ErrorMessage.IsNotNullOrWhitespace() ) // { // exportWorker.ReportProgress( 54, $"Error exporting groups: {TheCityApi.ErrorMessage}" ); // } //} // finalize the package ImportPackage.FinalizePackage("thecity-export.slingshot"); _apiUpdateTimer.Stop(); }