Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
Bentley 中国优先社区
  • Welcome to Bentley Communities
  • Bentley's Communities
  • Bentley 中国优先社区
  • Cancel
Bentley 中国优先社区
技术资料库 11-系统集成应用
    • Sign In
    Bentley 中国优先社区 requires membership for participation - click to join
    • +Bentley 中文技术资料库
    • -iTwin 数字孪生平台
      • Connector(原名Bridge)
      • i-twin微信小课堂
      • -iModel.js
        • +01-iModel.js资源
        • -02-iModel.js初步
          • 01-开始使用iModel.js
          • 02-简介
          • 03-为何使用iModel.js
          • 04-iModel上传
          • +05-iModel.js处理CSV文件
          • 06-简单的浏览应用
          • 07-数据显示
          • 08-前端和后端
          • 09-超级URLs
          • 10-iModel项目
          • 11-系统集成应用
          • 12-部署应用
          • 13-与微软IOT集成
          • 14-BIS数据结构
          • 15-快速开始
        • +03-iModel.js专题应用
      • +iTwin工作流程
      • +iTwin技术主题
    • Bentley二次开发资料库
    • +常见问题汇总
    • Bentley-Learn 官方教学平台-使用方法
    • +中国优先社区使用指南
    • +Bentley学习资料库
    • +Bentley用户成功活动精选
    • +服务合作伙伴计划

     
     Questions about this article, topic, or product? Click here. 

    11-系统集成应用

    说明:

    原文刊登在Medium.com/imodeljs站点,作者: Wil Maier

    中文翻译:

    正在进行中...

    英文原文:

    “How can you sign-in without a dialog?”

    Any app that connects to the iModelHub needs to present a sign-in dialog. But what if you just want to write a command-line app to perform a query?

    My colleague was trying to solve a similar dilemma. His imodel-unity-example communicates with a command line app. He was trying to update the app to interact with iModelHub but faced the same sign-in issue. As this has already been deployed for use with Microsoft HoloLens and VR headsets like Oculus Rift, HTC Vive, and Oculus Quest, it has gotten a lot of attention.

    I wonder what kind of model she is looking at!

    So how could apps like this sign-in and browse for a model in iModelHub without having a frontend?

    I wasn’t sure this was going to be possible.

    All we had to work with was an existing app that we could scavenge for the necessary UI code. But how could we popup a sign-in dialog and return the authentication token?

    Hmm. This was going to take some creative thinking!

    The concept we finally came up with was to build the dialog as an electron app. If you are not familiar with electron, it allows you to package and run a web app as a desktop app. Now we had a plan! This could allow us to create a popup dialog in a separate process, return the needed information to the app, and then close it.

    Anyway, after proving that we could return a sign-in token from one app and use it for authentication in another app, we knew it could be done!

    Once we finished developing this popup app, we packaged it so that it could easily be installed and integrated as an npm package in any Node.js app.

    And here you see it in action:

    The happy ending to this story is that we have decided to make this iModel selector utility available to anyone that needs it. For example, it could enable you to write a command-line app to query an iModel and produce a report. That’s exactly what the included sample does.

    To use iModel Selector, all you need to do is call a function with a few parameters:

    const params: IModelSelectorConfig = {only_signin: false};const data: IModelSelectorData = await launchIModelSelector(params);

    It will open the popup dialog and once it has completed, it will return the authentication string and model id needed to open an iModel.

    If you are ready to jump in, checkout this sample command-line app to see how easy it is to use.

    Happy coding!

    • Share
    • History
    • More
    • Cancel
    • shunnai.zhao Created by Bentley Colleague shunnai.zhao
    • When: Mon, Sep 14 2020 1:50 AM
    • shunnai.zhao Last revision by Bentley Colleague shunnai.zhao
    • When: Mon, Sep 14 2020 8:17 AM
    • Revisions: 2
    • Comments: 0
    • Sign in to reply
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies