示例#1
0
        private bool ParseS3Key(string inKey, out Models.EntryType outType, out string outPath, out string outVersion)
        {
            outType = Models.EntryType.FILE_VERSION;
            S3PathBuilder builder = new S3PathBuilder();

            builder.LocalRootDirectory  = this.LocalRootDirectory;
            builder.RemoteRootDirectory = this.RemoteRootDirectory;
            outPath = builder.BuildLocalPath(inKey, out outVersion);
            return(true);
        }
示例#2
0
        private Dictionary <string, BackupPlanTreeNodeData> ExpandCheckedDataSource(
            Dictionary <string, BackupPlanTreeNodeData> dict)
        {
            if (dict == null)
            {
                return(null);
            }

            Dictionary <string, BackupPlanTreeNodeData> expandedDict =
                new Dictionary <string, BackupPlanTreeNodeData>(dict.Count * 2);

            bool hasParents = false;

            // Expand paths into their respective parts.
            foreach (var obj in dict)
            {
                switch (obj.Value.Type)
                {
                default: throw new ArgumentException("Unhandled TypeEnum", "obj.Value.Type");

                case TypeEnum.FILE_VERSION:
                case TypeEnum.FILE:
                case TypeEnum.FOLDER:
                    hasParents = true;
                    break;

                case TypeEnum.DRIVE:
                    hasParents = false;
                    break;
                }

                if (obj.Value.InfoObject == null)
                {
                    obj.Value.InfoObject = new EntryInfo(obj.Value.Type, obj.Value.Name, obj.Value.Path, obj.Value.Version);
                }

                string nodeKey = BuildNodeKey(obj.Value, obj.Value.Version);
                if (!expandedDict.ContainsKey(nodeKey))
                {
                    expandedDict.Add(nodeKey, obj.Value);

                    if (hasParents)
                    {
                        if (obj.Value.Type == TypeEnum.FILE_VERSION)
                        {
                            ExpandCheckedDataSourceFileVersionNode(expandedDict, obj.Value);
                        }
                        ExpandCheckedDataSourceAddParents(expandedDict, obj.Value.Path);
                    }
                }
            }

            // Load all respective `BackupPlanPathNode`s.
            foreach (var obj in expandedDict)
            {
                BackupPlanTreeNodeData nodeData = obj.Value;
                if (nodeData.UserObject == null)
                {
                    Models.EntryType nodeType = Models.EntryTypeExtensions.ToEntryType(nodeData.Type);
                    if (nodeData.Type == TypeEnum.FILE_VERSION)
                    {
                        nodeType = Models.EntryType.FILE;
                    }
                    BackupPlanPathNodeRepository daoPathNode = new BackupPlanPathNodeRepository();
                    nodeData.UserObject = daoPathNode.GetByStorageAccountAndTypeAndPath(StorageAccount, nodeType, nodeData.Path);
                }
            }

            return(expandedDict);
        }