Esempio n. 1
0
        /// <summary>
        /// Create an ItemBuilder which allows you to create organizational items (keywords, folders and structure groups) quickly by passing in an Excel
        /// File with the data. Optionally - you can also pass in a secondary spreadsheet which allows you to provide further information about the items being created
        /// such as linked schemas, metadata information - etc.
        /// </summary>
        /// <param name="client">session-aware core service client</param>
        /// <param name="publicationName">name of the publication to create the item in ie '010 Schemas'</param>
        /// <param name="xlsxPath">The xlsx path of the file (if file in same directory as exe, pass "file-name.exe".</param>
        public ItemBuilder(SessionAwareCoreServiceClient client, string publicationName, string xlsxPath)
        {
            try
            {
                ExcelReader = new ExcelReader(xlsxPath);
            }
            catch (Exception e)
            {
                throw new Exception($"Something went wrong deserializing .xlsx file(s) {e.Message}");
            }

            _publicationName = publicationName;

            FolderBuilder         = new FolderBuilder(client);
            StructureGroupBuilder = new StructureGroupBuilder(client);
            KeywordBuilder        = new KeywordBuilder(client);
        }
Esempio n. 2
0
        /// <summary>
        /// Create the structure groups from the xlsx file under the structure group name passed as input.
        /// </summary>
        /// <param name="structureGroupName">Name of the structure group to create the structure groups under. Leave empty for "Root".</param>
        public void CreateStructureGroups(string structureGroupName = null)
        {
            foreach (var sgPath in ExcelReader.PendingItems)
            {
                var sgWebdav = WebDavBase;
                sgWebdav += Constants.Root;
                sgWebdav += !string.IsNullOrEmpty(structureGroupName)
                    ? Constants.Slash + structureGroupName
                    : string.Empty;
                sgWebdav += Constants.Slash + sgPath;

                StructureGroupBuilder.RootSgWebDav         = WebDavBase + structureGroupName;
                StructureGroupBuilder.StructureGroupWebDav = sgPath;

                Console.WriteLine($"Creating structure group at path {sgWebdav}");
                StructureGroupBuilder.GetOrCreateOrganizationalItem(sgWebdav);
            }
        }