internal void NotifyDownloadedItem(LocalTaxonomyItem localTaxonomyItem, bool willFetchChildren) { if (this.DownloadedItem != null) { this.DownloadedItem(this, new DownloadedItemEventArgs(localTaxonomyItem, willFetchChildren)); } }
internal void NotifyUploadingItem(LocalTaxonomyItem localTaxonomyItem, int itemsUploaded, int totalItems) { if (this.UploadingItem != null) { this.UploadingItem(this, new UploadingItemEventArgs(localTaxonomyItem, itemsUploaded, totalItems)); } }
private TaxonomyItemUploader CreateUploader(LocalTaxonomyItem item) { TaxonomyItemUploader uploader; switch (item.Kind) { case LocalTaxonomyItemKind.TermStore: return(null); case LocalTaxonomyItemKind.TermGroup: uploader = new TermGroupUploader((LocalTermGroup)item, this); break; case LocalTaxonomyItemKind.TermSet: uploader = new TermSetUploader((LocalTermSet)item, this); break; case LocalTaxonomyItemKind.Term: uploader = new TermUploader((LocalTerm)item, this); break; default: throw new NotSupportedException(); } this.uploadersByItem.Add(item, uploader); this.queuedUploaders.Add(uploader); return(uploader); }
private void CheckForUnimplementedSyncActions(LocalTaxonomyItem item) { string error = null; var syncAction = item.SyncAction; if (syncAction != null) { if (syncAction.DeleteExtraChildItems) { error = "The DeleteExtraChildItems attribute is not implemented yet"; } switch (syncAction.IfElsewhere) { case SyncActionIfElsewhere.Error: break; default: error = "The IfElsewhere=" + syncAction.IfElsewhere.ToString() + " option is not implemented yet"; break; } switch (syncAction.IfPresent) { case SyncActionIfPresent.Update: case SyncActionIfPresent.OnlyUpdateChildItems: case SyncActionIfPresent.Error: break; default: error = "The IfPresent=" + syncAction.IfPresent.ToString() + " option is not implemented yet"; break; } switch (syncAction.IfMissing) { case SyncActionIfMissing.Create: case SyncActionIfMissing.Error: break; default: error = "The IfMissing=" + syncAction.IfMissing.ToString() + " option is not implemented yet"; break; } } if (error != null) { throw new NotImplementedException(error + "\r\nItem: " + item.ToString()); } }
// If we are creating a reused instance of a term, this locates the source term // (i.e. this.clientTermOtherInstance). private bool LoadClientTermOtherInstanceForTermLink() { if (this.localTerm.TermKind == LocalTermKind.TermLinkUsingId) { // Is the source term something that we're supposed to be creating in this data set? var localTermStore = this.Controller.LocalTermStore; var localSourceTerm = this.localTerm.SourceTerm; if (localSourceTerm != null) { TermUploader sourceTermUploader = (TermUploader)this.Controller.GetUploader(localSourceTerm); if (!sourceTermUploader.FoundClientObject) { this.WaitForBlocker(sourceTermUploader); return(false); } this.clientTermOtherInstance = sourceTermUploader.ClientTerm; } } else { Debug.Assert(this.localTerm.TermKind == LocalTermKind.TermLinkUsingPath); if (this.termLinkSourcePathPartLookups == null) { this.termLinkSourcePathPartLookups = new List <TermLinkSourcePathPartLookup>(); foreach (string partName in this.localTerm.GetTermLinkSourcePathParts()) { this.termLinkSourcePathPartLookups.Add(new TermLinkSourcePathPartLookup(partName)); } // See how far we can get by matching objects from the LocalTermStore LocalTaxonomyItem localParentItem = this.Controller.LocalTermStore; foreach (TermLinkSourcePathPartLookup lookup in this.termLinkSourcePathPartLookups) { LocalTaxonomyItem localItem = localParentItem.ChildItems .FirstOrDefault(x => x.Name == lookup.PartName); if (localItem != null) { lookup.LocalTaxonomyItem = localItem; Debug.Assert(lookup.ItemIsInLocalTermStore); lookup.Uploader = this.Controller.GetUploader(localItem); localParentItem = localItem; } } } // Make sure the local parents have been created/found foreach (TermLinkSourcePathPartLookup lookup in this.termLinkSourcePathPartLookups) { if (!lookup.ItemIsInLocalTermStore) { break; } if (!lookup.Uploader.FoundClientObject) { this.WaitForBlocker(lookup.Uploader); return(false); } lookup.ClientObject = lookup.Uploader.ClientTaxonomyItem; Debug.Assert(lookup.ClientObject != null); } if (this.termLinkSourcePathPartLookups.Any(x => !x.ItemIsInLocalTermStore)) { this.SetClientWorkingLanguageToDefault(); this.termLinkSourcePathExceptionHandlingScope = new ExceptionHandlingScope(this.ClientContext); using (this.termLinkSourcePathExceptionHandlingScope.StartScope()) { using (this.termLinkSourcePathExceptionHandlingScope.StartTry()) { // For anything else, we need to query it ourselves for (int i = 0; i < this.termLinkSourcePathPartLookups.Count; ++i) { TermLinkSourcePathPartLookup lookup = this.termLinkSourcePathPartLookups[i]; if (lookup.ItemIsInLocalTermStore) { continue; } // NOTE: For these queries we don't use CsomHelpers.FlushCachedProperties() // because the objects are outside the LocalTermStore, so we don't need to // worry about the cached copies getting invalidated by the uploaders. if (i == 0) { // Find a Group lookup.ClientObject = this.Controller.ClientTermStore.Groups.GetByName(lookup.PartName); } else if (i == 1) { // Find a TermSet TermGroup clientGroup = (TermGroup)this.termLinkSourcePathPartLookups[0].ClientObject; lookup.ClientObject = clientGroup.TermSets.GetByName(lookup.PartName); } else { // Find a term TermSetItem clientTermContainer = (TermSetItem)this.termLinkSourcePathPartLookups[i - 1].ClientObject; lookup.ClientObject = clientTermContainer.Terms.GetByName(lookup.PartName); } } } using (this.termLinkSourcePathExceptionHandlingScope.StartCatch()) { } } } this.clientTermOtherInstance = (Term)this.termLinkSourcePathPartLookups.Last().ClientObject; Debug.Assert(this.clientTermOtherInstance != null); } return(true); }
private void clientConnector_UploadingItem(object sender, UploadingItemEventArgs e) { string message = ""; bool wroteTerm = false; for (LocalTaxonomyItem item = e.LocalTaxonomyItem; item != null; item = item.ParentItem) { string header = null; switch (item.Kind) { case LocalTaxonomyItemKind.Term: if (!wroteTerm) { switch (((LocalTerm)item).TermKind) { case LocalTermKind.NormalTerm: header = "TERM"; break; default: header = "TERMLINK"; break; } } wroteTerm = true; break; case LocalTaxonomyItemKind.TermSet: header = "TERMSET"; break; case LocalTaxonomyItemKind.TermGroup: header = "GROUP"; break; } if (header != null) { if (message.Length > 0) { message = " " + message; } message = header + ": \"" + item.Name + "\"" + message; } } double percent = 0; if (e.TotalItems != 0) { percent = e.ItemsUploaded * 100.0 / e.TotalItems; } var progressRecord = new ProgressRecord(0, ImportTaxmlCommand.ProgressRecordTitle, string.Format("{0} of {1} items completed", e.ItemsUploaded, e.TotalItems)); progressRecord.PercentComplete = (int)(e.ItemsUploaded * 100.0 / e.TotalItems); this.WriteProgress(progressRecord); this.AppLog.WriteInfo(message); }
internal TaxonomyItemUploader GetUploader(LocalTaxonomyItem item) { return(this.uploadersByItem[item]); }
public UploadingItemEventArgs(LocalTaxonomyItem localTaxonomyItem, int itemsUploaded, int totalItems) { this.LocalTaxonomyItem = localTaxonomyItem; this.ItemsUploaded = itemsUploaded; this.TotalItems = totalItems; }
public DownloadedItemEventArgs(LocalTaxonomyItem localTaxonomyItem, bool willFetchChildItems) { this.LocalTaxonomyItem = localTaxonomyItem; this.WillFetchChildItems = willFetchChildItems; }