Пример #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);
                    }
                }
            }
        }
Пример #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);
            }
        }
Пример #3
0
        /// <summary>
        /// Process the Move-IshFolder commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshFolder"/> array to the pipeline</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");
                long folderId   = FolderId;
                long toFolderId = ToFolderId;

                // Folder Ids to retrieve added folder(s)
                List <long>      foldersToRetrieve = new List <long>();
                List <IshFolder> returnedFolders   = new List <IshFolder>();

                if (IshFolders != null && IshFolders.Length == 0)
                {
                    // Do nothing
                    WriteVerbose("IshFolders is empty, so nothing to move");
                    WriteVerbose("IshFolders is empty, so nothing to retrieve");
                }
                else
                {
                    if (IshFolders != null)
                    {
                        WriteDebug("Moving");

                        // 2b. Move using IshFolder[] pipeline.
                        IshFolder[] ishFolders = IshFolders;

                        int current = 0;
                        foreach (IshFolder ishFolder in ishFolders)
                        {
                            // read "folderRef" from the ishFolder object
                            folderId = ishFolder.IshFolderRef;
                            WriteDebug($"folderId[{folderId}] ToFolderId[{toFolderId}] {++current}/{ishFolders.Length}");
                            if (ShouldProcess(Convert.ToString(folderId)))
                            {
                                IshSession.Folder25.Move(folderId, toFolderId);
                                foldersToRetrieve.Add(folderId);
                            }
                        }
                    }
                    else
                    {
                        // 2a. Set using provided parameters (not piped IshFolder)
                        WriteDebug($"folderId[{folderId}] ToFolderId[{toFolderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Move(folderId, toFolderId);
                            foldersToRetrieve.Add(folderId);
                        }
                    }

                    // 3a. Retrieve moved folder(s) from the database and write it out
                    WriteDebug("Retrieving");

                    // Add the required fields (needed for pipe operations)
                    IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(), Enumerations.ActionMode.Read);
                    string    xmlIshFolders     = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(foldersToRetrieve.ToArray(), requestedMetadata.ToXml());

                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders);
                    returnedFolders.AddRange(retrievedFolders.Folders);
                }

                WriteVerbose("returned object count[" + returnedFolders.Count + "]");
                WriteObject(returnedFolders, true);
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
        /// <summary>
        /// Process the Get-IshFolderLocation commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes FolderPath string to the pipeline.</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");
                List <long> returnFolderIds = new List <long>();

                if (IshFolder != null)
                {
                    // 1a. Retrieve using IshFolder object
                    foreach (IshFolder ishFolder in IshFolder)
                    {
                        returnFolderIds.Add(ishFolder.IshFolderRef);
                    }
                }
                else if (FolderId != 0)
                {
                    // 1b. Retrieve using FolderId
                    WriteDebug($"folderId[{FolderId}]");
                    returnFolderIds.Add(FolderId);
                }
                else if (FolderPath != null)
                {
                    // 1c. Retrieve using provided parameter FolderPath
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        "");
                    IshFolders ishFolder = new IshFolders(xmlIshFolder, "ishfolder");
                    returnFolderIds.Add(ishFolder.Folders[0].IshFolderRef);
                }
                else
                {
                    // 1d. Retrieve subfolder(s) from the specified root folder using BaseFolder string (enumeration)
                    var    baseFolder    = EnumConverter.ToBaseFolder <Folder25ServiceReference.BaseFolder>(BaseFolder);
                    string xmlIshFolders = IshSession.Folder25.GetMetadata(
                        baseFolder,
                        new string[0],
                        "");
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder");
                    returnFolderIds.Add(retrievedFolders.Folders[0].IshFolderRef);
                }

                WriteDebug("Retrieving FolderLocation");
                int current = 0;
                foreach (long returnFolderId in returnFolderIds)
                {
                    WriteDebug($"folderId[{returnFolderId}] {++current}/{returnFolderIds.Count}");
                    var response = IshSession.Folder25.FolderLocation(new Folder25ServiceReference.FolderLocationRequest(returnFolderId));
                    // Using basefolder name and folderPaths array make a full folder path
                    var folderPaths = new List <string>()
                    {
                        BaseFolderEnumToLabel(IshSession, response.baseFolder)
                    };
                    folderPaths.AddRange(response.folderPath);
                    WriteObject(IshSession.FolderPathSeparator + string.Join(IshSession.FolderPathSeparator, folderPaths), true);
                }

                WriteVerbose("returned folderlocation count[" + returnFolderIds.Count + "]");
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Пример #5
0
        /// <summary>
        /// Process the Remove-IshFolder commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                // 2. Doing Remove
                WriteDebug("Removing");
                if (IshFolder != null)
                {
                    long folderId;
                    // 2a. Remove using IshFolder[] pipeline
                    IshFolder[] ishFolders = IshFolder;
                    int         current    = 0;
                    foreach (IshFolder ishFolder in ishFolders)
                    {
                        // read "folderRef" from the ishFolder object
                        folderId = ishFolder.IshFolderRef;
                        WriteDebug($"folderId[{folderId}] {++current}/{ishFolders.Length}");
                        if (!Recurse)
                        {
                            if (ShouldProcess(Convert.ToString(folderId)))
                            {
                                IshSession.Folder25.Delete(folderId);
                            }
                        }
                        else
                        {
                            DeleteRecursive(ishFolder, 0);
                        }
                    }
                }
                else if (FolderId != 0)
                {
                    // 2b. Remove using provided parameters (not piped IshFolder)
                    long folderId = FolderId;
                    WriteDebug($"folderId[{folderId}]");
                    if (!Recurse)
                    {
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Delete(folderId);
                        }
                    }
                    else
                    {
                        IshFields  requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(), Enumerations.ActionMode.Read);
                        string     xmlIshFolder      = IshSession.Folder25.GetMetadataByIshFolderRef(folderId, requestedMetadata.ToXml());
                        IshFolders ishFolders        = new IshFolders(xmlIshFolder, "ishfolder");
                        DeleteRecursive(ishFolders.Folders[0], 0);
                    }
                }
                else if (FolderPath != null)
                {
                    // 2c. Retrieve using provided parameter FolderPath
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        "");
                    IshFolders ishFolder = new IshFolders(xmlIshFolder, "ishfolder");
                    long       folderId  = ishFolder.Folders[0].IshFolderRef;
                    if (!Recurse)
                    {
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Delete(folderId);
                        }
                    }
                    else
                    {
                        WriteParentProgress("Recursive folder remove...", _parentCurrent, 1);
                        DeleteRecursive(ishFolder.Folders[0], 0);
                    }
                }
                else
                {
                    WriteDebug("How did you get here? Probably provided  too little parameters.");
                }
                WriteVerbose("returned object count[0]");
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Пример #6
0
        /// <summary>
        /// Process the Get-IshFolderContent commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshObject"/> array to the pipeline</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");
                List <long> returnFolderIds = new List <long>();

                if (IshFolder != null)
                {
                    // 1a. Retrieve using IshFolder object
                    foreach (IshFolder ishFolder in IshFolder)
                    {
                        returnFolderIds.Add(ishFolder.IshFolderRef);
                    }
                }
                else if (FolderId != 0)
                {
                    // 1b. Retrieve using FolderId
                    WriteDebug($"folderId[{FolderId}]");
                    returnFolderIds.Add(FolderId);
                }
                else if (FolderPath != null)
                {
                    // 1c. Retrieve using provided parameter FolderPath
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        "");
                    IshFolders ishFolder = new IshFolders(xmlIshFolder, "ishfolder");
                    returnFolderIds.Add(ishFolder.Folders[0].IshFolderRef);
                }
                else
                {
                    // 1d. Retrieve subfolder(s) from the specified root folder using BaseFolder string (enumeration)
                    var    baseFolder    = EnumConverter.ToBaseFolder <Folder25ServiceReference.BaseFolder>(BaseFolder);
                    string xmlIshFolders = IshSession.Folder25.GetMetadata(
                        baseFolder,
                        new string[0],
                        "");
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder");
                    returnFolderIds.Add(retrievedFolders.Folders[0].IshFolderRef);
                }

                List <IshObject> returnIshObjects = new List <IshObject>();
                int current = 0;
                foreach (long returnFolderId in returnFolderIds)
                {
                    // 2. Doing Retrieve
                    WriteDebug($"folderId[{returnFolderId}] {++current}/{returnFolderIds.Count}");
                    string xmlIshObjects = IshSession.Folder25.GetContents(returnFolderId);
                    var    ishObjects    = new IshObjects(xmlIshObjects);

                    WriteDebug("Retrieving Language Objects");
                    if (ishObjects.Ids.Length > 0)
                    {
                        // First handle all documents/illustrations
                        var documentLogicalIds = ishObjects.Objects
                                                 .Where(ishObject => ishObject.IshType != Enumerations.ISHType.ISHPublication)
                                                 .Select(ishObject => ishObject.IshRef)
                                                 .ToList();
                        if (documentLogicalIds.Any())
                        {
                            Enumerations.ISHType[] ISHDocumentTypes = { Enumerations.ISHType.ISHIllustration, Enumerations.ISHType.ISHLibrary, Enumerations.ISHType.ISHMasterDoc, Enumerations.ISHType.ISHModule, Enumerations.ISHType.ISHTemplate };
                            IshFields requestedMetadata             = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHDocumentTypes, new IshFields(), Enumerations.ActionMode.Read);

                            xmlIshObjects = IshSession.DocumentObj25.RetrieveLanguageMetadata(documentLogicalIds.ToArray(),
                                                                                              VersionFilter, LanguagesFilter,
                                                                                              new string[0], DocumentObj25ServiceReference.StatusFilter.ISHNoStatusFilter, requestedMetadata.ToXml());
                            var documentIshObjects = new IshObjects(xmlIshObjects);
                            returnIshObjects.AddRange(documentIshObjects.Objects);
                        }

                        // Handle all publications
                        var publicationLogicalIds =
                            ishObjects.Objects
                            .Where(ishObject => ishObject.IshType == Enumerations.ISHType.ISHPublication)
                            .Select(ishObject => ishObject.IshRef)
                            .ToList();
                        if (publicationLogicalIds.Any())
                        {
                            Enumerations.ISHType[] ISHPublicationTypes = { Enumerations.ISHType.ISHPublication };
                            IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHPublicationTypes, new IshFields(), Enumerations.ActionMode.Read);
                            xmlIshObjects = IshSession.PublicationOutput25.RetrieveVersionMetadata(publicationLogicalIds.ToArray(),
                                                                                                   VersionFilter, "");
                            var publicationIshObjects = new IshObjects(xmlIshObjects);
                            if (publicationIshObjects.Objects.Length > 0)
                            {
                                var metadataFilterFields = new IshFields();
                                if (LanguagesFilter != null && LanguagesFilter.Length > 0)
                                {
                                    metadataFilterFields.AddField(new IshMetadataFilterField("DOC-LANGUAGE", Enumerations.Level.Lng,
                                                                                             Enumerations.FilterOperator.In,
                                                                                             String.Join(IshSession.Seperator, LanguagesFilter),
                                                                                             Enumerations.ValueType.Value));
                                }
                                var versionRefs = publicationIshObjects.Objects
                                                  .Select(ishObject => Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Version]))
                                                  .ToList();
                                xmlIshObjects =
                                    IshSession.PublicationOutput25.RetrieveMetadataByIshVersionRefs(versionRefs.ToArray(),
                                                                                                    PublicationOutput25ServiceReference.StatusFilter.ISHNoStatusFilter, metadataFilterFields.ToXml(),
                                                                                                    requestedMetadata.ToXml());
                                publicationIshObjects = new IshObjects(xmlIshObjects);
                                returnIshObjects.AddRange(publicationIshObjects.Objects);
                            }
                        }
                    }
                }
                WriteVerbose("returned object count[" + returnIshObjects.Count + "]");
                WriteObject(returnIshObjects, true);
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Пример #7
0
        /// <summary>
        /// Process the Get-IshFolder commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshFolder"/> object to the pipeline.</remarks>
        protected override void EndProcessing()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");

                List <IshFolder> returnIshFolders = new List <IshFolder>();

                // 2. Doing Retrieve
                WriteDebug("Retrieving");
                _requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Read);

                if (ParameterSetName == "IshFolderGroup" && _retrievedIshFolders.Count > 0)
                {
                    var folderCardIds = _retrievedIshFolders.Select(ishFolder => Convert.ToInt64(ishFolder.IshFolderRef)).ToList();
                    WriteDebug($"Retrieving CardIds.length[{folderCardIds.Count}] RequestedMetadata.length[{_requestedMetadata.ToXml().Length}] 0/{folderCardIds.Count}");
                    // Devides the list of folder card ids in different lists that all have maximally MetadataBatchSize elements
                    List <List <long> > devidedFolderCardIdsList = DevideListInBatches <long>(folderCardIds, IshSession.MetadataBatchSize);
                    int currentFolderCardIdCount = 0;
                    foreach (List <long> folderCardIdBatch in devidedFolderCardIdsList)
                    {
                        // Process card ids in batches
                        string     xmlIshFolders    = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(folderCardIdBatch.ToArray(), _requestedMetadata.ToXml());
                        IshFolders retrievedObjects = new IshFolders(xmlIshFolders);
                        returnIshFolders.AddRange(retrievedObjects.Folders);
                        currentFolderCardIdCount += folderCardIdBatch.Count;
                        WriteDebug($"Retrieving CardIds.length[{ folderCardIdBatch.Count}] RequestedMetadata.length[{ _requestedMetadata.ToXml().Length}] {currentFolderCardIdCount}/{folderCardIds.Count}");
                    }
                }
                else if (ParameterSetName == "FolderIdGroup" && _retrievedFolderIds.Count > 0)
                {
                    WriteDebug($"Retrieving CardIds.length[{ _retrievedFolderIds.Count}] RequestedMetadata.length[{_requestedMetadata.ToXml().Length}] 0/{_retrievedFolderIds.Count}");
                    // Devides the list of folder card ids in different lists that all have maximally MetadataBatchSize elements
                    List <List <long> > devidedFolderCardIdsList = DevideListInBatches <long>(_retrievedFolderIds, IshSession.MetadataBatchSize);
                    int currentFolderCardIdCount = 0;
                    foreach (List <long> folderCardIdBatch in devidedFolderCardIdsList)
                    {
                        // Process card ids in batches
                        string     xmlIshFolders    = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(folderCardIdBatch.ToArray(), _requestedMetadata.ToXml());
                        IshFolders retrievedObjects = new IshFolders(xmlIshFolders);
                        returnIshFolders.AddRange(retrievedObjects.Folders);
                        currentFolderCardIdCount += folderCardIdBatch.Count;
                        WriteDebug($"Retrieving CardIds.length[{folderCardIdBatch.Count}] RequestedMetadata.length[{_requestedMetadata.ToXml().Length}] {currentFolderCardIdCount}/{_retrievedFolderIds.Count}");
                    }
                }
                else if (ParameterSetName == "FolderPathGroup")
                {
                    // Retrieve using provided parameter FolderPath
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{ folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        _requestedMetadata.ToXml());
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolder, "ishfolder");
                    returnIshFolders.AddRange(retrievedFolders.Folders);
                }
                else if (ParameterSetName == "BaseFolderGroup")
                {
                    // Retrieve using BaseFolder string (enumeration)
                    var baseFolder = EnumConverter.ToBaseFolder <Folder25ServiceReference.BaseFolder>(BaseFolder);

                    WriteDebug($"BaseFolder[{baseFolder}]");
                    string xmlIshFolders = IshSession.Folder25.GetMetadata(
                        baseFolder,
                        new string[0],
                        _requestedMetadata.ToXml());
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder");
                    returnIshFolders.AddRange(retrievedFolders.Folders);
                }

                // 3b. Write it
                if (!Recurse)
                {
                    if (FolderTypeFilter == null)
                    {
                        WriteDebug($"returned object count[{returnIshFolders.Count}]");
                        WriteObject(IshSession, ISHType, returnIshFolders.ConvertAll(x => (IshBaseObject)x), true);
                    }
                    else
                    {
                        List <IshFolder> filteredIshFolders = new List <IshFolder>();
                        foreach (var returnIshFolder in returnIshFolders)
                        {
                            if (FolderTypeFilter.Contains(returnIshFolder.IshFolderType))
                            {
                                filteredIshFolders.Add(returnIshFolder);
                            }
                            else
                            {
                                string folderName = returnIshFolder.IshFields.GetFieldValue("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value);
                                string folderpath = returnIshFolder.IshFields.GetFieldValue("FISHFOLDERPATH", Enumerations.Level.None, Enumerations.ValueType.Value);
                                WriteVerbose(folderpath.Replace(IshSession.Separator, IshSession.FolderPathSeparator) + IshSession.FolderPathSeparator + folderName + " skipped");
                            }
                        }

                        WriteDebug($"returned object count after filtering[{filteredIshFolders.Count}]");
                        WriteObject(IshSession, ISHType, filteredIshFolders.ConvertAll(x => (IshBaseObject)x), true);
                    }
                }
                else
                {
                    WriteParentProgress("Recursive folder retrieve...", 0, returnIshFolders.Count);
                    foreach (IshFolder ishFolder in returnIshFolders)
                    {
                        WriteParentProgress("Recursive folder retrieve...", ++_parentCurrent, returnIshFolders.Count);
                        if (_maxDepth > 0)
                        {
                            RetrieveRecursive(ishFolder, 0, _maxDepth);
                        }
                    }
                }
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
            finally
            {
                base.EndProcessing();
            }
        }
