コード例 #1
0
 /// <summary>
 /// Handles the Tick event of the _apiUpdateTimer control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void _apiUpdateTimer_Tick(object sender, EventArgs e)
 {
     // update the api stats
     CcbApi.UpdateApiStatus();
     lblApiUsage.Text = $"API Usage: {CcbApi.Counter} / {CcbApi.DailyLimit}";
     _apiUpdateTimer.Stop();
 }
コード例 #2
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)
        {
            lblApiUsage.Text = $"API Usage: {CcbApi.Counter} / {CcbApi.DailyLimit}";

            // add group types
            ExportGroupTypes = CcbApi.GetGroupTypes();

            foreach (var groupType in ExportGroupTypes)
            {
                //cblGroupTypes.Items.Add( groupType );
                GroupTypesCheckboxItems.Add(new CheckListItem {
                    Id = groupType.Id, Text = groupType.Name, Checked = true
                });
            }

            cblGroupTypes.ItemsSource = GroupTypesCheckboxItems;

            txtImportCutOff.Text = DateTime.Now.ToShortDateString(); // remove before flight (sets today's date as the modified since)
        }
コード例 #3
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)
            {
                CcbApi.Connect(txtHostname.Text, txtApiUsername.Text, txtApiPassword.Text);

                if (CcbApi.IsConnected)
                {
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    this.Close();
                }
                else
                {
                    lblMessage.Text = $"Could not login with the information provided. {CcbApi.ErrorMessage}";
                }
            }
            else
            {
                lblMessage.Text = "Please provide the information needed to connect.";
            }
        }
コード例 #4
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)
        {
            int remainingRequests = CcbApi.DailyLimit - CcbApi.Counter;

            CcbApi.ApiRequestLimit = remainingRequests;

            lblApiUsage.Text     = $"API Usage: {CcbApi.Counter} / {CcbApi.DailyLimit}";
            txtItemsPerPage.Text = CcbApi.ItemsPerPage.ToString();
            txtThrottleRate.Text = CcbApi.ApiThrottleRate.ToString();

            // add group types
            ExportGroupTypes = CcbApi.GetGroupTypes().OrderBy(t => t.Name).ToList();

            foreach (var groupType in ExportGroupTypes)
            {
                GroupTypesCheckboxItems.Add(new CheckListItem {
                    Id = groupType.Id, Text = groupType.Name, Checked = true
                });
            }

            cblGroupTypes.ItemsSource = GroupTypesCheckboxItems;

            txtImportCutOff.Text = new DateTime(1998, 1, 1).ToShortDateString();
        }
コード例 #5
0
        private void ExportWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            exportWorker.ReportProgress(0, "");

            var exportSettings = (ExportSettings)e.Argument;

            // clear filesystem directories
            CcbApi.InitializeExport();



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

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

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

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

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

                CcbApi.ExportContributions(exportSettings.ModifiedSince);
                if (CcbApi.ErrorMessage.IsNotNullOrWhitespace())
                {
                    exportWorker.ReportProgress(36, $"Error exporting financial batches: {CcbApi.ErrorMessage}");
                }
            }

            // export group types
            if (ExportGroupTypes.Count > 0)
            {
                exportWorker.ReportProgress(54, $"Exporting Groups...");

                CcbApi.ExportGroups(ExportGroupTypes.Select(t => t.Id).ToList(), exportSettings.ModifiedSince);

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

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

                CcbApi.ExportAttendance(exportSettings.ModifiedSince);


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

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

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