Esempio n. 1
0
		private void BtnOk_Click(Object sender, EventArgs e)
		{
			Defenition = new BackupDefenition {Name = TxtName.Text};
			foreach (string dir in TxtFolders.Text.Split(';'))
			{
				Defenition.AddFolder(dir);
			}
			Defenition.TargetDirectory = TxtDestination.Text;
			Defenition.Compression = ChkCompression.Checked;
			DialogResult = DialogResult.OK;
			Close();
		}
Esempio n. 2
0
 private void BtnOk_Click(Object sender, EventArgs e)
 {
     Defenition = new BackupDefenition {
         Name = TxtName.Text
     };
     foreach (string dir in TxtFolders.Text.Split(';'))
     {
         Defenition.AddFolder(dir);
     }
     Defenition.TargetDirectory = TxtDestination.Text;
     Defenition.Compression     = ChkCompression.Checked;
     DialogResult = DialogResult.OK;
     Close();
 }
Esempio n. 3
0
        /// <summary>
        ///     Load all folders and files from the xml defenition
        /// </summary>
        /// <param name="xmle">The xml element defining the backup</param>
        /// <returns>Returns the backup defenition</returns>
        public static BackupDefenition LoadXml(XmlElement xmle)
        {
            if (xmle != null)
            {
                BackupDefenition bd = new BackupDefenition();
                try
                {
                    bd.Name = xmle.GetAttribute("name");

                    XmlElement foldersElement = (XmlElement)xmle.GetElementsByTagName("folders")[0];
                    foreach (string folder in foldersElement.InnerText.Split(';'))
                    {
                        string entry = folder.Trim(';').Trim();
                        if (Directory.Exists(entry))
                        {
                            bd.AddFolder(entry);
                        }
                        if (File.Exists(entry))
                        {
                            bd.AddFile(entry);
                        }
                    }

                    XmlElement destinationE = (XmlElement)xmle.GetElementsByTagName("destination")[0];
                    bd.TargetDirectory = destinationE.InnerText;

                    XmlElement compressionE = (XmlElement)xmle.GetElementsByTagName("compression")[0];
                    bd.Compression = (compressionE.InnerText.ToLower() == "true");

                    Logger.Log(LogLevel.Info, "Backupmanager", "Loaded backup:" + bd.Name + " :Backup enabled");
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Warning, "Backupmanager", "Could not load backup:" + ex.Message);
                    return(null);
                }
                return(bd);
            }
            Logger.Log(LogLevel.Warning, "Backupmanager", "Skipped backup! Wrong XML");
            MetroMessageBox.Show(Application.OpenForms[0],
                                 Locale.Tr(
                                     "One of your backup profiles wasn't loaded: the file is probably corrupt! The backup profile was removed."),
                                 Locale.Tr("Can't load backup profile"), MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(null);
        }
Esempio n. 4
0
		/// <summary>
		///     Load all folders and files from the xml defenition
		/// </summary>
		/// <param name="xmle">The xml element defining the backup</param>
		/// <returns>Returns the backup defenition</returns>
		public static BackupDefenition LoadXml(XmlElement xmle)
		{
			if (xmle != null)
			{
				BackupDefenition bd = new BackupDefenition();
				try
				{
					bd.Name = xmle.GetAttribute("name");

					XmlElement foldersElement = (XmlElement) xmle.GetElementsByTagName("folders")[0];
					foreach (string folder in foldersElement.InnerText.Split(';'))
					{
						string entry = folder.Trim(';').Trim();
						if (Directory.Exists(entry)) bd.AddFolder(entry);
						if (File.Exists(entry)) bd.AddFile(entry);
					}

					XmlElement destinationE = (XmlElement) xmle.GetElementsByTagName("destination")[0];
					bd.TargetDirectory = destinationE.InnerText;

					XmlElement compressionE = (XmlElement) xmle.GetElementsByTagName("compression")[0];
					bd.Compression = (compressionE.InnerText.ToLower() == "true");

					Logger.Log(LogLevel.Info, "Backupmanager", "Loaded backup:" + bd.Name + " :Backup enabled");
				}
				catch (Exception ex)
				{
					Logger.Log(LogLevel.Warning, "Backupmanager", "Could not load backup:" + ex.Message);
					return null;
				}
				return bd;
			}
			Logger.Log(LogLevel.Warning, "Backupmanager", "Skipped backup! Wrong XML");
			MetroMessageBox.Show(Application.OpenForms[0],
				Locale.Tr(
					"One of your backup profiles wasn't loaded: the file is probably corrupt! The backup profile was removed."),
				Locale.Tr("Can't load backup profile"), MessageBoxButtons.OK, MessageBoxIcon.Error);
			return null;
		}