Пример #8
0
        /// <summary>
        /// Process the Add-IshFolder commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshFolder"/> array to the pipeline</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");

                if (FolderType == Enumerations.IshFolderType.ISHQuery ||
                    FolderType == Enumerations.IshFolderType.ISHReference)
                {
                    throw new NotSupportedException("Query and reference folders are not supported");
                }

                List <IshFolder> returnedFolders = new List <IshFolder>();

                if (IshFolder != null && IshFolder.Length == 0)
                {
                    // Do nothing
                    WriteVerbose("IshFolders is empty, so nothing to add");
                    WriteVerbose("IshFolders is empty, so nothing to retrieve");
                }
                else
                {
                    WriteDebug("Adding");

                    List <long> foldersToRetrieve = new List <long>();
                    IshFields   returnFields;

                    // 2a. Add using provided parameters (not piped IshFolder)
                    if (IshFolder != null)
                    {
                        // 2b. Add using IshFolder[] pipeline
                        int current = 0;
                        foreach (IshFolder ishFolder in IshFolder)
                        {
                            // read all info from the ishFolder/ishFields object
                            string   folderName       = ishFolder.IshFields.GetFieldValue("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value);
                            var      folderType       = ishFolder.IshFolderType;
                            string   readAccessString = ishFolder.IshFields.GetFieldValue("READ-ACCESS", Enumerations.Level.None, Enumerations.ValueType.Value);
                            string[] readAccess       = readAccessString.Split(new string[] { IshSession.Separator }, StringSplitOptions.None);
                            string   ownedBy          = ishFolder.IshFields.GetFieldValue("FUSERGROUP", Enumerations.Level.None, Enumerations.ValueType.Value);

                            WriteDebug($"Adding ParentFolderId[{ParentFolderId}] FolderType[{folderType}] FolderName[{folderName}] {++current}/{IshFolder.Length}");
                            if (ShouldProcess(folderName))
                            {
                                var folderId = IshSession.Folder25.Create(
                                    ParentFolderId,
                                    folderName,
                                    ownedBy,
                                    readAccess,
                                    EnumConverter.ToFolderType <Folder25ServiceReference.IshFolderType>(folderType));
                                foldersToRetrieve.Add(folderId);
                            }
                        }
                        returnFields = (IshFolder[0] == null) ? new IshFields() : IshFolder[0].IshFields;
                    }
                    else
                    {
                        string   ownedBy    = OwnedBy ?? "";
                        string[] readAccess = ReadAccess ?? new string[] { };

                        WriteDebug($"Adding ParentFolderId[{ParentFolderId}] FolderType[{FolderType}] FolderName[{FolderName}]");
                        if (ShouldProcess(FolderName))
                        {
                            var folderId = IshSession.Folder25.Create(
                                ParentFolderId,
                                FolderName,
                                ownedBy,
                                readAccess,
                                EnumConverter.ToFolderType <Folder25ServiceReference.IshFolderType>(FolderType));
                            foldersToRetrieve.Add(folderId);
                        }
                        returnFields = new IshFields();
                    }

                    // 3a. Retrieve added folder from the database and write it out
                    WriteDebug("Retrieving");

                    // Add the required fields (needed for pipe operations)
                    IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read);
                    string    xmlIshFolders     = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(foldersToRetrieve.ToArray(), requestedMetadata.ToXml());

                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders);
                    returnedFolders.AddRange(retrievedFolders.Folders);
                }

                // 3b. Write it
                WriteVerbose("returned object count[" + returnedFolders.Count + "]");
                WriteObject(IshSession, ISHType, returnedFolders.ConvertAll(x => (IshBaseObject)x), true);
            }

            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Пример #9
