How to use the @bentley/imodeljs-common.IModelReadRpcInterface.getClient function in @bentley/imodeljs-common

To help you get started, we’ve selected a few @bentley/imodeljs-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / imodelindex / ViewsList.tsx View on Github external
public async queryViewProps(imodel: IModelConnection, refresh?: boolean): Promise {
    if (!this._viewDefCache || refresh) {
      const params: ViewQueryParams = {};
      params.from = ViewState.classFullName; // use "BisCore.ViewDefinition" as default class name
      params.where = "";
      const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken.toJSON(), params);
      this._viewDefCache = viewProps as ViewDefinitionProps[];
    }

    return this._viewDefCache;
  }
github imodeljs / imodeljs / core / frontend / src / GeoServices.ts View on Github external
}
    }

    // if none are missing from the cache, resolve the promise immediately
    if (undefined === missing) {
      response.fromCache = request.geoCoords.length;
    } else {
      // keep track of how many came from the cache (mostly for tests).
      response.fromCache = request.geoCoords.length - missing.length;

      // Avoiding requesting too many points at once, exceeding max request length (this definition of "too many" should be safely conservative)
      const maxPointsPerRequest = 200;
      const promises: Array> = [];
      for (let i = 0; i < missing.length; i += maxPointsPerRequest) {
        const remainingRequest = { sourceDatum: this._sourceDatum, geoCoords: missing.slice(i, i + maxPointsPerRequest) };
        const promise = IModelReadRpcInterface.getClient().getIModelCoordinatesFromGeoCoordinates(this._iModel.iModelToken.toJSON(), JSON.stringify(remainingRequest)).then((remainingResponse) => {
          // put the responses into the cache, and fill in the output response for each
          for (let iResponse: number = 0; iResponse < remainingResponse.iModelCoords.length; ++iResponse) {
            const thisPoint: PointWithStatus = remainingResponse.iModelCoords[iResponse];

            // put the answer in the cache.
            const thisGeoCoord: XYZProps = remainingRequest!.geoCoords[iResponse];
            const thisCacheKey: string = JSON.stringify(thisGeoCoord);
            this._cache[thisCacheKey] = thisPoint;

            // transfer the answer stored in remainingResponse to the correct position in the overall response.
            const responseIndex = originalPositions[thisCacheKey];
            if (Array.isArray(responseIndex)) {
              for (const thisIndex of responseIndex) {
                response.iModelCoords[thisIndex] = thisPoint;
              }
            } else {
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
public async load(viewDefinitionId: Id64String): Promise {
      const viewProps = await IModelReadRpcInterface.getClient().getViewStateData(this._iModel.iModelToken.toJSON(), viewDefinitionId);
      const className = viewProps.viewDefinitionProps.classFullName;
      const ctor = await this._iModel.findClassFor(className, undefined) as typeof ViewState | undefined;
      if (undefined === ctor)
        return Promise.reject(new IModelError(IModelStatus.WrongClass, "Invalid ViewState class", Logger.logError, loggerCategory, () => viewProps));

      const viewState = ctor.createFromProps(viewProps, this._iModel)!;
      await viewState.load(); // loads models for ModelSelector
      return viewState;
    }
github imodeljs / imodeljs / core / frontend-devtools / src / tools / InspectElementTool.ts View on Github external
private async process(elementIds: Id64String[]) {
    const request = {
      elementIds,
      options: this._options,
    };
    let messageDetails: NotifyMessageDetails;
    try {
      const str = await IModelReadRpcInterface.getClient().getGeometrySummary(this.iModel.iModelToken.toJSON(), request);
      if (this._doCopy)
        copyStringToClipboard(str);

      const brief = "Summary " + (this._doCopy ? "copied to clipboard." : "complete.");
      messageDetails = new NotifyMessageDetails(OutputMessagePriority.Info, brief, str);

      if (this._modal) {
        const div = document.createElement("div");
        const appendText = (toAppend: string) => {
          const txt = document.createElement("div");
          txt.innerText = toAppend;
          div.append(txt);
        };

        const lines = str.split("\n");
        const maxLines = 30;
github imodeljs / imodeljs / ui / framework / src / pickers / ViewSelector.tsx View on Github external
private async _getViewProps(imodel: IModelConnection, params: ViewQueryParams): Promise {
    try {
      const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken, params);
      return viewProps as ViewDefinitionProps[];
    } catch {
      return [] as ViewDefinitionProps[];
    }
  }
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
public async queryEntityIds(params: EntityQueryParams): Promise {
    return new Set(this.isOpen ? await IModelReadRpcInterface.getClient().queryEntityIds(this.iModelToken.toJSON(), params) : undefined);
  }
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
public async loadFontMap(): Promise {
    if (undefined === this.fontMap) {
      this.fontMap = new FontMap();
      if (this.isOpen) {
        const fontProps = JSON.parse(await IModelReadRpcInterface.getClient().readFontJson(this.iModelToken.toJSON())) as FontMapProps;
        this.fontMap.addFonts(fontProps.fonts);
      }
    }
    return this.fontMap;
  }
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
public async queryRows(ecsql: string, bindings?: any[] | object, limit?: QueryLimit, quota?: QueryQuota, priority?: QueryPriority): Promise {

    return IModelReadRpcInterface.getClient().queryRows(this.iModelToken.toJSON(), ecsql, bindings, limit, quota, priority);
  }
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
  private _toolTipRpc = new OneAtATimeAction((id: string) => IModelReadRpcInterface.getClient().getToolTipMessage(this.iModelToken.toJSON(), id));
  /** Request a tooltip from the backend.