Пример #1
0
        /// <summary>
        /// Set all project data from an specified XElement which parsed an XML formated string
        /// </summary>
        /// <param name="inputProject">Specifies XElement XElement which parsed an XML formated string which represents the project</param>
        internal bool Project_FromXMLString(XElement inputProject)
        {
            try
            {
                this._restrainChangedEvent = true;

                this._toBackupDirectorys.Clear();
                this._toBackupFiles.Clear();

                //Check Fileversion
                if (!this.Project_FromXMLString_CheckVersion(inputProject.Attribute("Version").Value))
                {
                    return(false);
                }
                //Read Directorys
                foreach (XElement DirectoryItem in inputProject.Element(XML_DIRECTORYS_ELEMENT_NAME).Elements(XML_DIRECTORY_ITEM_NAME))
                {
                    string         DirectoryPath  = DirectoryItem.Element(XML_DIRECTORY_ITEM_PATH_NAME).Value;
                    DirectoryScope DirectoryScope = (DirectoryScope)Convert.ToInt32(DirectoryItem.Element(XML_DIRECTORY_ITEM_SCOPE_NAME).Value);
                    this.DirectoryAdd(DirectoryPath, DirectoryScope);
                    //Read Files
                    foreach (XElement FileItem in DirectoryItem.Element(XML_FILES_ELEMENT_NAME).Elements())
                    {
                        string FilePath = FileItem.Element(XML_FILE_ITEM_PATH_NAME).Value;
                        this.FileAdd(DirectoryPath, FilePath);
                    }
                }

                //Read Settings
                this._settings.RestrainChangedEvent = true;
                XElement Settings = inputProject.Element(XML_FILE_SETTINGS_NODE);
                {
                    XElement Common = Settings.Element("Common");
                    {
                        XElement ExistringFiles = Common.Element("ExistringFiles");
                        {
                            this._settings.Common.ExisitingFiles.AddTextToExistingFile = (string)ExistringFiles.Element("AddTextToExistingFile");
                            this._settings.Common.ExisitingFiles.HandleExistingItem    = (HandleExistingFiles.HowToHandleExistingItem)(int) ExistringFiles.Element("HandleExistingItem");
                        }
                    }
                    XElement ControleBackup = Settings.Element("ControleBackup");
                    {
                        XElement Action = ControleBackup.Element("Action");
                        {
                            this._settings.ControleBackup.Action.CopyData           = (bool)Action.Element("CopyData");
                            this._settings.ControleBackup.Action.CountItemsAndBytes = (bool)Action.Element("CountItemsAndBytes");
                            this._settings.ControleBackup.Action.DeleteOldData      = Serialize.GetFromXElement(Action, "DeleteOldData", false);
                        }
                        XElement Directory = ControleBackup.Element("Directory");
                        {
                            this._settings.ControleBackup.Directory.CreateDriveDirectroy = (bool)Directory.Element("CreateDriveDirectroy");
                            this._settings.ControleBackup.Directory.Path = (string)Directory.Element("Path");
                        }
                        XElement Logfile = ControleBackup.Element("Logfile");
                        {
                            this._settings.ControleBackup.Logfile.AutoPath = (bool)Logfile.Element("AutoPath");
                            this._settings.ControleBackup.Logfile.Create   = (bool)Logfile.Element("Create");
                            this._settings.ControleBackup.Logfile.Path     = (string)Logfile.Element("Path");
                        }
                    }
                    XElement ControleRestore = Settings.Element("ControleRestore");
                    {
                        XElement Action = ControleRestore.Element("Action");
                        {
                            this._settings.ControleRestore.Action.CopyData           = (bool)Action.Element("CopyData");
                            this._settings.ControleRestore.Action.CountItemsAndBytes = (bool)Action.Element("CountItemsAndBytes");
                        }
                        XElement Directory = ControleRestore.Element("Directory");
                        {
                            this._settings.ControleRestore.Directory.CreateDriveDirectroy = (bool)Directory.Element("CreateDriveDirectroy");
                            this._settings.ControleRestore.Directory.Path = (string)Directory.Element("Path");
                            this._settings.ControleRestore.Directory.RestoreTargetPath = (string)Directory.Element("RestoreTargetPath");
                        }
                        XElement Logfile = ControleRestore.Element("Logfile");
                        {
                            this._settings.ControleRestore.Logfile.AutoPath = (bool)Logfile.Element("AutoPath");
                            this._settings.ControleRestore.Logfile.Create   = (bool)Logfile.Element("Create");
                            this._settings.ControleRestore.Logfile.Path     = (string)Logfile.Element("Path");
                        }
                    }
                }
                this._changed = false;
                this._settings.RestrainChangedEvent = false;
                this._restrainChangedEvent          = false;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Stringtable._0x001Fm, new object[] { ex.Message }), Stringtable._0x001Fc, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }