Exemple #1
0
        public void PopulateDrives()
        {
            if (StorageAccount == null)
            {
                return;
            }

            BackupPlanPathNodeRepository dao = new BackupPlanPathNodeRepository();

            try
            {
                //IFileVersion version = BuildVersion(Plan);
                IList <Models.BackupPlanPathNode> drives = dao.GetAllDrivesByStorageAccount(StorageAccount);

                foreach (var drive in drives)
                {
                    //EntryInfo info = new EntryInfo(TypeEnum.DRIVE, drive.Name, drive.Name, version);
                    BackupPlanTreeNode driveNode = BackupPlanTreeNode.CreateDriveNode(drive);
                    this.Nodes.Add(driveNode);
                    RestoreNodeState(driveNode);
                }
            }
            catch (System.SystemException e)
            {
                ShowErrorMessage(e, null);
            }
        }
Exemple #2
0
        // May throw System.SystemException
        private void PopulateFile(BackupPlanPathNode pathNode)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);

#if true
            BackupedFileRepository     dao           = new BackupedFileRepository();
            IList <BackupedFile>       backupedFiles = dao.GetCompletedByStorageAccountAndPath(pathNode.StorageAccount, pathNode.Path);
            IEnumerable <IFileVersion> versions      =
                from f in backupedFiles
                select new FileVersion {
                Name = f.VersionName, Version = f.Version
            };
#else
            // *** DO NOT USE THIS APPROACH BECAUSE IT WILL NOT SHOW A BACKUP VERSION THAT HAS JUST BEEN CREATED! ***
            // I know it's a problem related to the NHibernate caching mechanism, but I don't want to deal with it right now. Sorry! :-)
            IList <BackupedFile>       backupedFiles = pathNode.PlanFile.Versions;
            IEnumerable <IFileVersion> versions      =
                from f in backupedFiles
                where f.TransferStatus == Storage.TransferStatus.COMPLETED
                select new FileVersion {
                Name = f.Backup.VersionName, Version = f.Backup.Version
            };
#endif
            foreach (IFileVersion version in versions)
            {
                BackupPlanTreeNode versionNode = AddFileVersionNode(pathNode, version);
            }
        }
Exemple #3
0
        private void RestoreNodeStateRemove(BackupPlanTreeNode node)
        {
            if (CheckedDataSource == null)
            {
                return;
            }
            if (node.Data == null)
            {
                return;
            }

            if (node.Data.Type != TypeEnum.LOADING)
            {
#if false
                string path = node.Data.Path;
                if (CheckedDataSource.ContainsKey(path))
                {
                    CheckedDataSource.Remove(path);
                }
#else
                string nodeKey = BuildNodeKey(node.Data, node.Data.Version);
                if (CheckedDataSource.ContainsKey(nodeKey))
                {
                    CheckedDataSource.Remove(nodeKey);
                }
#endif
            }
        }
Exemple #4
0
        // May throw System.SystemException
        private void PopuplateDirectory(BackupPlanPathNode pathNode)
        {
            //Assert.AreEqual(EntryType.FOLDER, pathNode.Type);
            if (pathNode.Type != EntryType.DRIVE && pathNode.Type != EntryType.FOLDER)
            {
                throw new ArgumentException("Unexpected EntryType", "pathNode.Type");
            }

            foreach (var subNode in pathNode.SubNodes)
            {
                if (subNode.Type != EntryType.FOLDER)
                {
                    continue;
                }
                BackupPlanTreeNode subFolderNode = AddFolderNode(subNode);
            }
            foreach (var subNode in pathNode.SubNodes)
            {
                if (subNode.Type != EntryType.FILE)
                {
                    continue;
                }
                BackupPlanTreeNode subFolderNode = AddFileNode(subNode);
            }
        }
Exemple #5
0
        private TreeNode AddLazyLoadingNode()
        {
            BackupPlanTreeNode node = BackupPlanTreeNode.CreateLoadingNode();

            Nodes.Add(node);
            return(node);
        }
Exemple #6
0
        public static BackupPlanTreeNode CreateLoadingNode()
        {
            BackupPlanTreeNode node = new BackupPlanTreeNode("Retrieving data...", 0, 0);

            node.Data.Type = TypeEnum.LOADING;
            node.ImageKey  = "loading";
            return(node);
        }
Exemple #7
0
        private BackupPlanTreeNode AddFileVersionNode(BackupPlanPathNode pathNode, IFileVersion version)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);
            BackupPlanTreeNode node = BackupPlanTreeNode.CreateFileVersionNode(pathNode, version);

            Nodes.Add(node);
            return(node);
        }
Exemple #8
0
        private BackupPlanTreeNode AddFolderNode(BackupPlanPathNode pathNode)
        {
            Assert.AreEqual(EntryType.FOLDER, pathNode.Type);
            BackupPlanTreeNode node = BackupPlanTreeNode.CreateFolderNode(pathNode);

            Nodes.Add(node);
            return(node);
        }