0
        /// <summary>
        /// Process the Set-IshFolder commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshFolder"/> array to the pipeline</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");
                string      xmlIshFolders = "";
                long        folderId      = -5;
                string[]    readAccess;
                string      newFolderName;
                List <long> returnFolderIds = new List <long>();
                if (IshFolder != null)
                {
                    // 1a. read all info from the IshFolder/IshFields object
                    IshFolder[] ishFolders = IshFolder;
                    int         current    = 0;
                    foreach (IshFolder ishFolder in ishFolders)
                    {
                        // read "folderRef" from the ishFolder object
                        folderId = ishFolder.IshFolderRef;
                        WriteDebug($"folderId[{folderId}] {++current}/{ishFolders.Length}");
                        string readAccessString = ishFolder.IshFields.GetFieldValue("READ-ACCESS", Enumerations.Level.None, Enumerations.ValueType.Value);
                        readAccess    = readAccessString.Split(new[] { IshSession.Seperator }, StringSplitOptions.RemoveEmptyEntries);
                        newFolderName = ishFolder.IshFields.GetFieldValue("FNAME", Enumerations.Level.None, Enumerations.ValueType.Value);
                        if (readAccess == null)
                        {
                            WriteDebug($"Renaming folderId[{folderId}]");
                            if (ShouldProcess(Convert.ToString(folderId)))
                            {
                                IshSession.Folder25.Rename(folderId, newFolderName);
                            }
                        }
                        else
                        {
                            WriteDebug($"Updating folderId[{folderId}]");
                            if (ShouldProcess(Convert.ToString(folderId)))
                            {
                                IshSession.Folder25.Update(folderId, newFolderName, readAccess);
                            }
                        }
                        returnFolderIds.Add(folderId);
                    }
                }
                else if (FolderId != 0)
                {
                    // 1b. Retrieve using FolderId
                    WriteDebug($"folderId[{FolderId}]");
                    folderId      = FolderId;
                    readAccess    = ReadAccess;
                    newFolderName = _newFolderName;
                    if (newFolderName == null && readAccess == null)
                    {
                        WriteDebug($"Renaming folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Rename(folderId, newFolderName);
                        }
                    }
                    else
                    {
                        WriteDebug($"Updating folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Update(folderId, newFolderName, readAccess);
                        }
                    }
                    returnFolderIds.Add(folderId);
                }
                else if (FolderPath != null)
                {
                    // 1c. Retrieve using provided parameter FolderPath
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        "");
                    IshFolders ishFolder = new IshFolders(xmlIshFolder, "ishfolder");
                    folderId      = ishFolder.Folders[0].IshFolderRef;
                    readAccess    = ReadAccess;
                    newFolderName = _newFolderName;
                    if (newFolderName == "")
                    {
                        WriteWarning("Skipping rename to empty for folderId[" + folderId + "]");
                    }
                    else if (readAccess == null)
                    {
                        WriteDebug($"Renaming folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Rename(folderId, newFolderName);
                        }
                    }
                    else
                    {
                        WriteDebug($"Updating folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Update(folderId, newFolderName, readAccess);
                        }
                    }
                    returnFolderIds.Add(folderId);
                }
                else
                {
                    // 1d. Retrieve subfolder(s) from the specified root folder using BaseFolder string (enumeration)
                    var baseFolder = EnumConverter.ToBaseFolder <Folder25ServiceReference.BaseFolder>(BaseFolder);
                    xmlIshFolders = IshSession.Folder25.GetMetadata(
                        baseFolder,
                        new string[0],
                        "");
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder");
                    folderId      = retrievedFolders.Folders[0].IshFolderRef;
                    readAccess    = ReadAccess;
                    newFolderName = _newFolderName;
                    if (newFolderName == "")
                    {
                        WriteWarning("Skipping rename to empty for folderId[" + folderId + "]");
                    }
                    if (readAccess == null)
                    {
                        WriteDebug($"Renaming folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Rename(folderId, newFolderName);
                        }
                    }
                    else
                    {
                        WriteDebug($"Updating folderId[{folderId}]");
                        if (ShouldProcess(Convert.ToString(folderId)))
                        {
                            IshSession.Folder25.Update(folderId, newFolderName, readAccess);
                        }
                    }
                    returnFolderIds.Add(folderId);
                }


                // Retrieve updated folder from the database and write it out
                WriteDebug("Retrieving");

                // Add the required fields (needed for pipe operations)
                IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(), Enumerations.ActionMode.Read);
                xmlIshFolders = IshSession.Folder25.RetrieveMetadataByIshFolderRefs(returnFolderIds.ToArray(), requestedMetadata.ToXml());

                // 3b. Write it
                IshFolders returnIshObjects = new IshFolders(xmlIshFolders);
                WriteVerbose("returned object count[" + returnIshObjects.Folders.Length + "]");
                WriteObject(returnIshObjects.Folders, true);
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
Пример #10
0
        /// <summary>
        /// Process the Get-IshFolderContent commandlet.
        /// </summary>
        /// <exception cref="TrisoftAutomationException"></exception>
        /// <exception cref="Exception"></exception>
        /// <remarks>Writes an <see cref="IshObject"/> array to the pipeline</remarks>
        protected override void ProcessRecord()
        {
            try
            {
                // 1. Validating the input
                WriteDebug("Validating");
                List <long> returnFolderIds = new List <long>();

                switch (ParameterSetName)
                {
                case "IshFolderGroup":
                    foreach (IshFolder ishFolder in IshFolder)
                    {
                        returnFolderIds.Add(ishFolder.IshFolderRef);
                    }
                    break;

                case "FolderIdGroup":
                    WriteDebug($"folderId[{FolderId}]");
                    returnFolderIds.Add(FolderId);
                    break;

                case "FolderPathGroup":
                    // Parse FolderPath input parameter: get basefolderName(1st element of an array)
                    string   folderPath         = FolderPath;
                    string[] folderPathElements = folderPath.Split(
                        new string[] { IshSession.FolderPathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    string baseFolderLabel = folderPathElements[0];

                    // remaining folder path elements
                    string[] folderPathTrisoft = new string[folderPathElements.Length - 1];
                    Array.Copy(folderPathElements, 1, folderPathTrisoft, 0, folderPathElements.Length - 1);

                    WriteDebug($"FolderPath[{folderPath}]");
                    string xmlIshFolder = IshSession.Folder25.GetMetadata(
                        BaseFolderLabelToEnum(IshSession, baseFolderLabel),
                        folderPathTrisoft,
                        "");
                    IshFolders ishFolders = new IshFolders(xmlIshFolder, "ishfolder");
                    returnFolderIds.Add(ishFolders.Folders[0].IshFolderRef);
                    break;

                case "BaseFolderGroup":
                    var    baseFolder    = EnumConverter.ToBaseFolder <Folder25ServiceReference.BaseFolder>(BaseFolder);
                    string xmlIshFolders = IshSession.Folder25.GetMetadata(
                        baseFolder,
                        new string[0],
                        "");
                    IshFolders retrievedFolders = new IshFolders(xmlIshFolders, "ishfolder");
                    returnFolderIds.Add(retrievedFolders.Folders[0].IshFolderRef);
                    break;
                }

                List <IshObject> returnIshObjects     = new List <IshObject>();
                IshFields        metadataFilterFields = new IshFields(MetadataFilter);
                // Update MetadataFilter with LanguagesFilter (if provided)
                if (LanguagesFilter != null && LanguagesFilter.Length > 0)
                {
                    if (LanguagesFilter[0].StartsWith("VLANGUAGE"))
                    {
                        metadataFilterFields.AddOrUpdateField(new IshMetadataFilterField(FieldElements.DocumentLanguage,
                                                                                         Enumerations.Level.Lng,
                                                                                         Enumerations.FilterOperator.In,
                                                                                         String.Join(IshSession.Separator, LanguagesFilter),
                                                                                         Enumerations.ValueType.Element),
                                                              Enumerations.ActionMode.Update);
                    }
                    else
                    {
                        metadataFilterFields.AddOrUpdateField(new IshMetadataFilterField(FieldElements.DocumentLanguage,
                                                                                         Enumerations.Level.Lng,
                                                                                         Enumerations.FilterOperator.In,
                                                                                         String.Join(IshSession.Separator, LanguagesFilter),
                                                                                         Enumerations.ValueType.Value),
                                                              Enumerations.ActionMode.Update);
                    }
                }

                int current = 0;
                foreach (long returnFolderId in returnFolderIds)
                {
                    // 2. Doing Retrieve
                    WriteDebug($"Looping folderId[{returnFolderId}] {++current}/{returnFolderIds.Count}");
                    string xmlIshObjects = IshSession.Folder25.GetContents(returnFolderId);
                    var    ishObjects    = new IshObjects(xmlIshObjects);

                    if (ishObjects.Ids.Length > 0)
                    {
                        WriteDebug("Retrieving LogicalIds.Length[" + ishObjects.Ids.Length + "]");
                        // First handle all documents/illustrations
                        var documentLogicalIds = ishObjects.Objects
                                                 .Where(ishObject => ishObject.IshType != Enumerations.ISHType.ISHPublication)
                                                 .Select(ishObject => ishObject.IshRef)
                                                 .ToList();
                        if (documentLogicalIds.Any())
                        {
                            Enumerations.ISHType[] ISHType = { Enumerations.ISHType.ISHIllustration, Enumerations.ISHType.ISHLibrary, Enumerations.ISHType.ISHMasterDoc, Enumerations.ISHType.ISHModule, Enumerations.ISHType.ISHTemplate };
                            IshFields requestedMetadata    = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(), Enumerations.ActionMode.Read);

                            // Devides the list of LogicalIds in different lists that all have maximally MetadataBatchSize elements
                            List <List <string> > devidedDocumentLogicalIdsList = DevideListInBatches <string>(documentLogicalIds, IshSession.MetadataBatchSize);
                            int currentLogicalIdCount = 0;
                            foreach (List <string> logicalIdBatch in devidedDocumentLogicalIdsList)
                            {
                                currentLogicalIdCount += logicalIdBatch.Count;
                                WriteDebug($"Retrieving DocumentObj.length[{logicalIdBatch.Count}] MetadataFilter.length[{metadataFilterFields.ToXml().Length}] {currentLogicalIdCount}/{documentLogicalIds.Count}");

                                if (VersionFilter != null && VersionFilter.Length > 0)
                                {
                                    WriteDebug($"Filtering DocumentObj using VersionFilter[{VersionFilter}]");
                                    xmlIshObjects = IshSession.DocumentObj25.RetrieveVersionMetadata(logicalIdBatch.ToArray(), VersionFilter, "");
                                    var documentIshObjects = new IshObjects(xmlIshObjects);
                                    if (documentIshObjects.Objects.Length > 0)
                                    {
                                        WriteVerbose($"Filtering DocumentObj using MetadataFilter.length[{metadataFilterFields.ToXml().Length}] and LanguagesFilter.Length[{LanguagesFilter.Length}]");
                                        var versionRefs = documentIshObjects.Objects
                                                          .Select(ishObject => Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Version]))
                                                          .ToList();
                                        xmlIshObjects =
                                            IshSession.DocumentObj25.RetrieveMetadataByIshVersionRefs(versionRefs.ToArray(),
                                                                                                      DocumentObj25ServiceReference.StatusFilter.ISHNoStatusFilter, metadataFilterFields.ToXml(),
                                                                                                      requestedMetadata.ToXml());
                                        documentIshObjects = new IshObjects(ISHType, xmlIshObjects);
                                        returnIshObjects.AddRange(documentIshObjects.Objects);
                                    }
                                }
                                else
                                {
                                    WriteVerbose($"Filtering DocumentObj using MetadataFilter.length[{metadataFilterFields.ToXml().Length}]");
                                    xmlIshObjects = IshSession.DocumentObj25.RetrieveMetadata(logicalIdBatch.ToArray(),
                                                                                              DocumentObj25ServiceReference.StatusFilter.ISHNoStatusFilter,
                                                                                              metadataFilterFields.ToXml(),
                                                                                              requestedMetadata.ToXml());
                                    var documentIshObjects = new IshObjects(ISHType, xmlIshObjects);
                                    returnIshObjects.AddRange(documentIshObjects.Objects);
                                }
                            }
                        }

                        // Handle all publications
                        var publicationLogicalIds =
                            ishObjects.Objects
                            .Where(ishObject => ishObject.IshType == Enumerations.ISHType.ISHPublication)
                            .Select(ishObject => ishObject.IshRef)
                            .ToList();
                        if (publicationLogicalIds.Any())
                        {
                            Enumerations.ISHType[] ISHType = { Enumerations.ISHType.ISHPublication };
                            IshFields requestedMetadata    = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(), Enumerations.ActionMode.Read);

                            // Devides the list of LogicalIds in different lists that all have maximally MetadataBatchSize elements
                            List <List <string> > devidedPublicationLogicalIdsList = DevideListInBatches <string>(publicationLogicalIds, IshSession.MetadataBatchSize);
                            int currentLogicalIdCount = 0;
                            foreach (List <string> logicalIdBatch in devidedPublicationLogicalIdsList)
                            {
                                currentLogicalIdCount += logicalIdBatch.Count;
                                WriteDebug($"Retrieving PublicationOutput.length[{logicalIdBatch.Count}] MetadataFilter.length[{metadataFilterFields.ToXml().Length}] {currentLogicalIdCount}/{publicationLogicalIds.Count}");

                                if (VersionFilter != null && VersionFilter.Length > 0)
                                {
                                    WriteDebug($"Filtering PublicationOutput using VersionFilter[{VersionFilter}]");
                                    xmlIshObjects = IshSession.PublicationOutput25.RetrieveVersionMetadata(logicalIdBatch.ToArray(), VersionFilter, "");
                                    var publicationIshObjects = new IshObjects(xmlIshObjects);

                                    if (publicationIshObjects.Objects.Length > 0)
                                    {
                                        WriteVerbose($"Filtering PublicationOutput using MetadataFilter.length[{metadataFilterFields.ToXml().Length}] and LanguagesFilter.Length[{LanguagesFilter.Length}]");
                                        var versionRefs = publicationIshObjects.Objects
                                                          .Select(ishObject => Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Version]))
                                                          .ToList();
                                        xmlIshObjects =
                                            IshSession.PublicationOutput25.RetrieveMetadataByIshVersionRefs(versionRefs.ToArray(),
                                                                                                            PublicationOutput25ServiceReference.StatusFilter.ISHNoStatusFilter, metadataFilterFields.ToXml(),
                                                                                                            requestedMetadata.ToXml());
                                        publicationIshObjects = new IshObjects(ISHType, xmlIshObjects);
                                        returnIshObjects.AddRange(publicationIshObjects.Objects);
                                    }
                                }
                                else
                                {
                                    WriteVerbose($"Filtering PublicationOutput using MetadataFilter.length[{metadataFilterFields.ToXml().Length}]");
                                    xmlIshObjects = IshSession.PublicationOutput25.RetrieveMetadata(logicalIdBatch.ToArray(),
                                                                                                    PublicationOutput25ServiceReference.StatusFilter.ISHNoStatusFilter,
                                                                                                    metadataFilterFields.ToXml(),
                                                                                                    requestedMetadata.ToXml());
                                    var publicationIshObjects = new IshObjects(ISHType, xmlIshObjects);
                                    returnIshObjects.AddRange(publicationIshObjects.Objects);
                                }
                            }
                        }
                    }
                }
                WriteVerbose("returned object count[" + returnIshObjects.Count + "]");
                WriteObject(IshSession, ISHType, returnIshObjects.ConvertAll(x => (IshBaseObject)x), true);
            }
            catch (TrisoftAutomationException trisoftAutomationException)
            {
                ThrowTerminatingError(new ErrorRecord(trisoftAutomationException, base.GetType().Name, ErrorCategory.InvalidOperation, null));
            }
            catch (Exception exception)
            {
                ThrowTerminatingError(new ErrorRecord(exception, base.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }