protected override bool OnProcessCreate() { TermGroupUploader groupUploader = (TermGroupUploader)this.GetParentUploader(); Debug.Assert(groupUploader.FoundClientObject && groupUploader.ClientTermGroup != null); Guid id = this.localTermSet.Id; if (id == Guid.Empty) { id = this.Controller.ClientConnector.GetNewGuid(); } // This is needed since we query ts.Name below this.SetClientWorkingLanguageToDefault(); this.clientTermSet = groupUploader.ClientTermGroup.CreateTermSet(this.localTermSet.Name, id, this.Controller.DefaultLanguageLcid); this.ClientContext.Load(this.clientTermSet, ts => ts.Id, ts => ts.Name ); return(true); }
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); }
protected override bool OnProcessCheckExistence() { this.clientTermSet = null; this.localizedNameQueries = null; TermGroupUploader groupUploader = (TermGroupUploader)this.GetParentUploader(); if (!groupUploader.FoundClientObject) { this.WaitForBlocker(groupUploader); return(false); } Debug.Assert(groupUploader.ClientTermGroup != null); this.SetClientWorkingLanguageToDefault(); using (this.Controller.ClientConnector.WorkingLanguageManager.StartUnmanagedScope(this.ClientTermStore)) { this.exceptionHandlingScope = new ExceptionHandlingScope(this.ClientContext); using (this.exceptionHandlingScope.StartScope()) { using (this.exceptionHandlingScope.StartTry()) { if (this.FindByName) { CsomHelpers.FlushCachedProperties(groupUploader.ClientTermGroup.TermSets); this.clientTermSet = groupUploader.ClientTermGroup.TermSets .GetByName(this.localTermSet.Name); } else { // TODO: If "elsewhere" isn't needed, then we // can get this directly from groupUploader.ClientChildTermSets CsomHelpers.FlushCachedProperties(this.ClientTermStore); this.clientTermSet = this.ClientTermStore .GetTermSet(this.localTermSet.Id); } var conditionalScope = new ConditionalScope(this.ClientContext, () => this.clientTermSet.ServerObjectIsNull.Value, allowAllActions: true); using (conditionalScope.StartScope()) { using (conditionalScope.StartIfFalse()) { // TODO: If SyncAction.DeleteExtraChildItems==false, then we can skip this this.ClientContext.Load(this.clientTermSet, ts => ts.Id, ts => ts.Name, ts => ts.Group.Id, ts => ts.CustomProperties, ts => ts.Stakeholders, // For AssignClientChildItems() // TODO: We can sometimes skip this ts => ts.Terms.Include(t => t.Id) ); this.localizedNameQueries = TermSetLocalizedNameQuery.Load( this.clientTermSet, this.Controller.ClientLcids, this.Controller.DefaultLanguageLcid, this.ClientTermStore, this.Controller.ClientConnector ); } } } using (this.exceptionHandlingScope.StartCatch()) { } } } return(true); }
protected override bool IsPlacedCorrectly() { TermGroupUploader groupUploader = (TermGroupUploader)this.GetParentUploader(); return(this.clientTermSet.Group.Id == groupUploader.ClientTermGroup.Id); }