當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Service.getService函數代碼示例

本文整理匯總了TypeScript中VSS/Service.getService函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getService函數的具體用法?TypeScript getService怎麽用?TypeScript getService使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getService函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getService

        return getService(CacheableQueryService).getCacheableQueryResult(new MetadataQuery(projectId, MetadataQuery.WorkItemSnapshot)).then(metadata => {
            this.state.configOptions.metadata = metadata;
            return getService(CacheableQueryService).getCacheableQueryResult(new WitFieldsQuery(projectId)).then(typeFields => {
                this.state.configOptions.typeFields = typeFields;
                if (typeFields) {
                    this.state.configOptions.types = this.filterUniqueTypes(typeFields, projectId);

                    //if work item type isn't selected, choose a default. For sample purpose, use the first type.
                    if (this.state.configuration.workItemType == null) {
                        if (this.state.configOptions.types.length > 0) {
                            this.state.configuration.workItemType = this.state.configOptions.types[0];
                        } else {
                            throw "No WorkItemTypes were found on the active project.";
                        }

                    }

                    this.state.configOptions.fields = this.filterFieldsOfType(typeFields, this.state.configuration.workItemType, projectId, this.state.configOptions.metadata,(o)=>{ return this.isAcceptedFilterField(o);});
                    this.updateFieldFilterControlOptions();
                    this.updateAggregationControlOptions();
                    return this.state;
                }
                this.notifyListenersOfStateChange(this.state);
                return this.state;
            });
        })
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:26,代碼來源:AnalyticsConfigActionCreator.ts

