当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript log.write方法代码示例

本文整理汇总了TypeScript中sp-pnp-js.log.write方法的典型用法代码示例。如果您正苦于以下问题:TypeScript log.write方法的具体用法?TypeScript log.write怎么用?TypeScript log.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sp-pnp-js.log的用法示例。


在下文中一共展示了log.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getNavigationNodes

    private getNavigationNodes(termSetId: string): void {

        if (!termSetId) {

            pnp.log.write("The term set id for the header links is null. Please specify a valid term set id in the configuration list", pnp.LogLevel.Error);

        } else {

            // Ensure all SP dependencies are loaded before retrieving navigation nodes
            this.taxonomyModule.init().then(() => {

            // Initialize the main menu with taxonomy terms            
            this.taxonomyModule.getNavigationTaxonomyNodes(new SP.Guid(termSetId)).then(navigationTree => {

                        // Initialize the mainMenu view model
                        this.initialize(navigationTree);
                        this.wait(false);

                        let now: Date = new Date();

                        // Set the navigation tree in the local storage of the browser
                        pnp.storage.local.put(this.localStorageKey, this.utilityModule.stringifyTreeObject(navigationTree), new Date(now.setDate(now.getDate() + 7)));

                }).catch(errorMesssage => {

                    pnp.log.write(errorMesssage, pnp.LogLevel.Error);
                });

            }).catch(errorMesssage => {

                pnp.log.write(errorMesssage, pnp.LogLevel.Error);
            });
        }
    }
开发者ID:kaminagi107,项目名称:PnP,代码行数:34,代码来源:headerlinks.viewmodel.ts

示例2: getTermById

    /**
     * Get a single term by its Id using the current taxonomy context.
     * @param  {SP.Guid} termId The taxonomy term Id
     * @return {Promise<SP.Taxonomy.Term>}       A promise containing the term infos.
     */
    public getTermById(termId: SP.Guid): Promise<SP.Taxonomy.Term> {

        if (termId) {

            let context: SP.ClientContext = SP.ClientContext.get_current();

            let taxSession: SP.Taxonomy.TaxonomySession  = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
            let termStore: SP.Taxonomy.TermStore = taxSession.getDefaultSiteCollectionTermStore();

            termStore.set_workingLanguage(this.workingLanguage);

            let term: SP.Taxonomy.Term = termStore.getTerm(termId);

            context.load(term, "Name");

            let p = new Promise<SP.Taxonomy.Term>((resolve, reject) => {

                context.executeQueryAsync(() => {

                    resolve(term);

                },  (sender, args) => {

                    reject("Request failed. " + args.get_message() + "\n" + args.get_stackTrace());
                });
            });

            return p;

        } else {
            pnp.log.write("TaxonomyModule.getTermById: the provided term id is null!", pnp.LogLevel.Error);
        }
    }
开发者ID:kaminagi107,项目名称:PnP,代码行数:38,代码来源:taxonomy.ts

示例3:

            pnp.sp.web.lists.getByTitle("Pages").items.getById(_spPageContextInfo.pageItemId).select(this.siteMapFieldName).get().then((item) => {

                    let siteMapTermGuid = item[this.siteMapFieldName];
                    let currentNode: NavigationNode = undefined;

                    if (siteMapTermGuid) {

                        // 1: Search for this guid in the site map
                        currentNode = this.utilityModule.getNodeByTermId(navigationTree, siteMapTermGuid.TermGuid);
                    }

                    if (currentNode === undefined) {

                        // 2: Get the navigation node according to the current URL   
                        currentNode = this.utilityModule.getNodeByUrl(navigationTree, window.location.pathname);
                    }

                    if (currentNode !== undefined) {

                        // If there is no 'ParentId', this is a root term
                        if (currentNode.ParentId !== null) {


                            let parentNode = this.utilityModule.getNodeByTermId(navigationTree, new SP.Guid(currentNode.ParentId));

                            // Set the parent section
                            this.parentSection(parentNode);

                            if (parentNode.ChildNodes.length > 0) {

                                // Display all siblings and child nodes from the current node (just like the CSOM results)
                                // Siblings = children of my own parent ;)
                                navigationTree = parentNode.ChildNodes;

                                // Set the current node as first item
                                navigationTree = this.utilityModule.moveItem(navigationTree, navigationTree.indexOf(currentNode), 0);
                            }
                        }

                    } else {

                        pnp.log.write("[Contextual Menu] Unable to determine the current position in the site map", pnp.LogLevel.Warning);
                    }

                    this.initialize(navigationTree);
                    this.wait(false);

                    if (currentNode !== undefined) {

                        this.setCurrentNode(new SP.Guid(currentNode.Id));
                    }

            }).catch((errorMesssage) => {
开发者ID:kaminagi107,项目名称:PnP,代码行数:53,代码来源:contextualmenu.viewmodel.ts

示例4:

        pnp.sp.site.rootWeb.lists.getByTitle(configListName).items.filter(filterQuery).top(1).get().then((item) => {

            if (item.length > 0) {

                // Get the boolean value
                let noCache: boolean = item[0].ForceCacheRefresh;

                // Get the term set id
                let termSetId = item[0].SiteMapTermSetId;

                if (noCache) {

                        // Clear the local storage value
                        pnp.storage.local.delete(this.localStorageKey);

                        // Get navigation nodes
                        this.getNavigationNodes(termSetId);

                } else {

                    let navigationTree = this.utilityModule.isCacheValueValid(this.localStorageKey);

                    // Check if the local storage value is still valid (i.e not null)
                    if (navigationTree) {

                        this.initialize(navigationTree);
                        this.wait(false);

                        // Publish the data to all subscribers (contextual menu and breadcrumb) 
                        PubSub.publish("navigationNodes", { nodes: navigationTree } );

                    } else {

                        this.getNavigationNodes(termSetId);
                    }
                }

            } else {

                pnp.log.write("There is no configuration item for the site map for the language '" + currentLanguage + "'", pnp.LogLevel.Error);
            }

        }).catch(errorMesssage => {
开发者ID:kaminagi107,项目名称:PnP,代码行数:43,代码来源:topnav.viewmodel.ts

示例5:

        pnp.sp.site.rootWeb.lists.getByTitle(configListName).items.filter(filterQuery).top(1).get().then((item) => {

            if (item.length > 0) {

                // Get the boolean value
                let noCache: boolean = item[0].ForceCacheRefresh;

                // Get the term set id
                let termSetId = item[0].HeaderLinksTermSetId;

                if (noCache) {

                        // Clear the local storage value
                        pnp.storage.local.delete(this.localStorageKey);

                        // Get navigation nodes
                        this.getNavigationNodes(termSetId);

                } else {

                    let navigationTree = this.utilityModule.isCacheValueValid(this.localStorageKey);

                    // Check if the local storage value is still valid
                    if (navigationTree) {

                        this.initialize(navigationTree);
                        this.wait(false);

                    } else {

                        this.getNavigationNodes(termSetId);
                    }
                }

            } else {

                pnp.log.write("There is no configuration item for this site", pnp.LogLevel.Warning);
            }

        }).catch(errorMesssage => {
开发者ID:kaminagi107,项目名称:PnP,代码行数:40,代码来源:headerlinks.viewmodel.ts

示例6:

        }).catch((errorMesssage) => {

            pnp.log.write(errorMesssage, pnp.LogLevel.Error);
        });
开发者ID:kaminagi107,项目名称:PnP,代码行数:4,代码来源:languageswitcher.viewmodel.ts


注:本文中的sp-pnp-js.log.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。