/// <summary> /// Process the Find-IshDocumentObj 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 { IshFields metadataFilter = new IshFields(MetadataFilter); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Find); string ishTypeFilter = (IshTypeFilter != null) ? String.Join(IshSession.Seperator, IshTypeFilter) : ""; var statusFilter = EnumConverter.ToStatusFilter <DocumentObj25ServiceReference.StatusFilter>(StatusFilter); // Finding any hits with extra requested metadata if specified. // Note that is better to do a Find and pipe it to a Get which will retrieve additional metadata in batches WriteDebug($"Finding StatusFilter[{statusFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.DocumentObj25.Find( ishTypeFilter, statusFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); var returnIshObjects = new IshObjects(xmlIshObjects).Objects; WriteVerbose("returned object count[" + returnIshObjects.Length + "]"); 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)); } }
/// <summary> /// Process the Find-IshAnnotation commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes <see cref="IshAnnotation"/> array to the pipeline</remarks> protected override void ProcessRecord() { try { //1. Initialize List <IshObject> returnedObjects = new List <IshObject>(); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Read); IshFields metadataFilter = new IshFields(MetadataFilter); //2. Call Find WriteDebug($"Finding MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.Annotation25.Find(metadataFilter.ToXml(), requestedMetadata.ToXml()); IshObjects ishObjectsFound = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(ishObjectsFound.Objects); //3. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
protected override void ProcessRecord() { try { IshFields metadataFilter = new IshFields(MetadataFilter); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Find); WriteDebug($"Finding MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.Baseline25.GetList( metadataFilter.ToXml(), requestedMetadata.ToXml()); var returnedObjects = new IshObjects(xmlIshObjects).Objects; WriteVerbose("returned object count[" + returnedObjects.Length + "]"); WriteObject(returnedObjects, 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 Find-IshPublicationOutput 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 { string xmlIshObjects = ""; PublicationOutput25ServiceReference.StatusFilter statusFilter = EnumConverter.ToStatusFilter <PublicationOutput25ServiceReference.StatusFilter>(StatusFilter); IshFields metadataFilter = new IshFields(MetadataFilter); // Add the required fields (needed for pipe operations) IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Read); WriteDebug($"Finding StatusFilter[{statusFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); xmlIshObjects = IshSession.PublicationOutput25.Find( statusFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); var returnedObjects = new IshObjects(xmlIshObjects).Objects; WriteVerbose("returned object count[" + returnedObjects.Length + "]"); WriteObject(returnedObjects, 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 Find-IshDocumentObj 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 { IshFields metadataFilter = new IshFields(MetadataFilter); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Find); string ishTypeFilter = (IshTypeFilter != null) ? String.Join(IshSession.Separator, IshTypeFilter) : String.Join(IshSession.Separator, new Enumerations.ISHType[] { Enumerations.ISHType.ISHModule, Enumerations.ISHType.ISHMasterDoc, Enumerations.ISHType.ISHLibrary, Enumerations.ISHType.ISHTemplate, Enumerations.ISHType.ISHIllustration }); // explicitly exclude ISHReusedObject which is still returned by DocumentObj25.Find?! var statusFilter = EnumConverter.ToStatusFilter <DocumentObj25ServiceReference.StatusFilter>(StatusFilter); // Finding any hits with extra requested metadata if specified. // Note that is better to do a Find and pipe it to a Get which will retrieve additional metadata in batches WriteDebug($"Finding StatusFilter[{statusFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.DocumentObj25.Find( ishTypeFilter, statusFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); var returnIshObjects = new IshObjects(ISHType, xmlIshObjects); WriteVerbose("returned object count[" + returnIshObjects.ObjectList.Count + "]"); WriteObject(IshSession, ISHType, returnIshObjects.ObjectList.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)); } }
protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); var activityFilter = EnumConverter.ToActivityFilter <EDT25ServiceReference.ActivityFilter>(ActivityFilter); IshFields metadataFilter = new IshFields(MetadataFilter); // add more fields required for pipe operations IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Find); // 2. Finding WriteDebug($"Finding ActivityFilter[{activityFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.EDT25.Find( activityFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); WriteVerbose("xmlIshObjects.length[" + xmlIshObjects.Length + "]"); // 3. Write it var returnedObjects = new IshObjects(xmlIshObjects).Objects; WriteVerbose("returned object count[" + returnedObjects.Length + "]"); WriteObject(returnedObjects, 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)); } }
protected override void ProcessRecord() { try { IshFields metadataFilter = new IshFields(MetadataFilter); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Find); var activityFilter = EnumConverter.ToActivityFilter <User25ServiceReference.ActivityFilter>(ActivityFilter); WriteDebug($"Finding ActivityFilter[{activityFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); string xmlIshObjects = IshSession.User25.Find( activityFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); var returnedObjects = new IshObjects(ISHType, xmlIshObjects).ObjectList; WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
/// <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)); } }
/// <summary> /// Process the Publish-IshPublicationOutput commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.Public.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { List <IshObject> returnedObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to publish"); } else { WriteDebug("Publishing"); IshFields requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); IshFields publishMetadata = new IshFields(); publishMetadata.AddField(new IshMetadataField("FISHPUBSTATUS", Enumerations.Level.Lng, Enumerations.ValueType.Element, "VPUBSTATUSPUBLISHPENDING")); if (IshObject != null) { // Using the pipeline int current = 0; var lngCardIds = new List <long>(); IshObjects ishObjects = new IshObjects(IshObject); foreach (IshObject ishObject in ishObjects.Objects) { long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); WriteDebug($"lngRef[{lngRef}] {++current}/{IshObject.Length}"); var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, publishMetadata, Enumerations.ActionMode.Update); if (ShouldProcess(Convert.ToString(lngRef))) { IshSession.PublicationOutput25.SetMetadataByIshLngRef(lngRef, metadata.ToXml(), requiredCurrentMetadata.ToXml()); } lngCardIds.Add(lngRef); } var returnFields = (IshObject[0] == null) ? new IshFields() : IshObject[0].IshFields; IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.PublicationOutput25.RetrieveMetadataByIshLngRefs(lngCardIds.ToArray(), requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } else { var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, publishMetadata, Enumerations.ActionMode.Update); string version = Version; PublicationOutput25ServiceReference.SetMetadataResponse response = null; if (ShouldProcess(LogicalId + "=" + version + "=" + LanguageCombination + "=" + OutputFormat)) { response = IshSession.PublicationOutput25.SetMetadata(new SetMetadataRequest( LogicalId, version, OutputFormat, LanguageCombination, metadata.ToXml(), requiredCurrentMetadata.ToXml())); // Get the metadata of the object IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, publishMetadata, Enumerations.ActionMode.Read); var response2 = IshSession.PublicationOutput25.GetMetadata(new PublicationOutput25ServiceReference. GetMetadataRequest( LogicalId, response.version, OutputFormat, LanguageCombination, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } } } WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
/// <summary> /// Process the Add-IshPublicationOutput commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { // validating the input List <IshObject> returnedObjects = new List <IshObject>(); WriteDebug("Adding"); if (IshObject != null) { // Using the pipeline int current = 0; IshObjects ishObjects = new IshObjects(IshObject); foreach (IshObject ishObject in ishObjects.Objects) { // Get values WriteDebug($"Id[{ishObject.IshRef}] {++current}/{IshObject.Length}"); string logicalId = ishObject.IshRef; //Remember that RetrieveFirst prefers id over element over value ishfields var versionMetadataField = ishObject.IshFields.RetrieveFirst("VERSION", Enumerations.Level.Version).ToMetadataField() as IshMetadataField; string version = versionMetadataField.Value; var outputFormatMetadataField = ishObject.IshFields.RetrieveFirst("FISHOUTPUTFORMATREF", Enumerations.Level.Lng).ToMetadataField() as IshMetadataField; string outputFormat = outputFormatMetadataField.Value; var languageCombinationMetadataField = ishObject.IshFields.RetrieveFirst("FISHPUBLNGCOMBINATION", Enumerations.Level.Lng).ToMetadataField() as IshMetadataField; string languageCombination = languageCombinationMetadataField.Value; var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Create); PublicationOutput25ServiceReference.CreateResponse response = null; if (ShouldProcess(logicalId + "=" + version + "=" + languageCombination + "=" + outputFormat)) { response = IshSession.PublicationOutput25.Create(new PublicationOutput25ServiceReference. CreateRequest( _folderId, logicalId, version, outputFormat, languageCombination, metadata.ToXml())); } IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, metadata, Enumerations.ActionMode.Read); var response2 = IshSession.PublicationOutput25.GetMetadata(new PublicationOutput25ServiceReference. GetMetadataRequest( response.logicalId, response.version, outputFormat, languageCombination, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } } else { var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Create); PublicationOutput25ServiceReference.CreateResponse response = null; if (ShouldProcess(LogicalId + "=" + Version + "=" + LanguageCombination + "=" + OutputFormat)) { response = IshSession.PublicationOutput25.Create(new PublicationOutput25ServiceReference. CreateRequest( _folderId, LogicalId, Version, OutputFormat, LanguageCombination, metadata.ToXml())); } IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, metadata, Enumerations.ActionMode.Read); var response2 = IshSession.PublicationOutput25.GetMetadata(new PublicationOutput25ServiceReference. GetMetadataRequest( response.logicalId, response.version, OutputFormat, LanguageCombination, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } // Write objects to the pipeline WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(returnedObjects, 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-IshDocumentObjData commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="File"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { List <FileInfo> fileInfo = new List <FileInfo>(); if (IshObject != null && IshObject.Length == 0) { WriteVerbose("IshObject is empty, so nothing to retrieve"); } else { WriteDebug("Retrieving"); IshFeatures productDefinitionFeatures = new IshFeatures(IshFeature); int current = 0; var ishObjects = new IshObjects(IshObject).Objects; foreach (IshObject ishObject in ishObjects) { // Get language ref long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); long[] lngRefsArray = new long[1] { lngRef }; var dataObjectResponse = IshSession.DocumentObj25.RetrieveObjectsByIshLngRefs(lngRefsArray, productDefinitionFeatures.ToXml(), ""); XmlDocument xmlIshDataObject = new XmlDocument(); xmlIshDataObject.LoadXml(dataObjectResponse); XmlElement ishDataObjectElement = (XmlElement)xmlIshDataObject.SelectSingleNode("ishobjects/ishobject/ishdata"); IshData ishData = new IshData(ishDataObjectElement); if (FolderPath != null) { string tempLocation = Directory.CreateDirectory(FolderPath).FullName; WriteDebug($"Writing lngRef[{lngRef}] to [{tempLocation}] {++current}/{ishObjects.Length}"); //Create the file. string tempFilePath = FileNameHelper.GetDefaultObjectFileName(tempLocation, ishObject, ishData.FileExtension); using (FileStream fs = File.Create(tempFilePath)) { fs.Write(ishData.ByteArray, 0, ishData.Size()); } // Append file info list fileInfo.Add(new FileInfo(tempFilePath)); WriteObject(fileInfo, true); } else { WriteDebug($"Enriching ishObject[{ishObject.ObjectRef[Enumerations.ReferenceType.Lng]}] with IshData {++current}/{IshObject.Length}"); ishObject.IshData = ishData; WriteObject(ishObject, true); } } WriteVerbose("returned file count[" + current + "]"); } } 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 Set-IshDocumentObj 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 <IshObject> returnedObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to update"); } else { // 2. Doing the update WriteDebug("Updating"); IshFields requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); if (IshObject != null) { int current = 0; IshObject[] ishObjects = IshObject; List <long> lngCardIds = new List <long>(); foreach (IshObject ishObject in ishObjects) { // Get language ref long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); // Use incoming Metadata for update operation, or re-submit metadata of incoming IshObjects var metadata = (Metadata != null) ? IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Update) : IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Update); if (ishObject.IshData != null) { WriteDebug($"lngRef[{lngRef}] Metadata.length[{metadata.ToXml().Length}] dataSize[{ishObject.IshData.Size()}] {++current}/{ishObjects.Length}"); if (ShouldProcess(Convert.ToString(lngRef))) { IshSession.DocumentObj25.UpdateByIshLngRef( lngRef, metadata.ToXml(), requiredCurrentMetadata.ToXml(), ishObject.IshData.Edt, ishObject.IshData.ByteArray); } } else { WriteDebug($"lngRef[{lngRef}] Metadata.length[{metadata.ToXml().Length}] dataSize[0] {++current}/{ishObjects.Length}"); if (ShouldProcess(Convert.ToString(lngRef))) { IshSession.DocumentObj25.SetMetadataByIshLngRef( lngRef, metadata.ToXml(), requiredCurrentMetadata.ToXml()); } } lngCardIds.Add(lngRef); } var returnFields = (IshObject[0] == null) ? new IshFields() : IshObject[0].IshFields; IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.DocumentObj25.RetrieveMetadataByIshLngRefs(lngCardIds.ToArray(), requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } else { string resolution = Resolution ?? ""; var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Update); string version = "-1"; if (Edt != null && FilePath != null) { IshData ishData = new IshData(Edt, FilePath); WriteDebug($"Id[{LogicalId}] Version[{Version}] Lng[{Lng}] Resolution[{resolution}] Metadata.length[{metadata.ToXml().Length}] dataSize[{ishData.Size()}]"); DocumentObj25ServiceReference.UpdateResponse response = null; if (ShouldProcess(LogicalId + "=" + Version + "=" + Lng + "=" + resolution)) { response = IshSession.DocumentObj25.Update(new UpdateRequest( LogicalId, Version, Lng, resolution, metadata.ToXml(), requiredCurrentMetadata.ToXml(), ishData.Edt, ishData.ByteArray)); version = response.version; } } else { WriteDebug($"Id[{LogicalId}] Version[{Version}] Lng[{Lng}] Resolution[{resolution}] Metadata.length[{metadata.ToXml().Length}] dataSize[0]"); DocumentObj25ServiceReference.SetMetadataResponse response = null; if (ShouldProcess(LogicalId + "=" + Version + "=" + Lng + "=" + resolution)) { response = IshSession.DocumentObj25.SetMetadata(new SetMetadataRequest( LogicalId, Version, Lng, resolution, metadata.ToXml(), requiredCurrentMetadata.ToXml())); version = response.version; } } IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, metadata, Enumerations.ActionMode.Read); var response2 = IshSession.DocumentObj25.GetMetadata(new GetMetadataRequest(LogicalId, version, Lng, resolution, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); } } // 3. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
/// <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)); } }
/// <summary> /// Process the Set-IshEDT commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.Public.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); List <IshObject> returnedObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to update"); } else { IshFields requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); // Updated EDT Ids List <string> EDTIdsToRetrieve = new List <string>(); IshFields returnFields; // 2. Doing Set WriteDebug("Updating"); // 2a. Set using provided parameters (not piped IshObject) if (IshObject != null) { // 2b. Set using IshObject pipeline. IshObjects ishObjects = new IshObjects(IshObject); int current = 0; foreach (IshObject ishObject in ishObjects.Objects) { WriteDebug($"Id[{ishObject.IshRef}] {++current}/{IshObject.Length}"); var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Update); if (ShouldProcess(ishObject.IshRef)) { IshSession.EDT25.Update( ishObject.IshRef, metadata.ToXml(), requiredCurrentMetadata.ToXml()); EDTIdsToRetrieve.Add(ishObject.IshRef); } } returnFields = (IshObject[0] == null) ? new IshFields() : IshObject[0].IshFields; } else { var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Update); if (ShouldProcess(Id)) { IshSession.EDT25.Update( Id, metadata.ToXml(), requiredCurrentMetadata.ToXml()); EDTIdsToRetrieve.Add(Id); } returnFields = metadata; } // 3a. Retrieve updated EDT(s) from the database and write them out WriteDebug("Retrieving"); // Add the required fields (needed for pipe operations) IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, returnFields, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.EDT25.RetrieveMetadata( EDTIdsToRetrieve.ToArray(), EDT25ServiceReference.ActivityFilter.None, "", requestedMetadata.ToXml()); returnedObjects.AddRange(new IshObjects(xmlIshObjects).Objects); } // 3b. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(returnedObjects, 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 Add-IshAnnotation commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes <see cref="IshAnnotation"/> array to the pipeline</remarks> protected override void ProcessRecord() { try { List <IshObject> returnedObjects = new List <IshObject>(); //1. Add annotations depending on the chosen ParameterSet List <string> returnAnnotations = new List <string>(); IshFields returnFields = new IshFields(); if (ParameterSetName == "MetadataGroup") { var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Create); if (ShouldProcess("AnnotationAddress: '" + metadata.GetFieldValue(FieldElements.AnnotationAddress, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "' AnnotationText: '" + metadata.GetFieldValue(FieldElements.AnnotationText, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "'")) { string annotationId = IshSession.Annotation25.Create(metadata.ToXml()); returnAnnotations.Add(annotationId); } returnFields = metadata; } if (ParameterSetName == "ParametersGroup" || ParameterSetName == "IshObjectGroup") { // 1.1. Get the latest RevisionId for the given LogicalId/Version/Language of the content object var metadata = (Metadata == null) ? new IshFields() : new IshFields(Metadata); IshFields requestedMetadataContentObject = new IshFields(); requestedMetadataContentObject.AddField(new IshRequestedMetadataField(FieldElements.ED, Enumerations.Level.Lng, Enumerations.ValueType.Element)); string xmlIshContentObjects; string logicalId; string version; string lng; if (IshObject != null) { // IshObjectGroup xmlIshContentObjects = IshSession.DocumentObj25.GetMetadataByIshLngRef(Convert.ToInt64(IshObject.LngRef), requestedMetadataContentObject.ToXml()); logicalId = IshObject.IshRef; version = IshObject.IshFields.GetFieldValue(FieldElements.Version, Enumerations.Level.Version, Enumerations.ValueType.Value); lng = IshObject.IshFields.GetFieldValue(FieldElements.DocumentLanguage, Enumerations.Level.Lng, Enumerations.ValueType.Value); } else { // ParametersGroup var response = IshSession.DocumentObj25.GetMetadata(new GetMetadataRequest(LogicalId, Version, Lng, "", requestedMetadataContentObject.ToXml())); // GetMetadata call should throw in case of non-existing LogicalId/Version/Lng combination. So not checking count of returned objects xmlIshContentObjects = response.xmlObjectList; logicalId = LogicalId; version = Version; lng = Lng; } IshObjects retrievedContentObjects = new IshObjects(ISHType, xmlIshContentObjects); string retrievedContentObjectED = retrievedContentObjects.Objects[0].IshFields.GetFieldValue(FieldElements.ED, Enumerations.Level.Lng, Enumerations.ValueType.Element); // 1.2. Owerwrite incoming metadata field values with parameters provided in the parameters metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationPublicationLogicalId, Enumerations.Level.Annotation, PubLogicalId), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationPublicationVersion, Enumerations.Level.Annotation, PubVersion), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationContentObjectLogicalId, Enumerations.Level.Annotation, logicalId), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationContentObjectVersion, Enumerations.Level.Annotation, version), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationContentObjectLanguage, Enumerations.Level.Annotation, lng), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationRevisionId, Enumerations.Level.Annotation, Enumerations.ValueType.Element, retrievedContentObjectED), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationType, Enumerations.Level.Annotation, Type), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationText, Enumerations.Level.Annotation, Text), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationStatus, Enumerations.Level.Annotation, Status), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationAddress, Enumerations.Level.Annotation, Address), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField(FieldElements.AnnotationCategory, Enumerations.Level.Annotation, Category), Enumerations.ActionMode.Update); metadata.AddOrUpdateField(new IshMetadataField("FISHPUBLANGUAGE", Enumerations.Level.Annotation, PubLng), Enumerations.ActionMode.Update); metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, metadata, Enumerations.ActionMode.Create); if (ShouldProcess("AnnotationAddress: '" + metadata.GetFieldValue(FieldElements.AnnotationAddress, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "' AnnotationText: '" + metadata.GetFieldValue(FieldElements.AnnotationText, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "'")) { string annotationId = IshSession.Annotation25.Create(metadata.ToXml()); returnAnnotations.Add(annotationId); } returnFields = metadata; } if (ParameterSetName == "IshAnnotationGroup") { foreach (IshAnnotation ishAnnotation in IshAnnotation) { IshFields metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishAnnotation.IshFields, Enumerations.ActionMode.Create); if (ShouldProcess("AnnotationAddress: '" + metadata.GetFieldValue(FieldElements.AnnotationAddress, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "' AnnotationText: '" + metadata.GetFieldValue(FieldElements.AnnotationText, Enumerations.Level.Annotation, Enumerations.ValueType.Value) + "'")) { string annotationId = IshSession.Annotation25.Create(metadata.ToXml()); returnAnnotations.Add(annotationId); } } returnFields = (IshAnnotation[0] == null) ? new IshFields() : IshAnnotation[0].IshFields; } //2. Retrieve added annotations WriteDebug("Retrieving"); // Add the required fields IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.Annotation25.RetrieveMetadata(returnAnnotations.ToArray(), "", requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); //3. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
protected override void ProcessRecord() { try { // 2. Retrieve the updated material from the database and write it out WriteDebug("Retrieving"); IshFields requestedMetadata = new IshFields(); if (RequestedMetadata != null) { requestedMetadata = new IshFields(RequestedMetadata); } else if (FieldName != null) { requestedMetadata.AddField(new IshRequestedMetadataField(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value)); } var metadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, requestedMetadata, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.Settings25.GetMetadata(metadata.ToXml()); var ishFields = new IshObjects(xmlIshObjects).Objects[0].IshFields; if (FieldName == null) { // 3. Write it WriteVerbose("returned object count[1]"); WriteObject(ishFields.Fields(), true); } else if (FieldName != null) { if (FilePath != null) { //Create the file. Directory.CreateDirectory(Path.GetDirectoryName(FilePath)); var fileMode = (Force.IsPresent) ? FileMode.Create : FileMode.CreateNew; string value = ishFields.GetFieldValue(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value); if (!String.IsNullOrEmpty(value)) { try { // Let's try to see if it is xml first var doc = XDocument.Parse(value); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (var stream = new FileStream(FilePath, fileMode, FileAccess.Write)) { using (XmlWriter xmlWriter = XmlWriter.Create(stream, settings)) { doc.Save(xmlWriter); } } } catch (Exception) { // remove potential readonly flag if (File.Exists(FilePath)) { File.SetAttributes(FilePath, FileAttributes.Normal); } // Write it as a text file Stream stream = null; try { stream = new FileStream(FilePath, fileMode, FileAccess.ReadWrite); using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8)) { stream = null; writer.Write(value); } } finally { if (stream != null) { stream.Dispose(); } } } } WriteVerbose("returned object count[1]"); WriteObject(new FileInfo(FilePath)); } else { WriteVerbose("returned object count[1]"); WriteObject(ishFields.GetFieldValue(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value)); } } } 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-IshDocumentObjData commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="File"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { List <FileInfo> fileInfo = new List <FileInfo>(); if (IshObject != null && IshObject.Length == 0) { WriteVerbose("IshObject is empty, so nothing to retrieve"); } else { WriteDebug("Retrieving"); IshFeatures productDefinitionFeatures = new IshFeatures(IshFeature); int current = 0; var ishObjects = new IshObjects(IshObject).Objects; foreach (IshObject ishObject in ishObjects) { // Get language ref long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); long[] lngRefsArray = new long[1] { lngRef }; using (var stringReader = new StringReader(IshSession.DocumentObj25.RetrieveObjectsByIshLngRefs(lngRefsArray, productDefinitionFeatures.ToXml(), ""))) { byte[] bytearray = null; string edt = ""; string fileExtension = ""; using (XmlTextReader xmlTextReader = new XmlTextReader(stringReader)) { while (xmlTextReader.Read()) { if (xmlTextReader.NodeType == XmlNodeType.Element && xmlTextReader.Name == "ishdata") { edt = xmlTextReader.GetAttribute("edt"); fileExtension = xmlTextReader.GetAttribute("fileextension"); } if (xmlTextReader.NodeType == XmlNodeType.CDATA) { bytearray = System.Convert.FromBase64String(xmlTextReader.Value); } } } IshData ishData = new IshData(edt, fileExtension, bytearray); if (FolderPath != null) { string tempLocation = Directory.CreateDirectory(FolderPath).FullName; WriteDebug($"Writing lngRef[{lngRef}] to [{tempLocation}] {++current}/{ishObjects.Length}"); //Create the file. string tempFilePath = FileNameHelper.GetDefaultObjectFileName(tempLocation, ishObject, ishData.FileExtension); using (FileStream fs = File.Create(tempFilePath)) { fs.Write(ishData.ByteArray, 0, ishData.Size()); } // Append file info list fileInfo.Add(new FileInfo(tempFilePath)); WriteObject(fileInfo, true); } else { WriteDebug($"Enriching ishObject[{ishObject.ObjectRef[Enumerations.ReferenceType.Lng]}] with IshData {++current}/{IshObject.Length}"); ishObject.IshData = ishData; WriteObject(ishObject, true); } } } WriteVerbose("returned file count[" + current + "]"); } } 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-IshPublicationOutputData commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="File"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { List <FileInfo> fileInfo = new List <FileInfo>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to retrieve"); } else { WriteDebug("Retrieving"); string tempLocation = Directory.CreateDirectory(FolderPath).FullName; int current = 0; var ishObjects = new IshObjects(IshObject).Objects; foreach (IshObject ishObject in ishObjects) { // Get language ref long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); string xmlIshDataObject = IshSession.PublicationOutput25.GetDataObjectInfoByIshLngRef(lngRef); // Put the xml in a dataobject XmlDocument xmlIshDataObjectDocument = new XmlDocument(); xmlIshDataObjectDocument.LoadXml(xmlIshDataObject); XmlElement ishDataObjectElement = (XmlElement)xmlIshDataObjectDocument.SelectSingleNode("ishdataobjects/ishdataobject"); IshDataObject ishDataObject = new IshDataObject(ishDataObjectElement); string tempFilePath = FileNameHelper.GetDefaultPublicationOutputFileName(tempLocation, ishObject, ishDataObject.FileExtension); WriteDebug($"Writing lngRef[{lngRef}] to [{tempFilePath}] {++current}/{ishObjects.Length}"); //Create the file. using (FileStream fs = File.Create(tempFilePath)) { for (int offset = 0; offset < ishDataObject.Size; offset += IshSession.ChunkSize) { int size = IshSession.ChunkSize; long offsetCount = offset; byte[] byteArray = new byte[IshSession.ChunkSize]; var response = IshSession.PublicationOutput25.GetNextDataObjectChunkByIshLngRef( new PublicationOutput25ServiceReference.GetNextDataObjectChunkByIshLngRefRequest( lngRef, ishDataObject.Ed, offsetCount, size)); offsetCount = response.offSet; size = response.size; byteArray = response.bytes; fs.Write(byteArray, 0, size); } } // Append file info list fileInfo.Add(new FileInfo(tempFilePath)); } } WriteVerbose("returned file count[" + fileInfo.Count + "]"); WriteObject(fileInfo, 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 Set-IshAnnotation commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes <see cref="IshAnnotation"/> array to the pipeline</remarks> protected override void EndProcessing() { try { List <IshObject> returnedObjects = new List <IshObject>(); List <string> annotationIdsToRetrieve = new List <string>(); IshFields returnFields = new IshFields(); var metadata = (Metadata == null) ? new IshFields() : new IshFields(Metadata); var requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); //1. Set annotations depending on the chosen ParameterSet switch (ParameterSetName) { case "IshAnnotationGroup": int current = 0; foreach (IshObject ishObject in _ishAnnotationsToSet) { WriteDebug($" AnnotationId[{ishObject.IshRef}] Metadata.length[{metadata.ToXml().Length}] RequiredCurrentMetadata.length[{requiredCurrentMetadata.ToXml().Length}] {++current}/{_ishAnnotationsToSet.Count}"); if (ShouldProcess(Convert.ToString(ishObject.IshRef))) { IshSession.Annotation25.Update(ishObject.IshRef, metadata.ToXml(), requiredCurrentMetadata.ToXml()); } annotationIdsToRetrieve.Add(ishObject.IshRef); } returnFields = (_ishAnnotationsToSet[0] == null) ? new IshFields() : _ishAnnotationsToSet[0].IshFields; break; case "ParametersGroup": WriteDebug($" AnnotationId[{AnnotationId}] Metadata.length[{metadata.ToXml().Length}]"); if (ShouldProcess(AnnotationId)) { IshSession.Annotation25.Update(AnnotationId, metadata.ToXml(), requiredCurrentMetadata.ToXml()); } annotationIdsToRetrieve.Add(AnnotationId); returnFields = metadata; break; } //2. Retrieve set annotations WriteDebug($"Retrieving AnnotationId.length[{annotationIdsToRetrieve.Count}]"); // Devides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements List <List <string> > devidedAnnotationIdsList = DevideListInBatches <string>(annotationIdsToRetrieve, IshSession.MetadataBatchSize); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, returnFields, Enumerations.ActionMode.Read); int currentAnnotationIdCount = 0; foreach (List <string> annotationIdBatch in devidedAnnotationIdsList) { string xmlIshObjectsRetrieved = IshSession.Annotation25.RetrieveMetadata(annotationIdBatch.ToArray(), "", requestedMetadata.ToXml()); IshObjects ishObjectsRetrieved = new IshObjects(ISHType, xmlIshObjectsRetrieved); returnedObjects.AddRange(ishObjectsRetrieved.Objects); currentAnnotationIdCount += annotationIdBatch.Count; WriteDebug($"Retrieving AnnotationId.length[{annotationIdBatch.Count}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] {currentAnnotationIdCount}/{annotationIdsToRetrieve.Count}"); } //3. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
/// <summary> /// Process the Add-IshDocumentObj 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"); // Parameters to retrieve added document List <IshObject> returnIshObjects = new List <IshObject>(); WriteDebug("Adding"); if (IshObject != null) { int current = 0; foreach (IshObject ishObject in IshObject) { WriteDebug($"lngRef[{ishObject.ObjectRef[Enumerations.ReferenceType.Lng]}] {++current}/{IshObject.Length}"); // 2b. Add using IshObject pipeline // Initialize from the object string logicalId = ishObject.IshRef; string ishObjectVersion = ishObject.IshFields.GetFieldValue("VERSION", Enumerations.Level.Version, Enumerations.ValueType.Value); //TODO: [Should] Respect LanguageApplicability, which means take the first entry from the ishfield DOC-LANGUAGE value string ishObjectLanguage = ishObject.IshFields.GetFieldValue("DOC-LANGUAGE", Enumerations.Level.Lng, Enumerations.ValueType.Value); string ishObjectResolution = ishObject.IshFields.GetFieldValue("FRESOLUTION", Enumerations.Level.Lng, Enumerations.ValueType.Value); var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Create); // Add WriteDebug($"LogicalId[{logicalId}] Version[{ishObjectVersion}] Lng[{ishObjectLanguage}] Resolution[{ishObjectResolution}] Metadata.length[{metadata.ToXml().Length}] dataSize[{ishObject.IshData.Size()}]"); DocumentObj25ServiceReference.CreateResponse response = null; if (ShouldProcess(logicalId + "=" + ishObjectVersion + "=" + ishObjectLanguage + "=" + ishObjectResolution)) { response = IshSession.DocumentObj25.Create(new DocumentObj25ServiceReference.CreateRequest( _folderId, ishObject.IshType.ToString(), logicalId, ishObjectVersion, ishObjectLanguage, ishObjectResolution, metadata.ToXml(), ishObject.IshData.Edt, ishObject.IshData.ByteArray)); } IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, metadata, Enumerations.ActionMode.Read); var response2 = IshSession.DocumentObj25.GetMetadata(new DocumentObj25ServiceReference.GetMetadataRequest( response.logicalId, response.version, ishObjectLanguage, ishObjectResolution, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnIshObjects.AddRange(retrievedObjects.Objects); } } // 2a. LogicalId is provided else { string resolution = Resolution ?? ""; if ((FileContent != null) && (FilePath == null)) { if (!_edt.Equals("EDTXML", StringComparison.Ordinal)) { throw new NotImplementedException("FileContent parameter is only supported with Edt='EDTXML'"); } var doc = XDocument.Parse(FileContent, LoadOptions.PreserveWhitespace); var ms = new MemoryStream(); doc.Save(ms, SaveOptions.DisableFormatting); _ishData = new IshData(_edt, ms.ToArray()); } if ((FileContent == null) && (FilePath != null)) { _ishData = new IshData(_edt, FilePath); } var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Create); WriteDebug($"LogicalId[{LogicalId}] Version[{Version}] Lng[{Lng}] Resolution[{resolution}] Metadata.length[{metadata.ToXml().Length}] byteArray[{_ishData.Size()}]"); DocumentObj25ServiceReference.CreateResponse response = null; if (ShouldProcess(LogicalId + "=" + Version + "=" + Lng + "=" + resolution)) { response = IshSession.DocumentObj25.Create(new DocumentObj25ServiceReference.CreateRequest( _folderId, IshType.ToString(), LogicalId, Version, Lng, resolution, metadata.ToXml(), _ishData.Edt, _ishData.ByteArray)); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, metadata, Enumerations.ActionMode.Read); var response2 = IshSession.DocumentObj25.GetMetadata(new DocumentObj25ServiceReference.GetMetadataRequest( response.logicalId, response.version, Lng, resolution, requestedMetadata.ToXml())); string xmlIshObjects = response2.xmlObjectList; IshObjects retrievedObjects = new IshObjects(ISHType, xmlIshObjects); returnIshObjects.AddRange(retrievedObjects.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)); } }
/// <summary> /// Process the Set-IshOutputFormat commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); List <IshObject> returnedObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to set"); } else { // Updated OutputFormat Ids List <string> outputFormatIdsToRetrieve = new List <string>(); IshFields returnFields; // 2. Doing Set WriteDebug("Updating"); // 2a. Set using provided parameters (not piped IshObject) if (IshObject != null) { // 2b. Set using IshObject pipeline. IshObjects ishObjects = new IshObjects(IshObject); int current = 0; foreach (IshObject ishObject in ishObjects.Objects) { WriteDebug($"Id[{ishObject.IshRef}] {++current}/{IshObject.Length}"); var edtMetadataField = ishObject.IshFields.RetrieveFirst("FISHOUTPUTEDT", Enumerations.Level.None).ToMetadataField() as IshMetadataField; string edt = edtMetadataField.Value; var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Update); if (ShouldProcess(ishObject.IshRef)) { IshSession.OutputFormat25.Update( ishObject.IshRef, edt, metadata.ToXml()); outputFormatIdsToRetrieve.Add(ishObject.IshRef); } } returnFields = (IshObject[0] == null) ? new IshFields() : IshObject[0].IshFields; } else { var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Update); if (ShouldProcess(Id)) { IshSession.OutputFormat25.Update( Id, Edt, metadata.ToXml()); outputFormatIdsToRetrieve.Add(Id); } returnFields = metadata; } // 3a. Retrieve updated OutputFormat(s) from the database and write them out WriteDebug("Retrieving"); // Remove FISHDITADLVRCLIENTSECRET field explicitly, as we are not allowed to read it returnFields.RemoveField(FieldElements.DitaDeliveryClientSecret, Enumerations.Level.None, Enumerations.ValueType.All); // Add the required fields (needed for pipe operations) IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, returnFields, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.OutputFormat25.RetrieveMetadata( outputFormatIdsToRetrieve.ToArray(), OutputFormat25ServiceReference.ActivityFilter.None, "", requestedMetadata.ToXml()); returnedObjects.AddRange(new IshObjects(xmlIshObjects).Objects); } // 3b. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(returnedObjects, 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 Add-IshOutputFormat commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.Public.IshObject"/> array to the pipeline</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); List <IshObject> returnIshObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to add"); } else { WriteDebug("Adding"); // List of objects to write to the output in the end var outputFormatIds = new List <string>(); IshFields returnFields; if (IshObject != null) { // 2b. Add using IshObject[] pipeline int current = 0; IshObjects ishObjects = new IshObjects(IshObject); foreach (IshObject ishObject in ishObjects.Objects) { // Get values WriteDebug($"Id[{ishObject.IshRef}] {++current}/{IshObject.Length}"); var nameMetadataField = ishObject.IshFields.RetrieveFirst("FISHOUTPUTFORMATNAME", Enumerations.Level.None).ToMetadataField() as IshMetadataField; string name = nameMetadataField.Value; var edtMetadataField = ishObject.IshFields.RetrieveFirst("FISHOUTPUTEDT", Enumerations.Level.None).ToMetadataField() as IshMetadataField; string edt = edtMetadataField.Value; var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, ishObject.IshFields, Enumerations.ActionMode.Create); if (ShouldProcess(name)) { string outputFormatId = IshSession.OutputFormat25.Create( name, edt, metadata.ToXml()); outputFormatIds.Add(outputFormatId); } } returnFields = (IshObject[0] == null) ? new IshFields() : IshObject[0].IshFields; } else { // 2a. Add using provided parameters var metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, new IshFields(Metadata), Enumerations.ActionMode.Create); string edt = Edt ?? ""; WriteDebug($"Name[{Name}] EDT[{edt}] Metadata.Length[{metadata.ToXml().Length}]"); if (ShouldProcess(Name)) { string outputFormatId = IshSession.OutputFormat25.Create( Name, edt, metadata.ToXml()); outputFormatIds.Add(outputFormatId); } returnFields = metadata; } // 3a. Retrieve added OutputFormat 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 xmlIshObjects = IshSession.OutputFormat25.RetrieveMetadata( outputFormatIds.ToArray(), OutputFormat25ServiceReference.ActivityFilter.None, "", requestedMetadata.ToXml()); returnIshObjects.AddRange(new IshObjects(ISHType, xmlIshObjects).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)); } }
/// <summary> /// Process the Remove-IshPublicationOutput commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.Public.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { var logicalIdsVersionsCollection = new NameValueCollection(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to remove"); } else { WriteDebug("Removing"); IshFields requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); if (IshObject != null) { // Using the pipeline int current = 0; IshObjects ishObjects = new IshObjects(IshObject); foreach (IshObject ishObject in ishObjects.Objects) { long lngRef = Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng]); WriteDebug($"lngRef[{lngRef}] {++current}/{ishObjects.Objects.Length}"); if (ShouldProcess(Convert.ToString(lngRef))) { IshSession.PublicationOutput25.DeleteByIshLngRef(lngRef, requiredCurrentMetadata.ToXml()); } logicalIdsVersionsCollection.Add(ishObject.IshRef, ishObject.IshFields.GetFieldValue("VERSION", Enumerations.Level.Version, Enumerations.ValueType.Value)); } } else { if (ShouldProcess(LogicalId + "=" + Version + "=" + LanguageCombination + "=" + OutputFormat)) { IshSession.PublicationOutput25.Delete( LogicalId, Version, OutputFormat, LanguageCombination, requiredCurrentMetadata.ToXml()); } logicalIdsVersionsCollection.Add(LogicalId, Version); } } if (Force.IsPresent && logicalIdsVersionsCollection.Count > 0) { var xmlIshObjects = IshSession.PublicationOutput25.RetrieveMetadata(logicalIdsVersionsCollection.AllKeys.ToArray(), StatusFilter.ISHNoStatusFilter, "", "<ishfields><ishfield name='VERSION' level='version'/><ishfield name='FISHPUBLNGCOMBINATION' level='lng'/></ishfields>"); List <IshObject> retrievedObjects = new List <IshObject>(); retrievedObjects.AddRange(new IshObjects(xmlIshObjects).Objects); // Delete versions which do not have any language card anymore foreach (string logicalId in logicalIdsVersionsCollection.AllKeys) { var versions = logicalIdsVersionsCollection.GetValues(logicalId).Distinct(); foreach (var version in versions) { bool versionWithLanguagesFound = false; foreach (var retrievedObject in retrievedObjects) { if (retrievedObject.IshRef == logicalId && retrievedObject.IshFields.GetFieldValue("VERSION", Enumerations.Level.Version, Enumerations.ValueType.Value) == version) { versionWithLanguagesFound = true; } } if (!versionWithLanguagesFound) { if (ShouldProcess(logicalId + "=" + version + "=" + "=")) { IshSession.PublicationOutput25.Delete(logicalId, version, "", "", ""); } } } } // Delete logical cards which do not have any languages anymore foreach (string logicalId in logicalIdsVersionsCollection.AllKeys) { bool logicalIdFound = false; foreach (var retrievedObject in retrievedObjects) { if (retrievedObject.IshRef == logicalId) { logicalIdFound = true; } } if (!logicalIdFound) { if (ShouldProcess(logicalId + "===")) { IshSession.PublicationOutput25.Delete(logicalId, "", "", "", ""); } } } } 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)); } }
/// <summary> /// Process the Get-IshPublicationOutput commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes an <see cref="Objects.IshObject"/> array to the pipeline.</remarks> protected override void ProcessRecord() { try { // 1. Validating the input WriteDebug("Validating"); List <IshObject> returnedObjects = new List <IshObject>(); if (IshObject != null && IshObject.Length == 0) { // Do nothing WriteVerbose("IshObject is empty, so nothing to retrieve"); } else { WriteDebug("Retrieving"); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Read); if (IshObject != null) { // 2a. Retrieve using LngCardIds IshObjects ishObjects = new IshObjects(IshObject); var lngCardIds = ishObjects.Objects.Select( ishObject => Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng])) .ToList(); WriteDebug($"Retrieving CardIds.length[{lngCardIds}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] 0/{lngCardIds.Count}"); // Devides the list of language card ids in different lists that all have maximally MetadataBatchSize elements List <List <long> > devidedlngCardIdsList = DevideListInBatches <long>(lngCardIds, IshSession.MetadataBatchSize); int currentLngCardIdCount = 0; foreach (List <long> lngCardIdBatch in devidedlngCardIdsList) { // Process language card ids in batches string xmlIshObjects = IshSession.PublicationOutput25.RetrieveMetadataByIshLngRefs( lngCardIdBatch.ToArray(), requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); currentLngCardIdCount += lngCardIdBatch.Count; WriteDebug($"Retrieving CardIds.length[{lngCardIdBatch.Count}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] including data {currentLngCardIdCount}/{lngCardIds.Count}"); } } else { // 2b. Retrieve using LogicalId PublicationOutput25ServiceReference.StatusFilter statusFilter = EnumConverter.ToStatusFilter <PublicationOutput25ServiceReference.StatusFilter>(StatusFilter); IshFields metadataFilter = new IshFields(MetadataFilter); WriteDebug($"Retrieving LogicalId.length[{LogicalId.Length}] StatusFilter[{statusFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] 0/{LogicalId.Length}"); // Devides the list of language card ids in different lists that all have maximally MetadataBatchSize elements List <List <string> > devidedlogicalIdsList = DevideListInBatches <string>(LogicalId.ToList(), IshSession.MetadataBatchSize); int currentLogicalIdCount = 0; foreach (List <string> logicalIdBatch in devidedlogicalIdsList) { // Process language card ids in batches string xmlIshObjects = IshSession.PublicationOutput25.RetrieveMetadata( logicalIdBatch.ToArray(), statusFilter, metadataFilter.ToXml(), requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnedObjects.AddRange(retrievedObjects.Objects); currentLogicalIdCount += logicalIdBatch.Count; WriteDebug($"Retrieving LogicalId.length[{logicalIdBatch.Count}] StatusFilter[{statusFilter}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] {currentLogicalIdCount}/{LogicalId.Length}"); } } } WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(returnedObjects, 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-IshAnnotation commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> /// <remarks>Writes <see cref="IshAnnotation"/> array to the pipeline</remarks> protected override void EndProcessing() { try { //1. Get annotations depending on the chosen ParameterSet List <IshObject> returnedObjects = new List <IshObject>(); IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(IshSession.DefaultRequestedMetadata, ISHType, new IshFields(RequestedMetadata), Enumerations.ActionMode.Read); IshFields metadataFilter = new IshFields(MetadataFilter); List <string> annotationIds = new List <string>(); if (ParameterSetName == "IshObjectGroup") { IshFields ishMetadataFilterFind; List <IshObject> foundObjects = new List <IshObject>(); foreach (IshObject ishObject in _retrievedIshObjects) { string xmlIshAnnotations; switch (ishObject.IshType) { case Enumerations.ISHType.ISHPublication: ishMetadataFilterFind = new IshFields(); ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationPublicationLogicalId, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, ishObject.IshRef, Enumerations.ValueType.Element)); string pubVersion = ishObject.IshFields.GetFieldValue(FieldElements.Version, Enumerations.Level.Version, Enumerations.ValueType.Value); ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationPublicationVersion, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, pubVersion, Enumerations.ValueType.Value)); string pubLanguage = ishObject.IshFields.GetFieldValue(FieldElements.PublicationSourceLanguages, Enumerations.Level.Version, Enumerations.ValueType.Value); // TODO [Could] PublicationSourceLanguage theoretically is multi-value but passed below with an equal filter operator ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationPublicationLanguage, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, pubLanguage, Enumerations.ValueType.Value)); xmlIshAnnotations = IshSession.Annotation25.Find(ishMetadataFilterFind.ToXml(), ""); foundObjects.AddRange(new IshObjects(ISHType, xmlIshAnnotations).Objects); break; case Enumerations.ISHType.ISHMasterDoc: case Enumerations.ISHType.ISHModule: case Enumerations.ISHType.ISHLibrary: case Enumerations.ISHType.ISHIllustration: case Enumerations.ISHType.ISHTemplate: ishMetadataFilterFind = new IshFields(); ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationContentObjectLogicalId, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, ishObject.IshRef, Enumerations.ValueType.Element)); string documentVersion = ishObject.IshFields.GetFieldValue(FieldElements.Version, Enumerations.Level.Version, Enumerations.ValueType.Value); ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationContentObjectVersion, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, documentVersion, Enumerations.ValueType.Value)); string documentLanguage = ishObject.IshFields.GetFieldValue(FieldElements.DocumentLanguage, Enumerations.Level.Lng, Enumerations.ValueType.Value); ishMetadataFilterFind.AddField(new IshMetadataFilterField(FieldElements.AnnotationContentObjectLanguage, Enumerations.Level.Annotation, Enumerations.FilterOperator.Equal, documentLanguage, Enumerations.ValueType.Value)); xmlIshAnnotations = IshSession.Annotation25.Find(ishMetadataFilterFind.ToXml(), ""); foundObjects.AddRange(new IshObjects(ISHType, xmlIshAnnotations).Objects); break; default: WriteDebug($"Object type ishObject.IshType[{ishObject.IshType}] with ishObject.IshRef[{ishObject.IshRef}] is not supported, skipping"); break; } } annotationIds = foundObjects.Select(ishObject => Convert.ToString(ishObject.IshRef)).ToList(); } if (ParameterSetName == "ParametersGroup") { annotationIds = AnnotationId.ToList(); } if (ParameterSetName == "IshAnnotationGroup") { annotationIds = _retrievedIshAnnotations.Select(ishAnnotation => Convert.ToString(ishAnnotation.IshRef)).ToList(); } //2. Retrieve in batches // remove duplicates from annotationIds list annotationIds = annotationIds.Distinct().ToList(); WriteDebug($"Retrieving AnnotationId.length[{annotationIds.Count}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}]"); // Devides the list of Annotation Ids in different lists that all have maximally MetadataBatchSize elements List <List <string> > devidedAnnotationIdsList = DevideListInBatches <string>(annotationIds, IshSession.MetadataBatchSize); int currentAnnotationIdCount = 0; foreach (List <string> annotationIdBatch in devidedAnnotationIdsList) { string xmlIshObjectsRetrieved = IshSession.Annotation25.RetrieveMetadata(annotationIdBatch.ToArray(), metadataFilter.ToXml(), requestedMetadata.ToXml()); IshObjects ishObjectsRetrieved = new IshObjects(ISHType, xmlIshObjectsRetrieved); returnedObjects.AddRange(ishObjectsRetrieved.Objects); currentAnnotationIdCount += annotationIdBatch.Count; WriteDebug($"Retrieving AnnotationId.length[{annotationIdBatch.Count}] MetadataFilter.length[{metadataFilter.ToXml().Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] {currentAnnotationIdCount}/{annotationIds.Count}"); } //3. Write it WriteVerbose("returned object count[" + returnedObjects.Count + "]"); WriteObject(IshSession, ISHType, returnedObjects.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)); } }
protected override void ProcessRecord() { try { IshFields metadata = new IshFields(); IshFields requiredCurrentMetadata = new IshFields(RequiredCurrentMetadata); // 1. Doing the update WriteDebug("Updating"); if (Metadata != null) { metadata = new IshFields(Metadata); } else if (Value != null) { metadata.AddField(new IshMetadataField(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value, Value)); } else if (FilePath != null) { //Check file exists if (!File.Exists(FilePath)) { throw new FileNotFoundException(@"File '" + FilePath + "' does not exist."); } try { // Let's try to see if it is xml first var doc = XDocument.Load(FilePath, LoadOptions.PreserveWhitespace); // ToString does not keep xml declaration <?xml, but that does not really matter as we are passing it in as string anyway (and the API removed the xml desclaration anyway) string value = doc.ToString(SaveOptions.DisableFormatting); metadata.AddField(new IshMetadataField(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value, value)); } catch (Exception) { // Read it as a text file string value = String.Join(IshSession.Seperator, File.ReadAllLines(FilePath)); metadata.AddField(new IshMetadataField(FieldName, Enumerations.Level.None, Enumerations.ValueType.Value, value)); } } if (ShouldProcess("CTCONFIGURATION")) { metadata = IshSession.IshTypeFieldSetup.ToIshMetadataFields(ISHType, metadata, Enumerations.ActionMode.Update); requiredCurrentMetadata = IshSession.IshTypeFieldSetup.ToIshRequiredCurrentMetadataFields(ISHType, requiredCurrentMetadata, Enumerations.ActionMode.Update); IshSession.Settings25.SetMetadata3(metadata.ToXml(), requiredCurrentMetadata.ToXml()); } // 2. Retrieve the updated material from the database and write it out WriteDebug("Retrieving"); var requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, metadata, Enumerations.ActionMode.Read); string xmlIshObjects = IshSession.Settings25.GetMetadata(requestedMetadata.ToXml()); var ishFields = new IshObjects(xmlIshObjects).Objects[0].IshFields; // 3. Write it WriteVerbose("returned object count[1]"); WriteObject(ishFields); } 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> /// EndProcess the Move-IshDocumentObj commandlet. /// </summary> /// <exception cref="TrisoftAutomationException"></exception> /// <exception cref="Exception"></exception> protected override void EndProcessing() { try { // Validating the input where piped objects overrules explicit LogicalId parameter WriteDebug("Validating"); string[] logicalIds; if (_retrievedIshObjects.Count > 0) { logicalIds = _retrievedIshObjects.Select(ishObject => ishObject.IshRef).ToArray <string>(); } else { logicalIds = LogicalId; } WriteDebug("Moving"); if (ShouldProcess(String.Join(", ", logicalIds))) { WriteDebug($"Moving logicalIds.length[{logicalIds.Length}] FromFolderId[{_fromFolderId}] ToFolderId[{_toFolderId}] 0/{logicalIds.Length}"); // Devides the list of language card ids in different lists that all have maximally MetadataBatchSize elements List <List <string> > devidedlogicalIdsList = DevideListInBatches <string>(logicalIds.ToList(), IshSession.MetadataBatchSize); int currentLogicalIdCount = 0; foreach (List <string> logicalIdBatch in devidedlogicalIdsList) { // Process language card ids in batches string errorReport = IshSession.Folder25.MoveObjects(_toFolderId, logicalIdBatch.ToArray(), _fromFolderId); ReportErrors(errorReport); currentLogicalIdCount += logicalIdBatch.Count; WriteDebug($"Moving logicalIds.length[{logicalIds.Length}] FromFolderId[{_fromFolderId}] ToFolderId[{ _toFolderId}] {currentLogicalIdCount}/{logicalIds.Length}"); } } // Retrieve moved object(s) to write to the pipeline for a potential security/usergroup change WriteDebug("Retrieving"); var returnIshObjects = new List <IshObject>(); // Add the required fields (needed for pipe operations) IshFields requestedMetadata = IshSession.IshTypeFieldSetup.ToIshRequestedMetadataFields(ISHType, new IshFields(), Enumerations.ActionMode.Read); if (_retrievedIshObjects.Count > 0) { var lngCardIds = _retrievedIshObjects.Select(ishObject => Convert.ToInt64(ishObject.ObjectRef[Enumerations.ReferenceType.Lng])).ToList(); WriteDebug($"Retrieving CardIds.length[{lngCardIds.Count}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] 0/{lngCardIds.Count}"); // Devides the list of language card ids in different lists that all have maximally MetadataBatchSize elements List <List <long> > devidedlngCardIdsList = DevideListInBatches <long>(lngCardIds, IshSession.MetadataBatchSize); int currentLngCardIdCount = 0; foreach (List <long> lngCardIdBatch in devidedlngCardIdsList) { // Process language card ids in batches string xmlIshObjects = IshSession.DocumentObj25.RetrieveMetadataByIshLngRefs( lngCardIdBatch.ToArray(), requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnIshObjects.AddRange(retrievedObjects.Objects); currentLngCardIdCount += lngCardIdBatch.Count; WriteDebug($"Retrieving CardIds.length[{lngCardIdBatch.Count}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] including data {currentLngCardIdCount}/{lngCardIds.Count}"); } } else { // IshObject from pipeline is null. Retrieve using only provided LogicalId array WriteDebug($"Retrieving LogicalId.length[{LogicalId.Length}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] 0/{LogicalId.Length}"); // Devides the list of language card ids in different lists that all have maximally MetadataBatchSize elements List <List <string> > devidedlogicalIdsList = DevideListInBatches <string>(LogicalId.ToList(), IshSession.MetadataBatchSize); int currentLogicalIdCount = 0; foreach (List <string> logicalIdBatch in devidedlogicalIdsList) { // Process language card ids in batches string xmlIshObjects = IshSession.DocumentObj25.RetrieveMetadata(logicalIdBatch.ToArray(), DocumentObj25ServiceReference.StatusFilter.ISHNoStatusFilter, "", requestedMetadata.ToXml()); IshObjects retrievedObjects = new IshObjects(xmlIshObjects); returnIshObjects.AddRange(retrievedObjects.Objects); currentLogicalIdCount += logicalIdBatch.Count; WriteDebug($"Retrieving LogicalId.length[{logicalIdBatch.Count}] RequestedMetadata.length[{requestedMetadata.ToXml().Length}] {currentLogicalIdCount}/{LogicalId.Length}"); } } // Write retrieved objects to pipeline 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)); } finally { base.EndProcessing(); } }