Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
		}