Exemplo n.º 1
0
        private void ExportWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            exportWorker.ReportProgress(0, "");

            var exportSettings = ( ExportSettings )e.Argument;

            // clear filesystem directories
            ServantKeeperApi.InitializeExport();

            // export individuals and phone numbers
            if (exportSettings.ExportIndividuals)
            {
                exportWorker.ReportProgress(1, "Exporting Individuals...");
                ServantKeeperApi.ExportIndividuals(exportSettings.ModifiedSince, exportSettings.ExportEmailType, exportSettings.ExportCampus);

                if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    txtMessages.Text = $"Error exporting individuals: {ServantKeeperApi.ErrorMessage}";
                }

                /*exportWorker.ReportProgress( 1, "Exporting Phones..." );
                 * ServantKeeperApi.ExportPhoneNumbers( exportSettings.ModifiedSince );
                 *
                 * if ( ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace() )
                 * {
                 *  txtMessages.Text = $"Error exporting phones: {ServantKeeperApi.ErrorMessage}";
                 * }*/
            }

            // export contributions
            if (exportSettings.ExportContributions)
            {
                exportWorker.ReportProgress(30, "Exporting Funds...");

                ServantKeeperApi.ExportFunds();
                if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(31, $"Error exporting funds: {ServantKeeperApi.ErrorMessage}");
                }

                exportWorker.ReportProgress(32, "Exporting Contributions...");

                ServantKeeperApi.ExportContributions(exportSettings.ModifiedSince);
                if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(33, $"Error exporting contributions: {ServantKeeperApi.ErrorMessage}");
                }
            }


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

            // schedule the API status to update (the status takes a few mins to update)
            _apiUpdateTimer.Start();
        }
Exemplo n.º 2
0
        private void ExportWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            exportWorker.ReportProgress(0, "");

            var exportSettings = (ExportSettings)e.Argument;

            // clear filesystem directories
            ServantKeeperApi.InitializeExport(exportSettings.ModifiedSince, exportSettings.NoContributionsBefore);

            // export individuals and phone numbers
            if (exportSettings.ExportIndividuals)
            {
                exportWorker.ReportProgress(1, "Exporting Individuals...");
                ServantKeeperApi.ExportIndividuals();

                if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    txtMessages.Text = $"Error exporting individuals: {ServantKeeperApi.ErrorMessage}";
                }
            }

            // export contributions
            if (exportSettings.ExportContributions)
            {
                exportWorker.ReportProgress(32, "Exporting Contributions...");

                ServantKeeperApi.ExportContributions();
                if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(33, $"Error exporting contributions: {ServantKeeperApi.ErrorMessage}");
                }
            }

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

                ServantKeeperApi.ExportGroups(exportSettings.SelectedGroups);

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

            // finalize the package
            ImportPackage.FinalizePackage("servantkeeper.slingshot");

            // schedule the API status to update (the status takes a few mins to update)
            _apiUpdateTimer.Start();
        }