Beispiel #1
0
 private async void Close(object o)
 {
     if (IsBachupRunning())
     {
         var view = new ConfirmChoiceView
         {
             DataContext = new ConfirmChoiceViewModel("Careful There",
                                                      "There are still some bachup items running. Are you sure you want to exit?")
         };
         if (!(bool)await DialogHost.Show(view, "RootDialog"))
         {
             return;
         }
     }
     ((MainView)o).ExitApplication();
 }
Beispiel #2
0
        private async void DeleteDestination(object o)
        {
            string message    = String.Format("Delete Destination?");
            string submessage = String.Format("{0}", SelectedDestination);

            var view = new ConfirmChoiceView
            {
                DataContext = new ConfirmChoiceViewModel(message, submessage)
            };

            var choice = await DialogHost.Show(view, "RootDialog");

            if ((bool)choice)
            {
                _bachupGroup.DeleteDestination(_selectedDestination);
                MainViewModel.SaveData();
            }
        }
Beispiel #3
0
        private async void DeleteBachupGroup(object parameter)
        {
            string message    = String.Format("Delete {0}?", BachupGroup.Name);
            string submessage = String.Format("This is not reversable. You will lose all bachup items and their history. Source files will remain in place.");

            var view = new ConfirmChoiceView
            {
                DataContext = new ConfirmChoiceViewModel(message, submessage)
            };

            var choice = await DialogHost.Show(view, "RootDialog");

            if ((bool)choice == true)
            {
                MainViewModel.Bachup.Remove(BachupGroup);
                MainViewModel.SaveData();
                UpdateView();
            }
        }
Beispiel #4
0
        private async void DeleteDestination(object parameter)
        {
            if (!BachupItem.RunningBachup)
            {
                string message    = String.Format("Delete Destination?");
                string submessage = String.Format("{0}", SelectedDestination);

                var view = new ConfirmChoiceView
                {
                    DataContext = new ConfirmChoiceViewModel(message, submessage)
                };

                var choice = await DialogHost.Show(view, "RootDialog");

                if ((bool)choice)
                {
                    _bachupItem.DeleteDestination(_selectedDestination);
                    MainViewModel.SaveData();
                    EnableDeleteButton = false;
                }
            }
            // TODO: Show Notification
        }
Beispiel #5
0
        private async void DeleteBachup(object parameter)
        {
            if (!BachupItem.RunningBachup)
            {
                string message    = String.Format("Delete {0}", _bachupItem.Name);
                string submessage = String.Format("This is not reversable. You will lose this bachup item and its history. Source files will remain in place.");

                var view = new ConfirmChoiceView
                {
                    DataContext = new ConfirmChoiceViewModel(message, submessage)
                };

                var choice = await DialogHost.Show(view, "RootDialog");

                if ((bool)choice == true)
                {
                    BachupGroup bg = Bachup.ViewModel.MainViewModel.Bachup.Where(o => o.ID.Equals(_bachupItem.BachupGroupID)).Single();
                    bg.RemoveBachupItem(_bachupItem);
                    MainViewModel.SaveData();
                }
            }

            // TODO: Show Notification
        }
Beispiel #6
0
        internal async Task <bool> CheckDestinationsConnection(bool promptWithDialogToContinue)
        {
            int missingDestinations = 0;

            foreach (string destination in Destinations)
            {
                if (!System.IO.Directory.Exists(destination))
                {
                    missingDestinations++;
                }
            }


            if (missingDestinations == Destinations.Count())
            {
                var view = new AlertView
                {
                    DataContext = new AlertViewModel("All destinations are missing. Add a destination.")
                };
                await DialogHost.Show(view, "RootDialog");

                return(false);
            }

            if (missingDestinations > 0)
            {
                var view = new ConfirmChoiceView
                {
                    DataContext = new ConfirmChoiceViewModel("Bachup With Missing?",
                                                             "There are destinations missing. You can choose to bachup with connected destinations.")
                };
                return((bool)await DialogHost.Show(view, "RootDialog"));
            }

            int brokenDestinaitons = 0;

            foreach (var tempFile in from string destination in Destinations
                     let tempFile = Path.Combine(destination, "bachup.tmp")
                                    select tempFile)
            {
                try
                {
                    using (FileStream fs = new FileStream(tempFile, FileMode.Create, FileAccess.Write))
                    {
                        fs.WriteByte(0xFF);
                    }

                    if (File.Exists(tempFile))
                    {
                        File.Delete(tempFile);
                    }
                    else
                    {
                        brokenDestinaitons++;
                    }
                }
                catch
                {
                    brokenDestinaitons++;
                }
            }



            if (brokenDestinaitons == Destinations.Count())
            {
                var view = new AlertView
                {
                    DataContext = new AlertViewModel("All destinations are broken. Add a destination.")
                };
                await DialogHost.Show(view, "RootDialog");

                return(false);
            }

            if (brokenDestinaitons > 0)
            {
                var view = new ConfirmChoiceView
                {
                    DataContext = new ConfirmChoiceViewModel("Continue?",
                                                             "There are destinations that have no access. Continue with ones that do?")
                };
                return((bool)await DialogHost.Show(view, "RootDialog"));
            }

            return(true);
        }