Esempio n. 1
0
        public winFolder(string _editId = "")
        {
            InitializeComponent();
            DataContext = this;
            EditId      = _editId;

            //load settings if editing
            if (!string.IsNullOrWhiteSpace(EditId))
            {
                try
                {
                    FolderHelper helper = new FolderHelper();
                    FolderBackup backup = helper.GetConfig(EditId);
                    if (backup == null)
                    {
                        MessageBox.Show("Settings were not found.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    FolderName     = backup.FolderName;
                    BackupIsActive = backup.IsActive;
                    BackupTime     = backup.BackupTime;
                }
                catch (Exception ex)
                {
                    string message = Functions.GetErrorFromException(ex);
                    MessageBox.Show("A problem occurred while loading backup details.\n" + message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 2
0
 public bool AddConfig(FolderBackup backup)
 {
     try
     {
         List <FolderBackup> existingList = GetConfigList() ?? new List <FolderBackup>();
         existingList.Add(backup);
         string configFile = Path.Combine(EnVar.AppWorkingPath, configFileName);
         File.WriteAllText(configFile, JsonConvert.SerializeObject(existingList));
         return(true);
     }
     catch //(Exception ex)
     {
         return(false);
     }
 }
Esempio n. 3
0
 public FolderBackupViewModel(FolderBackup folderBackup)
 {
     this.FolderBackup = folderBackup;
 }