Example #1
0
 public BackupDefenition GetBackupByName(string name)
 {
     if (string.IsNullOrEmpty(name))
     {
         return(null);
     }
     if (!Backups.ContainsKey(name))
     {
         return(null);
     }
     return(Backups[name]);
 }
Example #2
0
        public bool AddBackupToXml(BackupDefenition bs)
        {
            if (bs == null)
            {
                return(false);
            }
            if (Backups.ContainsKey(bs.Name))
            {
                MetroMessageBox.Show(Application.OpenForms[0],
                                     "Couldn't save backup! You already defined another backup with this name:" + bs.Name,
                                     "Couldn't save backup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (string.IsNullOrEmpty(bs.Name))
            {
                MetroMessageBox.Show(Application.OpenForms[0],
                                     "Couldn't save backup! You didn't enter a name for this backup!",
                                     "Couldn't save backup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            try
            {
                string content = "<backup name=\"" + bs.Name + "\">" +
                                 "	<folders>"+ StringUtil.ListToCsv(bs.Folders, ';') + "</folders>" +
                                 "	<destination>"+ bs.TargetDirectory + "</destination>" +
                                 "	<compression>"+ bs.Compression.ToString().ToLower() + "</compression>" +
                                 "</backup>";
                _backupXml.FirstChild.InnerXml += content;

                _backupXml.Save(_backupXmlPath);

                Backups.Add(bs.Name, bs);
                if (BackupsLoaded != null)
                {
                    BackupsLoaded();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Severe, "Backupmanager", "Severe error in addBackup! " + ex.Message);
                return(false);
            }
            return(true);
        }