Exemplo n.º 1
0
        protected override void QueryExtendedProperties() // abstract
        {
            var clientTermStore = this.DownloaderContext.TermStoreDownloader.ClientTermStore;

            int defaultLcid = clientTermStore.DefaultLanguage;

            this.SetClientWorkingLanguageToDefault();

            this.ClientContext.Load(this.ClientTermSet,
                                    termSet => termSet.Contact,
                                    termSet => termSet.CustomSortOrder,
                                    termSet => termSet.Description,
                                    termSet => termSet.IsAvailableForTagging,
                                    termSet => termSet.IsOpenForTermCreation,
                                    termSet => termSet.Owner,
                                    termSet => termSet.CustomProperties,
                                    termSet => termSet.Stakeholders);

            using (this.ClientConnector.WorkingLanguageManager.StartUnmanagedScope(clientTermStore))
            {
                this.localizedNameQueries = TermSetLocalizedNameQuery.Load(
                    this.ClientTermSet,
                    this.DownloaderContext.GetLcidsToRead(),
                    defaultLcid,
                    clientTermStore,
                    this.ClientConnector
                    );
            }
        }
Exemplo n.º 2
0
        /// <remarks>
        /// This method is sometimes called inside a CSOM execution scope, so it
        /// has to use SetUnmanagedWorkingLanguageForTermStore().  The caller must
        /// set up an unmanaged scope using WorkingLanguageManager.StartUnmanagedScope().
        /// </remarks>
        public static List <TermSetLocalizedNameQuery> Load(TermSet clientTermSet,
                                                            IEnumerable <int> lcidsToRead, int defaultLcid,
                                                            TermStore clientTermStore, Client15Connector clientConnector)
        {
            var clientContext = clientConnector.ClientContext;

            var list = new List <TermSetLocalizedNameQuery>();

            foreach (int lcid in lcidsToRead)
            {
                if (lcid == defaultLcid)
                {
                    continue; // we already read this as clientTermSet.Name
                }
                clientConnector.WorkingLanguageManager
                .SetUnmanagedWorkingLanguageForTermStore(clientTermStore, lcid);

                var localizedNameQuery = new TermSetLocalizedNameQuery();
                // Since we want to read just one property, which is a property that we already
                // read in the same ExecuteQuery() transaction, we need to construct a separate
                // CSOM object to hold the result.
                // (This apparently causes the Id/Name to get refetched a second time
                // by QueryChildObjects().)
                localizedNameQuery.ClientTermSet = new TermSet(clientContext, clientTermSet.Path);
                localizedNameQuery.Lcid          = lcid;

                clientContext.Load(localizedNameQuery.ClientTermSet, ts => ts.Name);

                list.Add(localizedNameQuery);
            }

            return(list);
        }
Exemplo n.º 3
0
        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);
        }