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

            var exportSettings = (ExportSettings)e.Argument;

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

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

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

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

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

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

                ServanrKeeperApi.ExportGroups(exportSettings.SelectedGroups);

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

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

            // schedule the API status to update (the status takes a few mins to update)
            _apiUpdateTimer.Start();
        }
        /// <summary>
        /// Handles the Loaded event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Retrieve the Group Names from the database
            Dictionary <int, string> AllGroups = ServanrKeeperApi.GetAllGroups();

            // Populate Groups listbox control with available group names
            if (AllGroups.Any())
            {
                foreach (var group in AllGroups)
                {
                    GroupsListBox.Items.Add(new ListBoxItem()
                    {
                        Content = group.Value, Uid = group.Key.ToString()
                    });
                }
            }

            // Initialize values
            txtImportCutOff.Text        = "1/1/1900";
            txtContributionsCutOff.Text = "1/1/2017";
            Groups_Checked(null, null);
        }
Beispiel #3
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            lblMessage.Text = string.Empty;

            if (txtFilename.Text != string.Empty)
            {
                ServanrKeeperApi.OpenConnection(txtFilename.Text);

                if (ServanrKeeperApi.IsConnected)
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    lblMessage.Text = $"Could not open the MS Access database file. {ServanrKeeperApi.ErrorMessage}";
                }
            }
            else
            {
                lblMessage.Text = "Please choose a MS Access database file.";
            }
        }