Giter Site home page Giter Site logo

autodesk-forge / forge-viewhubs-desktop Goto Github PK

View Code? Open in Web Editor NEW
37.0 7.0 30.0 2.03 MB

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.85% ASP 6.83% HTML 0.32%
csharp winforms autodesk-vewier autodesk-data-management mongodb

forge-viewhubs-desktop's Introduction

Desktop app to view models on hubs (BIM 360 or Fusion Team)

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. MongoDB: noSQL database, learn more. Or use a online version via Mongo Altas (this is used on this sample)

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

MongoDB

MongoDB is a no-SQL database based on "documents", which stores JSON-like data. For testing purpouses, you can either use local or live. For cloud environment, try MongoDB Atlas (offers a free tier). With MongoDB Atlas you can set up an account for free and create clustered instances, intructions:

  1. Create a account on MongoDB Atlas.
  2. Under "Collections", create a new database (e.g. named desktopsample) with a collection (e.g. named users).
  3. Under "Command Line Tools", whitelist the IP address to access the database, see this tutorial. If the sample is running on Heroku, you'll need to open to all (IP 0.0.0.0/0). Create a new user to access the database.

At this point the connection string should be in the form of mongodb+srv://<username>:<password>@clusterX-a1b2c4.mongodb.net/desktopsample?retryWrites=true. Learn more here

There are several tools to view your database, Robo 3T (formerly Robomongo) is a free lightweight GUI that can be used. When it opens, follow instructions here to connect to MongoDB Atlas.

WebConfig

Open the web.config and edit the Forge Client ID, Secret and Callback URL. The OAUTH_DATABASE should point to your MongoDB instance.

<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

Other APIs:

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.

  2. Cloud module cannot load its dependencies: first clean up the solution, then delete the .vs (hidden) and packages folder. Make sure the cloud project is set to AnyCPU and the desktop project is either 32 or 64 bit. Rebuild.

  3. Specified argument was out of the range of valid values:
    This error might come up if the necessary IIS components are not installed on your machine. You can solve it by following the solution here, which basically that you should go to Control Panel ->> Programs ->> Programs and Features ->> Turn Windows features on or off ->> Internet Information Services and check the checkbox

  4. Could not find a part of the path: This error can be fixed by updating the packages used by the project. You can follow the solution shown here, which says that you should run the Package Manager Console and execute the following in it:
    Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r

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

forge-viewhubs-desktop's People

Contributors

adamenagy avatar augustogoncalves avatar jaylimboonkiat avatar kimekeunkyung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

forge-viewhubs-desktop's Issues

Error

Hi,
I have followed the readme to get this working but I get an error:
An exception of type 'System.Exception' occurred in mscorlib.dll but was not handled in user code Additional information: Cannot call /api/forge/session/isvalid

Looking at response I can see below details:
"{\"Message\":\"An error has occurred.\",\"ExceptionMessage\":\"Index was outside the bounds of the array.\",\"ExceptionType\":\"System.IndexOutOfRangeException\",\"StackTrace\":\" at MongoDB.Bson.ObjectId.FromByteArray(Byte[] bytes, Int32 offset, Int32& a, Int32& b, Int32& c)\\r\\n at MongoDB.Bson.ObjectId..ctor(String value)\\r\\n at FPD.Sample.Cloud.OAuthDB.<IsSessionIdValid>d__7.MoveNext() in C:\\\\dev\\\\data.management-csharp-desktop.sample\\\\data.management-csharp-desktop.sample\\\\cloud\\\\App_Code\\\\Database.cs:line 63\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at FPD.Sample.Cloud.Controllers.OAuthController.d__1.MoveNext() in C:\\dev\\data.management-csharp-desktop.sample\\data.management-csharp-desktop.sample\\cloud\\Controllers\\OAuthController.cs:line 51\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__11.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()\"}"

TLS1.2 change on Oct 31st 2018 (SOLVED)

Because of the TLS1.2 requirement, you need a vital change in order to run the solution.
In cloud\Global.asax.cs

This is due to RestSharp that is compiled using .Net4.0, where TLS1.2 is NOT default.
Newer version than 106.3.1 of RestSharp does not seem to work

        void Application_Start(object sender, EventArgs e)
        {
            // Enforce TLS1.2
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

            // Code that runs on application startup
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }

Documentation re localhost port

I tried port 3000, but the app would not work at all. I then tried 3010, and it would do almost everything...except it would fail with a 403 error when trying to get the model derivative to view.
After much pottering, I tried a different port. Voila.

Please add something like this to the troubleshooting documentation:

If you get a 403 error, consider changing your port.
In this app, you need to change it in 4 places:

  • In the callback path of your Forge app.
  • In the 'cloud' project, right-click, Properties, Web tab, Project Url.
  • Your Web.Keys.config file.
  • app.config in the 'desktop' project.

Error on load

After I have successfully logged in I get this error.

System.Exception: 'Cannot call /api/forge/session/isvalid'

GetResourceRequestHandler notImplementedException

In main.cs, the GetResourceRequestHandler throw a NotImplementedException, and I get a blank screen instead of the 3d model. I'm not able to update to the latest CEF redist, Is that part of the issue?

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.