Exemple #9
0
        private BackupPlanTreeNode AddDriveNode(TreeView view, BackupPlanPathNode pathNode)
        {
            Assert.AreEqual(EntryType.DRIVE, pathNode.Type);
            BackupPlanTreeNode node = BackupPlanTreeNode.CreateDriveNode(pathNode);

            view.Nodes.Add(node);
            return(node);
        }
Exemple #10
0
        protected override void CheckNode(System.Windows.Forms.TreeNode node, Teltec.Common.Controls.CheckState state)
        {
            base.CheckNode(node, state);

            BackupPlanTreeNode realNode = node as BackupPlanTreeNode;

            // Disallow checking multiple versions of the same file.
            if (realNode.Data.Type == TypeEnum.FILE_VERSION)
            {
                base.UncheckNodeSiblings(node);
            }
        }
Exemple #11
0
        private void BuildTagDataDict(BackupPlanTreeNode node, Dictionary <string, BackupPlanTreeNodeData> dict)
        {
            // Skip over loading nodes and nodes without a tag.
            if (node == null || node.Data.Type == TypeEnum.LOADING)
            {
                return;
            }

            CheckState state = GetCheckState(node);

            switch (state)
            {
            case CheckState.Unchecked:
                // If it's unchecked, ignore it and its child nodes.
                return;

            case CheckState.Checked:
                // If it's checked, add it and ignore its child nodes.
                // This means the entire folder was checked - regardless of what it contains - or
                // the file itself was checked, and not a specific version.
                if (CheckedDataSource != null)
                {
                    string path = node.Data.Path;
                    BackupPlanTreeNodeData match;
                    bool found = dict.TryGetValue(path, out match);
                    match       = found ? match : node.Data;
                    match.State = CheckState.Checked;
                    node.Data   = match;
                    if (!dict.ContainsKey(match.Path))
                    {
                        dict.Add(match.Path, match);
                    }
                }
                else
                {
                    BackupPlanTreeNodeData tag = node.Data;
                    tag.State = CheckState.Checked;
                    if (!dict.ContainsKey(tag.Path))
                    {
                        dict.Add(tag.Path, tag);
                    }
                }
                break;

            case CheckState.Mixed:
                // Ignore it, but verify its child nodes.
                foreach (BackupPlanTreeNode child in node.Nodes)
                {
                    BuildTagDataDict(child, dict);
                }
                break;
            }
        }
Exemple #12
0
        public static BackupPlanTreeNode CreateFileVersionNode(BackupPlanPathNode pathNode, IFileVersion version)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);
            BackupPlanTreeNode node = new BackupPlanTreeNode(version.Name, 0, 0);

            node.ImageKey = "file_version";
            EntryInfo info = new EntryInfo(TypeEnum.FILE_VERSION, pathNode.Name, pathNode.Path, version);

            node.Data.InfoObject = info;
            node.Data.UserObject = pathNode;
            return(node);
        }
Exemple #13
0
        public static BackupPlanTreeNode CreateFileNode(BackupPlanPathNode pathNode)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);
            BackupPlanTreeNode node = new BackupPlanTreeNode(pathNode.Name, 0, 0);

            node.ImageKey = "file";
            EntryInfo info = new EntryInfo(TypeEnum.FILE, pathNode.Name, pathNode.Path);

            node.Data.InfoObject = info;
            node.Data.UserObject = pathNode;
            node.AddLazyLoadingNode();
            return(node);
        }
Exemple #14
0
        private void RemoveLazyLoadingNode()
        {
            BackupPlanTreeNode node = FirstNode as BackupPlanTreeNode;

            if (node == null)
            {
                return;
            }

            if (node.Data.Type == TypeEnum.LOADING)
            {
                node.Remove();
            }
        }
Exemple #15
0
        private void RestoreNodeStateRecursively(BackupPlanTreeNode node)
        {
            //if (GetCheckState(parentNode) == CheckState.Checked)
            //{
            //	//SetCheckState(node, CheckState.Checked);
            //}
            //else
            //{
            RestoreNodeState(node);
            //}

            foreach (BackupPlanTreeNode subNode in node.Nodes)
            {
                RestoreNodeStateRecursively(subNode);
            }
        }
Exemple #16
0
        private void RestoreNodeState(BackupPlanTreeNode node)
        {
            if (CheckedDataSource == null)
            {
                return;
            }

            switch (node.Data.Type)
            {
            default:
                throw new ArgumentException("Unhandled TypeEnum", "node.Data.Type");

            case TypeEnum.LOADING:
                // Ignore this node.
                break;

            case TypeEnum.DRIVE:
            case TypeEnum.FOLDER:
            case TypeEnum.FILE:
            case TypeEnum.FILE_VERSION:
            {
                string path = node.Data.Path;
                BackupPlanTreeNodeData match;
                bool found = CheckedDataSource.TryGetValue(BuildNodeKey(node.Data, node.Data.Version), out match);
                if (found)
                {
                    //node.Data = match;
                    if (match.Type == node.Data.Type)
                    {
                        SetStateImage(node, (int)match.State);
                    }
                }
                break;
            }
            }
        }