Esempio n. 1
0
        private void RetrieveRecursive(IshFolder ishFolder, int currentDepth, int maxDepth)
        {
            // put them on the pipeline depth-first-traversel
            string folderName = ishFolder.IshFields.GetFieldValue("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value);

            WriteVerbose(new string('>', currentDepth) + IshSession.FolderPathSeparator + folderName + IshSession.FolderPathSeparator);
            WriteObject(IshSession, ISHType, ishFolder, true);

            if (currentDepth < (maxDepth - 1))
            {
                WriteDebug($"RetrieveRecursive IshFolderRef[{ishFolder.IshFolderRef}] folderName[{folderName}] ({currentDepth}<{maxDepth})");
                string xmlIshFolders = IshSession.Folder25.GetSubFoldersByIshFolderRef(ishFolder.IshFolderRef);
                // GetSubFolders contains ishfolder for the parent folder + ishfolder inside for the subfolders
                IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder/ishfolder");
                if (retrievedFolders.Ids.Length > 0)
                {
                    // Add the required fields (needed for pipe operations)
                    xmlIshFolders    = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(retrievedFolders.Ids, _requestedMetadata.ToXml());
                    retrievedFolders = new IshFolders(xmlIshFolders);
                    // sort them
                    ++currentDepth;
                    IshFolder[] sortedFolders = retrievedFolders.SortedFolders;
                    WriteParentProgress("Recursive folder retrieve...", _parentCurrent, _parentTotal + sortedFolders.Count());
                    foreach (IshFolder retrievedIshFolder in sortedFolders)
                    {
                        WriteParentProgress("Recursive folder retrieve...", ++_parentCurrent, _parentTotal);
                        RetrieveRecursive(retrievedIshFolder, currentDepth, maxDepth);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Recursive delete of folder, expects folders to be empty
        /// </summary>
        /// <param name="ishFolder"></param>
        /// <param name="currentDepth"></param>
        private void DeleteRecursive(IshFolder ishFolder, int currentDepth)
        {
            string folderName = ishFolder.IshFields.GetFieldValue("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value);

            WriteVerbose(new string('>', currentDepth) + IshSession.FolderPathSeparator + folderName + IshSession.FolderPathSeparator);

            WriteDebug($"DeleteRecursive IshFolderRef[{ishFolder.IshFolderRef}] folderName[{folderName}] ({currentDepth}/{int.MaxValue})");
            string xmlIshFolders = IshSession.Folder25.GetSubFoldersByIshFolderRef(ishFolder.IshFolderRef);
            // GetSubFolders contains ishfolder for the parent folder + ishfolder inside for the subfolders
            IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder/ishfolder");

            if (retrievedFolders.Ids.Length > 0)
            {
                IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(), Enumerations.ActionMode.Read);
                xmlIshFolders    = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(retrievedFolders.Ids, requestedMetadata.ToXml());
                retrievedFolders = new IshFolders(xmlIshFolders);
                // sort them
                ++currentDepth;
                IshFolder[] sortedFolders = retrievedFolders.SortedFolders;
                WriteParentProgress("Recursive folder remove...", _parentCurrent, _parentTotal + sortedFolders.Count());
                foreach (IshFolder retrievedIshFolder in sortedFolders)
                {
                    DeleteRecursive(retrievedIshFolder, currentDepth);
                }
            }
            WriteParentProgress("Recursive folder remove...", ++_parentCurrent, _parentTotal);
            if (ShouldProcess(Convert.ToString(ishFolder.IshFolderRef)))
            {
                IshSession.Folder25.Delete(ishFolder.IshFolderRef);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Convert a BaseFolder enumeration value into a base folder label
        /// </summary>
        /// <param name="ishSession">Client session object to the InfoShare server instance. Keeps track of your security tokens and provide you clients to the various API end points. Holds matching contract parameters like separators, batch and chunk sizes.</param>
        /// <param name="baseFolder">BaseFolder enumeration value</param>
        /// <returns>base folder label</returns>
        internal virtual string BaseFolderEnumToLabel(IshSession ishSession, Folder25ServiceReference.BaseFolder baseFolder)
        {
            IshFields requestedMetadata = new IshFields();

            requestedMetadata.AddField(new IshRequestedMetadataField("FNAME", Enumerations.Level.None, Enumerations.ValueType.All));
            string xmlIshFolder = ishSession.Folder25.GetMetadata(
                baseFolder,
                new string[] { },  // Use empty folder path so we can just get the basefolder name
                requestedMetadata.ToXml());
            XmlDocument result = new XmlDocument();

            result.LoadXml(xmlIshFolder);
            XmlElement xmlIshFolderElement = (XmlElement)result.SelectSingleNode("ishfolder");
            IshFolder  ishFolder           = new IshFolder(xmlIshFolderElement);

            return(((IshMetadataField)ishFolder.IshFields.RetrieveFirst("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value)).Value);
        }