How to use the @bentley/imodeljs-backend.IModelJsFs.readFileSync function in @bentley/imodeljs-backend

To help you get started, we’ve selected a few @bentley/imodeljs-backend 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 / display-performance-test-app / src / backend / CsvWriter.ts View on Github external
export function addDataToCsvFile(file: string, data: Map) {
  try {
    const columns = IModelJsFs.readFileSync(file).toString().split(/[\r\n]+/)[0].split(",");
    let stringData = "";
    columns.forEach((colName, index) => {
      let value = data.get(colName);
      if (value === undefined) {
        if (index < 2 || colName === "ReadPixels Selector")
          value = "";
        else
          value = 0;
      }
      if (colName === "iModel" || colName === "View Flags" || colName === "Disabled Ext" || colName === "ReadPixels Selector" || colName === "Tile Props")
        stringData += "\"" + value + "\",";
      else if (colName !== "" || index !== columns.length - 1)
        stringData += value + ",";
    });
    stringData += "\r\n";
    IModelJsFs.appendFileSync(file, stringData);
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / DisplayPerfRpcImpl.ts View on Github external
public async getDefaultConfigs(): Promise {
    let jsonStr = "";
    let defaultJsonFile;
    if (MobileRpcConfiguration.isMobileBackend && process.env.DOCS) {
      defaultJsonFile = path.join(process.env.DOCS, "MobilePerformanceConfig.json");
    } else {
      defaultJsonFile = "./src/backend/DefaultConfig.json";
    }
    if (IModelJsFs.existsSync(DisplayPerfRpcInterface.jsonFilePath)) {
      jsonStr = IModelJsFs.readFileSync(DisplayPerfRpcInterface.jsonFilePath).toString();
    } else if (IModelJsFs.existsSync(defaultJsonFile)) {
      jsonStr = IModelJsFs.readFileSync(defaultJsonFile).toString();
    }
    let argOutputPath: string | undefined;
    process.argv.forEach((arg, index) => {
      if (index >= 2 && arg !== "chrome" && arg !== "edge" && arg !== "firefox" && arg.split(".").pop() !== "json") {
        while (arg.endsWith("\\") || arg.endsWith("\/"))
          arg = arg.slice(0, -1);
        argOutputPath = "\"argOutputPath\": \"" + arg + "\",";
      }
    });

    if (argOutputPath) {
      const firstBraceIndex = jsonStr.indexOf("{") + 1;
      jsonStr = jsonStr.slice(0, firstBraceIndex) + argOutputPath + jsonStr.slice(firstBraceIndex);
    }
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / DisplayPerfRpcImpl.ts View on Github external
public async getDefaultConfigs(): Promise {
    let jsonStr = "";
    let defaultJsonFile;
    if (MobileRpcConfiguration.isMobileBackend && process.env.DOCS) {
      defaultJsonFile = path.join(process.env.DOCS, "MobilePerformanceConfig.json");
    } else {
      defaultJsonFile = "./src/backend/DefaultConfig.json";
    }
    if (IModelJsFs.existsSync(DisplayPerfRpcInterface.jsonFilePath)) {
      jsonStr = IModelJsFs.readFileSync(DisplayPerfRpcInterface.jsonFilePath).toString();
    } else if (IModelJsFs.existsSync(defaultJsonFile)) {
      jsonStr = IModelJsFs.readFileSync(defaultJsonFile).toString();
    }
    let argOutputPath: string | undefined;
    process.argv.forEach((arg, index) => {
      if (index >= 2 && arg !== "chrome" && arg !== "edge" && arg !== "firefox" && arg.split(".").pop() !== "json") {
        while (arg.endsWith("\\") || arg.endsWith("\/"))
          arg = arg.slice(0, -1);
        argOutputPath = "\"argOutputPath\": \"" + arg + "\",";
      }
    });

    if (argOutputPath) {
      const firstBraceIndex = jsonStr.indexOf("{") + 1;
      jsonStr = jsonStr.slice(0, firstBraceIndex) + argOutputPath + jsonStr.slice(firstBraceIndex);
    }
    return jsonStr;
  }
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / CsvWriter.ts View on Github external
export function addColumnsToCsvFile(filePath: string, rowData: Map) {
  let origFile = IModelJsFs.readFileSync(filePath).toString();
  const columns = origFile.split(/[\r\n]+/)[0].split(",");
  const opNamesIter = rowData.keys();
  const opNames: string[] = [];
  for (const name of opNamesIter)
    opNames.push(name);
  let opNamesIndex = 0;
  let columnsIndex = 0;
  while (opNamesIndex < opNames.length || columnsIndex < columns.length) {
    if (opNames[opNamesIndex] === undefined || columns[columnsIndex] === undefined
      || opNames[opNamesIndex].trim() !== columns[columnsIndex].trim()) {
      let count = 1;
      while (opNames[opNamesIndex + count] !== columns[columnsIndex] && (opNamesIndex + count) < opNames.length) {
        count++;
      }
      if (opNames[opNamesIndex + count] === columns[columnsIndex]) {
        for (let i = 0; i < count; i++) {
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / DisplayPerfRpcImpl.ts View on Github external
public async readExternalSavedViews(bimfileName: string): Promise {
    const esvFileName = this.createEsvFilename(bimfileName);
    if (!IModelJsFs.existsSync(esvFileName)) {
      return "";
    }
    const jsonStr = IModelJsFs.readFileSync(esvFileName).toString();
    if (undefined === jsonStr)
      return "";
    return jsonStr;
  }