Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            lblMessage.Text = string.Empty;

            if (txtHostname.Text != string.Empty && txtApiPassword.Text != string.Empty && txtApiUsername.Text != string.Empty)
            {
                ElexioCommunityApi.Connect(txtHostname.Text, txtApiUsername.Text, txtApiPassword.Text);

                if (ElexioCommunityApi.IsConnected)
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    lblMessage.Text = $"Could not login with the information provided. {ElexioCommunityApi.ErrorMessage}";
                }
            }
            else
            {
                lblMessage.Text = "Please provide the information needed to connect.";
            }
        }
Ejemplo n.º 2
0
        private void ExportWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            exportWorker.ReportProgress(0, "");
            _apiUpdateTimer.Start();

            var exportSettings = (ExportSettings)e.Argument;

            // clear filesystem directories
            ElexioCommunityApi.InitializeExport();

            // export individuals
            if (exportSettings.ExportIndividuals)
            {
                exportWorker.ReportProgress(1, "Exporting Individuals...");
                ElexioCommunityApi.ExportIndividuals(exportSettings.PersonCSVFileName);

                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        exportWorker.ReportProgress(4, $"Error exporting individuals: {ElexioCommunityApi.ErrorMessage}");
                    });
                }
            }

            // export contributions
            if (exportSettings.ExportContributions)
            {
                exportWorker.ReportProgress(25, "Exporting Financial Accounts...");

                ElexioCommunityApi.ExportFinancialAccounts();
                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(28, $"Error exporting financial accounts: {ElexioCommunityApi.ErrorMessage}");
                }

                exportWorker.ReportProgress(30, "Exporting Financial Pledges...");

                ElexioCommunityApi.ExportFinancialPledges();
                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(33, $"Error exporting financial pledges: {ElexioCommunityApi.ErrorMessage}");
                }

                exportWorker.ReportProgress(35, "Exporting Contribution Information...");

                ElexioCommunityApi.ExportFinancialTransactions(exportSettings.GivingCSVFileName);
                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(38, $"Error exporting financial data: {ElexioCommunityApi.ErrorMessage}");
                }
            }

            // export groups
            if (exportSettings.ExportGroups)
            {
                exportWorker.ReportProgress(50, $"Exporting Groups...");

                ElexioCommunityApi.ExportGroups();

                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(53, $"Error exporting groups: {ElexioCommunityApi.ErrorMessage}");
                }
            }

            // export attendance
            if (exportSettings.ExportAttendance)
            {
                exportWorker.ReportProgress(75, $"Exporting Attendance...");

                ElexioCommunityApi.ExportAttendance();

                if (ElexioCommunityApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(78, $"Error exporting attendance: {ElexioCommunityApi.ErrorMessage}");
                }
            }

            // finalize the package
            ImportPackage.FinalizePackage("elexio-export.slingshot");

            _apiUpdateTimer.Stop();
        }