示例2: requestData

    public requestData(): IPromise<QueryViewState> {
        let context = VSS.getWebContext();    
        this.results.isLoading = true;    

        if (!areSettingsValid(this.configuration)) {
            return this.packErrorMessage("This widget is not properly configured yet.");
        }

        let now : number = Date.now();
        let endDate : Date = new Date(now);
        let startDate : Date = new Date(now - (this.rollingPeriodLength * 1000 * 60 * 60 * 24)); // Rolling 60 day period from the current timestamp.

        let querySettings = {
            projectId: this.configuration.projectId,
            teamId: this.configuration.teamId,
            workItemType: this.configuration.workItemType,
            fields: this.configuration.fields,
            startDate: startDate,
            endDate: endDate,
            aggregation: this.configuration.aggregation
        } as BurndownQueryOptions;

        return getService(CacheableQueryService).getCacheableQueryResult(new DatesQuery()).then(dates => {
            return getService(CacheableQueryService).getCacheableQueryResult(new BurndownResultsQuery(querySettings)).then(groupedWorkItemAggregation => {
                if (groupedWorkItemAggregation.length > 0) {
                    this.results.chartState = new ChartOptionFactory().generateChart(this.size, groupedWorkItemAggregation, dates, this.suppressAnimation)
                } else {
                    this.results.statusMessage = "0 results were found for this query.";
                    this.results.messageType = WidgetMessageType.Warning;
                }
                this.results.isLoading = false;
                return this.results;
            });
        });
    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:35,代碼來源:AnalyticsViewActionCreator.ts

示例3: runQuery

    public runQuery(): IPromise<PopularValueQueryResults[]> {
        return getService(CacheableQueryService).getCacheableQueryResult(new MetadataQuery(this.popularValueQueryOptions.projectId, MetadataQuery.WorkItemSnapshot)).then(result => {
            return ODataClient.getInstance().then((client) => {

                let entity = "WorkItemSnapshot";
                let teamFilter = `Teams/any(t:t/TeamSK eq ${this.popularValueQueryOptions.teamId})`;
                let typeFilter = `(WorkItemType eq '${this.popularValueQueryOptions.workItemType}')`;                

                let filter = `${teamFilter} and ${typeFilter}`;
                let fieldQueryingname = mapReferenceNameForQuery(this.popularValueQueryOptions.fieldName, result);
                let groupFields = `${fieldQueryingname}`;
                let aggregation = `$count as Frequency`;
                let aggregationQuery = `${entity}?$apply=filter(${filter})/groupby((${groupFields}),aggregate(${aggregation}))`;

                let fullQueryUrl = client.generateProjectLink(this.popularValueQueryOptions.projectId, aggregationQuery);
                return client.runGetQuery(fullQueryUrl).then((results: any) => {
                    let resultSet = results["value"];
                    if (resultSet === undefined) {
                        return [];
                    } else {
                        resultSet.forEach(element => {
                            //Re-map the field name to be "Value" for strong type consistency
                            let temp = element[fieldQueryingname];
                            element.Value = temp;
                        });
                        return resultSet;
                    }
                });
            });
        });
    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:31,代碼來源:PopularValueQuery.ts

示例4: loadValues

    public loadValues(fieldName: string) {
        let queryOptions = {
            projectId: this.state.configuration.projectId,
            teamId: this.state.configuration.teamId,
            workItemType: this.state.configuration.workItemType,
            fieldName: fieldName
        };
        return getService(CacheableQueryService).getCacheableQueryResult(new PopularValueQuery(queryOptions));

    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:10,代碼來源:AnalyticsConfigActionCreator.ts

示例5: loadTeams

    private loadTeams(projectId: string): IPromise<AnalyticsConfigState> {
        return getService(CacheableQueryService).getCacheableQueryResult(new TeamsQuery(projectId)).then(teams => {
            this.state.configOptions.teams = teams;

            if (!this.state.configuration.teamId) {
                this.state.configuration.teamId = teams[0].TeamId;
            }
            this.notifyListenersOfStateChange(this.state);
            return this.state;
        });
    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:11,代碼來源:AnalyticsConfigActionCreator.ts

示例6: getService

 return getService(CacheableQueryService).getCacheableQueryResult(new DatesQuery()).then(dates => {
     return getService(CacheableQueryService).getCacheableQueryResult(new BurndownResultsQuery(querySettings)).then(groupedWorkItemAggregation => {
         if (groupedWorkItemAggregation.length > 0) {
             this.results.chartState = new ChartOptionFactory().generateChart(this.size, groupedWorkItemAggregation, dates, this.suppressAnimation)
         } else {
             this.results.statusMessage = "0 results were found for this query.";
             this.results.messageType = WidgetMessageType.Warning;
         }
         this.results.isLoading = false;
         return this.results;
     });
 });
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:12,代碼來源:AnalyticsViewActionCreator.ts

示例7: updateFieldFilterFieldState

    /**
     * Update visual state of filters to reflect new field, and then ensure the value picker settings for the current state is up to date.
     */
    public updateFieldFilterFieldState(rowIndex: number, field: WorkItemTypeField) {
        let row = this.state.configOptions.fieldFilter.fieldFilterRowValues[rowIndex];
        let priorState = row.settings.fieldReferenceName;
        row.settings.fieldReferenceName = field.FieldReferenceName;
        row.settings.fieldType = field.FieldType;
        row.settings.value = null;
        this.notifyListenersOfStateChange(this.state);

        return getService(CacheableQueryService).getCacheableQueryResult(new MetadataQuery(this.state.configuration.projectId, MetadataQuery.WorkItemSnapshot)).then(metadata => {
            row.settings.fieldQueryName = mapReferenceNameForQuery(field.FieldReferenceName, metadata);

            if (priorState != field.FieldReferenceName) {
                this.loadSuggestedFieldValues(this.state.configuration.projectId, this.state.configuration.teamId, this.state.configuration.workItemType, field.FieldReferenceName).then(() => {
                    this.notifyListenersOfStateChange(this.state);
                })
            }
        });
    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:21,代碼來源:AnalyticsConfigActionCreator.ts

示例8: loadSuggestedFieldValues

 private loadSuggestedFieldValues(projectId: string, teamId: string, workItemType: string, fieldName: string): IPromise<AnalyticsConfigState> {
     let params = {
         projectId: projectId,
         teamId: teamId,
         workItemType: workItemType,
         fieldName: fieldName
     };
     return getService(CacheableQueryService).getCacheableQueryResult(new PopularValueQuery(params)).then(results => {
         let suggestedValues = this.sortAllowedValues(results);
         //Update Fields matching the result FieldName.            
         this.state.configOptions.fieldFilter.fieldFilterRowValues.forEach(o => {
             if (o.settings.fieldReferenceName == fieldName) {
                 o.suggestedValues = suggestedValues;
                 if (o.settings.value == null) {
                     o.settings.value = (o.suggestedValues.length > 0) ? o.suggestedValues[0] : null;
                 }
             }
         });
         return this.state;
     });
 }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:21,代碼來源:AnalyticsConfigActionCreator.ts

示例9: requestData

    public requestData(): IPromise<AnalyticsConfigState> {
        if (!this.state.configuration.projectId) {
            this.state.configuration.projectId = VSS.getWebContext().project.id;
            this.state.configuration.teamId = VSS.getWebContext().team.id;
        }

        if (!this.state.configuration.aggregation) {
            this.state.configuration.aggregation = { aggregationMode: AggregationMode.count, displayName: null, queryableName: null, fieldReferenceName: null}
        }

        return getService(CacheableQueryService).getCacheableQueryResult(new ProjectsQuery()).then(projects => {
            this.state.configOptions.projects = projects;
            this.notifyListenersOfStateChange(this.state);

            //If we have a project selected, keep loading on other data.
            let teamPromise = this.state.configuration.projectId ? this.loadTeams(this.state.configuration.projectId) : this.endChain();
            return teamPromise.then((teams) => {
                return this.loadTypeFields(this.state.configuration.projectId).then(() => {
                    return this.state;
                });
            });
        });
    }
開發者ID:Microsoft,項目名稱:vsts-extension-samples,代碼行數:23,代碼來源:AnalyticsConfigActionCreator.ts


注:本文中的VSS/Service.getService函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。