Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExportButton_Click(object sender, EventArgs e)
        {
            if (Datastore.Transactions.TransactionHistory.Count == 0)
            {
                MessageBox.Show("There are no transactions to export");
                return;
            }

            var result = MessageBox.Show("Exporting transactions to Dropbox will clear all transactions in YNABcompanion. Are you sure you want to proceed?", "", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }

            ProgressBar.Visibility      = Visibility.Visible;
            ProgressBar.IsIndeterminate = true;

            if (!DropboxHelper.IsSetup())
            {
                DropboxHelper.Setup(this, delegate { ExportButton_Click(sender, e); });
            }
            else
            {
                bool success = true;
                Task.Run(async() => {
                    int i = 0;
                    Dictionary <String, String> csvStrings = GetCsvStrings();
                    foreach (KeyValuePair <String, String> pair in csvStrings)
                    {
                        success = await DropboxHelper.ExportTextFile("YNABcompanion", pair.Key + ".csv", pair.Value,
                                                                     delegate { ExportCompleted(new List <String>(csvStrings.Keys)); }, ++i == csvStrings.Count);
                        if (!success)
                        {
                            Deployment.Current.Dispatcher.BeginInvoke(() => {
                                MessageBox.Show("You cannot export transactions without network connectivity.");
                                ProgressBar.IsIndeterminate = false;
                                ProgressBar.Visibility      = Visibility.Collapsed;
                            });
                            break;
                        }
                    }
                });
            }
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ImportButton_Click(object sender, EventArgs e)
 {
     ProgressBar.Visibility      = Visibility.Collapsed;
     ProgressBar.IsIndeterminate = false;
     if (!DropboxHelper.IsSetup())
     {
         ProgressBar.Visibility      = Visibility.Visible;
         ProgressBar.IsIndeterminate = true;
         DropboxHelper.Setup(this, delegate { ImportButton_Click(sender, e); });
     }
     else
     {
         if (!NetworkInterface.GetIsNetworkAvailable())
         {
             MessageBox.Show("You can not import YNAB data without network connectivity.");
         }
         else
         {
             NavigationService.Navigate(new Uri("//FileExplorer.xaml", UriKind.Relative));
         }
     }
 }