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(); }
/// <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)); }
private void btnDownload_Click(object sender, EventArgs e) { LocalTermStore selectedTermStore = this.txtTermStore.SelectedItem as LocalTermStore; if (selectedTermStore == null) { throw new InvalidOperationException("No selection"); } MainForm mainForm = this.MainForm; if (mainForm == null) { throw new InvalidOperationException("No main form"); } DocumentView documentView = null; using (DownloadTaxonomyForm downloadForm = new DownloadTaxonomyForm(selectedTermStore)) { downloadForm.ShowDialog(this); using (DownloadProgressForm progressForm = new DownloadProgressForm()) { progressForm.ShowDialog(delegate() { // @@ Improve this progressForm.ProgressBar.Style = ProgressBarStyle.Marquee; ClientConnectorDownloadOptions options = downloadForm.GetTaxonomyReadOptions(); LocalTermStore termStoreCopy = new LocalTermStore(selectedTermStore.Id, selectedTermStore.Name); this.connector.Download(termStoreCopy, options); documentView = new DocumentView(); documentView.LoadTermStore(termStoreCopy); } ); } } if (documentView != null) { mainForm.AddTab(documentView); } }
public ClientConnectorDownloadOptions GetTaxonomyReadOptions() { ClientConnectorDownloadOptions options = new ClientConnectorDownloadOptions(); if (this.radDepthTerms.Checked) { options.MaximumDepth = -1; } else if (this.radDepthTermSets.Checked) { options.MaximumDepth = 2; } else { options.MaximumDepth = 1; } options.MinimalAtMaximumDepth = false; return(options); }