コード例 #1
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            ExportImportHelpers.WriteStartupBanner(this.AppLog);

            // Validate parameters
            string targetFilename = this.GetTargetFilename();

            this.AppLog.WriteInfo("TAXML output will be written to " + targetFilename);
            this.AppLog.WriteLine();

            ExportImportHelpers.ValidateSiteUrl(this.SiteUrl);

            // Fetch objects from SharePoint
            this.AppLog.WriteInfo("Connecting to SharePoint site: " + this.SiteUrl);
            Client15Connector clientConnector = ExportImportHelpers.CreateClientConnector(
                this.SiteUrl, this.Credential, this.CloudCredential, this.AppLog);

            clientConnector.DownloadedItem += this.clientConnector_DownloadedItem;

            List <LocalTermStore> fetchedTermStores = clientConnector.FetchTermStores();

            Guid?optionalTermStoreId = null;

            if (this.MyInvocation.BoundParameters.ContainsKey(ExportTaxmlCommand.PropertyName_TermStoreId))
            {
                optionalTermStoreId = this.TermStoreId;
            }
            LocalTermStore termStore = ExportImportHelpers.SelectTermStore(fetchedTermStores, optionalTermStoreId);

            this.AppLog.WriteInfo("Fetching items from TermStore \"" + termStore.Name + "\"");

            ClientConnectorDownloadOptions options = new ClientConnectorDownloadOptions();

            if (this.GroupIdFilter != null && this.GroupIdFilter.Length > 0)
            {
                options.EnableGroupIdFilter(this.GroupIdFilter);
            }

            LocalTermStore outputTermStore = new LocalTermStore(termStore.Id, termStore.Name);

            clientConnector.Download(outputTermStore, options);
            this.AppLog.WriteInfo("Finished fetching items.");

            // Write output
            this.AppLog.WriteLine();
            this.AppLog.WriteInfo("Writing TAXML output: " + targetFilename);
            TaxmlSaver saver = new TaxmlSaver();

            saver.SaveToFile(targetFilename, outputTermStore);

            this.AppLog.WriteLine();
            this.AppLog.WriteInfo("The operation completed successfully.");
            this.AppLog.WriteLine();
        }
コード例 #2
0
        /// <summary>
        /// Retrieve the taxonomy objects that were created in SharePoint,
        /// and return them as a TAXML string.
        /// </summary>
        private static string DownloadTestDataAsTaxml(Client15Connector connector)
        {
            Debug.WriteLine("DownloadTestDataAsTaxml()");
            ClientConnectorDownloadOptions options = new ClientConnectorDownloadOptions();

            options.EnableGroupIdFilter(SampleData.TestGroupIds);
            LocalTermStore outputTermStore = new LocalTermStore(SampleData.TermStoreId, "");

            connector.Download(outputTermStore, options);

            return(TaxmlSaver.SaveToString(outputTermStore));
        }