예제 #1
0
        /// <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)
        {
            // populate email types combobox
            ExportEmailTypes = AcsApi.GetEmailTypes();
            if (ExportEmailTypes.Any())
            {
                foreach (var emailType in ExportEmailTypes)
                {
                    EmailTypesComboBoxItems.Add(new ComboBoxItem {
                        Text = emailType
                    });
                }

                cblEmailTypes.ItemsSource   = EmailTypesComboBoxItems;
                cblEmailTypes.SelectedIndex = 0;
            }
            else
            {
                btnDownloadPackage.IsEnabled = false;
                txtMessages.Text             = "ERROR:  Cannot Export Data without Email Addresses." + Environment.NewLine;
            }

            // populate campus fields combobox
            ExportCampus = AcsApi.LoadPersonFields();

            ExportCampusComboBoxItems.Add(new ComboBoxItem {
                Text = "------"
            });

            if (ExportCampus.Any())
            {
                foreach (var field in ExportCampus)
                {
                    ExportCampusComboBoxItems.Add(new ComboBoxItem {
                        Text = field
                    });
                }

                cblCampus.ItemsSource   = ExportCampusComboBoxItems;
                cblCampus.SelectedIndex = 0;
            }
            else
            {
                btnDownloadPackage.IsEnabled = false;
                txtMessages.Text            += "ERROR:  Cannot Export Data without Campus data." + Environment.NewLine;
            }

            txtImportCutOff.Text = DateTime.Now.ToShortDateString();
        }
        /// <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)
        {
            // populate email types combobox
            ExportEmailTypes = AcsApi.GetEmailTypes();
            if (ExportEmailTypes.Any())
            {
                foreach (var emailType in ExportEmailTypes)
                {
                    EmailTypesComboBoxItems.Add(new ComboBoxItem {
                        Text = emailType
                    });
                }

                cblEmailTypes.ItemsSource   = EmailTypesComboBoxItems;
                cblEmailTypes.SelectedIndex = 0;
            }

            // populate campus fields combobox
            ExportCampus = AcsApi.LoadPersonFields();

            ExportCampusComboBoxItems.Add(new ComboBoxItem {
                Text = "------"
            });

            if (ExportCampus.Any())
            {
                foreach (var field in ExportCampus)
                {
                    ExportCampusComboBoxItems.Add(new ComboBoxItem {
                        Text = field
                    });
                }

                cblCampus.ItemsSource   = ExportCampusComboBoxItems;
                cblCampus.SelectedIndex = 0;
            }

            txtImportCutOff.Text = DateTime.Now.ToShortDateString();
        }
예제 #3
0
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            lblMessage.Text = string.Empty;

            if (txtFilename.Text != string.Empty && txtFilename.Text.Contains(".mdb"))
            {
                AcsApi.OpenConnection(txtFilename.Text);

                if (AcsApi.IsConnected)
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    lblMessage.Text = $"Could not open the MS Access database file. {AcsApi.ErrorMessage}";
                }
            }
            else
            {
                lblMessage.Text = "Please choose a MS Access database file.";
            }
        }
        private void ExportWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            exportWorker.ReportProgress(0, "");

            var exportSettings = ( ExportSettings )e.Argument;

            // clear filesystem directories
            AcsApi.InitializeExport();

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

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

                exportWorker.ReportProgress(1, "Exporting Phones...");
                AcsApi.ExportPhoneNumbers(exportSettings.ModifiedSince);

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

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

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

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

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

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

                AcsApi.ExportGroups();

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

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

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