Coder Social home page Coder Social logo

c4tcr4sh / data.management-csharp-desktop.sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from autodesk-forge/forge-viewhubs-desktop

0.0 2.0 0.0 743 KB

Autodesk design file explorer for desktop: Demonstrates a desktop application that shows BIM 360 Team, BIM 360 Docs and Fusion Team hubs, which respective Projects, Folders, Items and Versions

License: MIT License

C# 92.92% ASP 6.76% HTML 0.32%

data.management-csharp-desktop.sample's Introduction

data.management-csharp-desktop.sample

Platforms .NET ASP.NET License

OAuth2 Data-Management Viewer

Advanced

Demonstration

This sample demonstrates a desktop application that shows BIM 360 Team, BIM 360 Docs and Fusion Team hubs, which respective Projects, Folders, Items and Versions. For each version it is possible to view it using Viewer.

Uses Data Management to list hubs, projects and files. Uses Viewer to show models on a Chromium-based browser, CefSharp.WinForms. A Mongo database is used to store session (OAuth) information.

Thumbnail

thumbnail

See this quick video.

Architecture

When the user opens the desktop application, it redirects to Autodesk Account sign in page using the Forge Client ID stored on the Cloud module. After authenticating, the access_token and refresh_token are stored on a MongoDB database, creating a session ID. This ID is encrypted and sent to the Desktop client.

On the next request, the Desktop client provides the Session ID, the Cloud module uses that to get the respective access_token and connects to Autodesk. Once the data is acquired, it is adjusted and sent to the Desktop client.

The Desktop client will not have access to the access_token.

Security concerns

This sample uses CefSharp.WinForms, based on Chromium Embedded Framework, the open source version of Google Chrome. It's is also available for WPF applications. The build-in .NET WebView is based on Internet Explorer (version 11) and it's have several limitations.

The Cloud module acts as a proxy between the Desktop client and Autodesk data. Only authorized information is returned, including the viewables for Viewer, controlled via Proxy.

To identify the Desktop client, this sample uses a MachineID identifier. For this first version, it is using the MAC address, but this may be improvements.

Setup

Prerequisites

  1. Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
  2. Visual Studio: At least the Community edition
  3. .NET basic knowledge with C#
  4. mLab account: non-SQL online data, create a free development account at mLab

Running locally

For using this sample, you need an Autodesk developer credentials. Visit the Forge Developer Portal, sign up for an account, then create an app. For this new app, use http://localhost:3000/api/forge/callback/oauth as Callback URL. Finally take note of the Client ID and Client Secret.

This sample contains 2 projects: cloud and desktop.

Cloud server

The cloud server module will store the credentials on a Mongo database. You can setup an development instance for free at mLab (or any other provider). Make sure to include a collection named users and add a user that can access the collection.

Open the web.config and edit the Forge Client ID, Secret and Callback URL. The OAUTH_DATABASE should point to your MongoDB instance, like: mongodb://user:[email protected]:56789/databasename

<appSettings>
  <add key="FORGE_CLIENT_ID" value="" />
  <add key="FORGE_CLIENT_SECRET" value="" />
  <add key="FORGE_CALLBACK_URL" value="" />
  <add key="OAUTH_DATABASE" value="" />
</appSettings>

Desktop executable

Open the app.config file and specify the webserver address under appSettings:

<appSettings>
  <add key="serverAddress" value="http://localhost:3000" />
</appSettings>

For local testing, the desktop module should work "as is".

To debug, make sure to launch both projects. On the Solution Explorer, right-click on the solution and go to properties, under Startup Project select both.

Deployment

IMPORTANT: this sample implements minimum error check for simplicity, not ready for production environment.

The cloud project should be deployed live, any .NET compatible host should work, including (but not limited to):

Consider upgrading the mLab account to production.

Then the desktop module should be updated with the cloud module address (under appSettings file).

Further Reading

Documentation:

Blogs on Expanding .NET desktop apps into the cloud

Tips & Tricks

  1. The CEF Sharp library should work on AnyCPU, but this sample uses only x64 version. This issue entry explains how to adjust it, if needed.

  2. To keep keys locally, the sample defines a web.keys.config file that is added to .gitignore. On local development environment, this file stores the keys. When commit to Github, this file is not included.

  3. The AWS Elastic Beanstalk deployment cannot override web.config variables on deployment, so this sample includes a transform on the web.Release.config to remove them. With that it should work.

<appSettings>
  <add key="FORGE_CLIENT_ID" xdt:Transform="Remove" xdt:Locator="Match(key)" />
  <add key="FORGE_CLIENT_SECRET" xdt:Transform="Remove" xdt:Locator="Match(key)" />
  <add key="FORGE_CALLBACK_URL" xdt:Transform="Remove" xdt:Locator="Match(key)" />
  <add key="OAUTH_DATABASE" xdt:Transform="Remove" xdt:Locator="Match(key)" />
</appSettings>

Troubleshooting

  1. Cannot see my BIM 360 projects: Make sure to provision the Forge App Client ID within the BIM 360 Account, learn more here. This requires the Account Admin permission.

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Augusto Goncalves @augustomaia, Forge Partner Development

data.management-csharp-desktop.sample's People

Contributors

augustogoncalves avatar jaylimboonkiat avatar kimekeunkyung avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.