예제 #1
0
        private static void PurgeStructureGroups(CoreServiceClient client, string structureGroups, PurgeOldVersionsInstructionData purgeIntructions, UInt16 versionsToKeep, string pubUri)
        {
            int totalPageVersionsRemoved = 0;

            string[] structureGroupUris = structureGroups.Split(',');

            List<LinkToIdentifiableObjectData> itemsToPurge = new List<LinkToIdentifiableObjectData>();

            for (int i = 0; i < structureGroupUris.Length; i++)
            {
                StructureGroupData structureGroup = null;

                try
                {
                    string localUri = GetLocalUri(pubUri.Trim(), structureGroupUris[i]);

                    // Add sub and subsub-folders to list to prevent timeouts...
                    structureGroup = (StructureGroupData)client.Read(localUri, null);
                }
                catch(Exception ex)
                {
                    continue;
                }

                LinkToIdentifiableObjectData subfolderLink = new LinkToIdentifiableObjectData();
                subfolderLink.IdRef = structureGroup.Id;
                itemsToPurge.Add(subfolderLink);

                var itemTypes = new List<ItemType>();
                itemTypes.Add(ItemType.StructureGroup);

                var filter = new OrganizationalItemItemsFilterData();
                filter.Recursive = true;
                filter.ItemTypes = itemTypes.ToArray();
                purgeIntructions.VersionsToKeep = versionsToKeep;
                purgeIntructions.Recursive = false;

                IdentifiableObjectData[] subSGs = client.GetList(structureGroup.Id, filter);

                foreach (var subSubSG in subSGs)
                {
                    LinkToIdentifiableObjectData structureGroupLink = new LinkToIdentifiableObjectData();
                    structureGroupLink.IdRef = subSubSG.Id;
                    itemsToPurge.Add(structureGroupLink);
                    purgeIntructions.Containers = itemsToPurge.ToArray();

                    try
                    {
                        int versionsCleaned = client.PurgeOldVersions(purgeIntructions);
                        totalPageVersionsRemoved = totalPageVersionsRemoved + versionsCleaned;
                        WriteOutput("Removed " + versionsCleaned.ToString() + " Page Versions");
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    itemsToPurge.Clear();
                }
            }
            WriteOutput("Total Page versions removed is " + totalPageVersionsRemoved.ToString());
        }
예제 #2
0
        private static void PurgeFolders(CoreServiceClient client, string folders, PurgeOldVersionsInstructionData purgeIntructions, UInt16 versionsToKeep, string pubUri)
        {
            int totalCompVersionsRemoved = 0;

            string[] folderUris = folders.Split(',');

            List<LinkToIdentifiableObjectData> itemsToPurge = new List<LinkToIdentifiableObjectData>();

            for (int i = 0; i < folderUris.Length; i++)
            {
                FolderData subFolder = null;

                // Add sub and subsub-folders to list to prevent timeouts...
                try
                {
                    string localUri = GetLocalUri(pubUri.Trim(), folderUris[i]);
                    subFolder = (FolderData)client.Read(localUri, null);
                }
                catch(Exception ex)
                {
                    continue;
                }

                LinkToIdentifiableObjectData subfolderLink = new LinkToIdentifiableObjectData();
                subfolderLink.IdRef = subFolder.Id;
                itemsToPurge.Add(subfolderLink);

                var itemTypes = new List<ItemType>();
                //itemTypes.Add(ItemType.Component);
                itemTypes.Add(ItemType.Folder);
                var filter = new OrganizationalItemItemsFilterData();
                filter.Recursive = true;
                filter.ItemTypes = itemTypes.ToArray();

                purgeIntructions.VersionsToKeep = versionsToKeep;
                purgeIntructions.Recursive = false;

                IdentifiableObjectData[] allSubFolders = client.GetList(subFolder.Id, filter);

                foreach (var aFolder in allSubFolders)
                {
                    LinkToIdentifiableObjectData folderLink = new LinkToIdentifiableObjectData();
                    folderLink.IdRef = aFolder.Id;
                    itemsToPurge.Add(folderLink);
                    purgeIntructions.Containers = itemsToPurge.ToArray();

                    try
                    {
                        int versionsCleaned = client.PurgeOldVersions(purgeIntructions);
                        totalCompVersionsRemoved = totalCompVersionsRemoved + versionsCleaned;
                        WriteOutput("Folder " + folderLink.IdRef + " removed " + versionsCleaned.ToString());
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    itemsToPurge.Clear();
                }
            }
            WriteOutput("Total Component versions removed is " + totalCompVersionsRemoved.ToString());
        }
예제 #3
0
        private static void PurgeStructureGroups(CoreServiceClient client, string structureGroups, PurgeOldVersionsInstructionData purgeIntructions, UInt16 versionsToKeep, string pubUri)
        {
            int totalPageVersionsRemoved = 0;

            string[] structureGroupUris = structureGroups.Split(',');

            List <LinkToIdentifiableObjectData> itemsToPurge = new List <LinkToIdentifiableObjectData>();

            for (int i = 0; i < structureGroupUris.Length; i++)
            {
                StructureGroupData structureGroup = null;

                try
                {
                    string localUri = GetLocalUri(pubUri.Trim(), structureGroupUris[i]);

                    // Add sub and subsub-folders to list to prevent timeouts...
                    structureGroup = (StructureGroupData)client.Read(localUri, null);
                }
                catch (Exception ex)
                {
                    continue;
                }

                LinkToIdentifiableObjectData subfolderLink = new LinkToIdentifiableObjectData();
                subfolderLink.IdRef = structureGroup.Id;
                itemsToPurge.Add(subfolderLink);

                var itemTypes = new List <ItemType>();
                itemTypes.Add(ItemType.StructureGroup);

                var filter = new OrganizationalItemItemsFilterData();
                filter.Recursive = true;
                filter.ItemTypes = itemTypes.ToArray();
                purgeIntructions.VersionsToKeep = versionsToKeep;
                purgeIntructions.Recursive      = false;

                IdentifiableObjectData[] subSGs = client.GetList(structureGroup.Id, filter);

                foreach (var subSubSG in subSGs)
                {
                    LinkToIdentifiableObjectData structureGroupLink = new LinkToIdentifiableObjectData();
                    structureGroupLink.IdRef = subSubSG.Id;
                    itemsToPurge.Add(structureGroupLink);
                    purgeIntructions.Containers = itemsToPurge.ToArray();

                    try
                    {
                        int versionsCleaned = client.PurgeOldVersions(purgeIntructions);
                        totalPageVersionsRemoved = totalPageVersionsRemoved + versionsCleaned;
                        WriteOutput("Removed " + versionsCleaned.ToString() + " Page Versions");
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    itemsToPurge.Clear();
                }
            }
            WriteOutput("Total Page versions removed is " + totalPageVersionsRemoved.ToString());
        }
예제 #4
0
        private static void PurgeFolders(CoreServiceClient client, string folders, PurgeOldVersionsInstructionData purgeIntructions, UInt16 versionsToKeep, string pubUri)
        {
            int totalCompVersionsRemoved = 0;

            string[] folderUris = folders.Split(',');

            List <LinkToIdentifiableObjectData> itemsToPurge = new List <LinkToIdentifiableObjectData>();

            for (int i = 0; i < folderUris.Length; i++)
            {
                FolderData subFolder = null;

                // Add sub and subsub-folders to list to prevent timeouts...
                try
                {
                    string localUri = GetLocalUri(pubUri.Trim(), folderUris[i]);
                    subFolder = (FolderData)client.Read(localUri, null);
                }
                catch (Exception ex)
                {
                    continue;
                }

                LinkToIdentifiableObjectData subfolderLink = new LinkToIdentifiableObjectData();
                subfolderLink.IdRef = subFolder.Id;
                itemsToPurge.Add(subfolderLink);

                var itemTypes = new List <ItemType>();
                //itemTypes.Add(ItemType.Component);
                itemTypes.Add(ItemType.Folder);
                var filter = new OrganizationalItemItemsFilterData();
                filter.Recursive = true;
                filter.ItemTypes = itemTypes.ToArray();

                purgeIntructions.VersionsToKeep = versionsToKeep;
                purgeIntructions.Recursive      = false;

                IdentifiableObjectData[] allSubFolders = client.GetList(subFolder.Id, filter);

                foreach (var aFolder in allSubFolders)
                {
                    LinkToIdentifiableObjectData folderLink = new LinkToIdentifiableObjectData();
                    folderLink.IdRef = aFolder.Id;
                    itemsToPurge.Add(folderLink);
                    purgeIntructions.Containers = itemsToPurge.ToArray();

                    try
                    {
                        int versionsCleaned = client.PurgeOldVersions(purgeIntructions);
                        totalCompVersionsRemoved = totalCompVersionsRemoved + versionsCleaned;
                        WriteOutput("Folder " + folderLink.IdRef + " removed " + versionsCleaned.ToString());
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    itemsToPurge.Clear();
                }
            }
            WriteOutput("Total Component versions removed is " + totalCompVersionsRemoved.ToString());
        }
예제 #5
0
 public IdentifiableObjectData[] GetList(string id, SubjectRelatedListFilterData filter)
 {
     return(_client.GetList(id, filter));
 }