Giter VIP home page Giter VIP logo

forge-hubs-recursive-extraction's Introduction

Files and folders extraction sample

Platforms .NET License

oAuth2 Data-Management BIM360 ACC

MongoDB

Advanced

Description

This sample demonstrate how to retrieve data of all the folders and files on a specific project to render on a table and export it as csv. This sample recursively iterate through all folders of the selected project. It then, stores the data on a MongoDB collection temporarily, until the client retrieves that to render on its page. By the end of the extraction, every file and folder under the selected project are rendered on the user table and can be exported as csv.

Thumbnail

Live version

Try it at https://filesnfoldersextraction.herokuapp.com

Setup

Prerequisites

  1. Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
  2. Visual Studio: Either Community (Windows) or Code (Windows, MacOS).
  3. .NET Core basic knowledge with C#
  4. MongoDB: noSQL database, learn more. Or use a online version via mLab (this is used on this sample)
  5. HangFire: Library for dealing with queueing. [learn more] (https://www.hangfire.io).

Running locally

Clone this project or download it. It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):

git clone https://github.com/JoaoMartins-Forge/filesnfoldersextraction

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 filesnfoldersextraction) with a collection (e.g. named items).
  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/inventor2revit?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.

Visual Studio (Windows):

Right-click on the project, then go to Debug. Adjust the settings as shown below. For environment variable, define the following:

  • ASPNETCORE_ENVIRONMENT: Development
  • FORGE_CLIENT_ID: your id here
  • FORGE_CLIENT_SECRET: your secret here
  • FORGE_CALLBACK_URL: http://localhost:3000/api/forge/callback/oauth
  • ITEMS_COLLECTION: your collection for temporary storage of files and folders
  • HANGFIREDATABASE: Hangfire database name
  • MONGO_CONNECTOR: your mongodb connection string
  • ITEMS_DB: your items database name

Visual Sutdio Code (Windows, MacOS):

Open the folder, at the bottom-right, select Yes and Restore. This restores the packages (e.g. Autodesk.Forge) and creates the launch.json file. See Tips & Tricks for .NET Core on MacOS.

At the .vscode\launch.json, find the env vars and add your Forge Client ID, Secret and callback URL. Also define the ASPNETCORE_URLS variable. The end result should be as shown below:

"env": {
  "ASPNETCORE_ENVIRONMENT": "Development",
  "ASPNETCORE_URLS" : "http://localhost:3000",
  "ITEMS_COLLECTION": "your collection for temporary storage of files and folders",
  "FORGE_CALLBACK_URL": "http://localhost:3000/api/forge/callback/oauth",
  "FORGE_CLIENT_SECRET": "your client secret here",
  "HANGFIREDATABASE": "Hangfire database name",
  "MONGO_CONNECTOR": "your mongodb connection string",
  "FORGE_CLIENT_ID": "your client Id here",
  "ITEMS_DB": "your items database name"
},

Open http://localhost:3000 to start the app. Select Index my BIM 360 Account before using (this process may take a while). Check the http://localhost:3000/dashboard to see the jobs running (Hangfire dashboard).

Deployment

To deploy this application to Heroku, the Callback URL for Forge must use your .herokuapp.com address. After clicking on the button below, at the Heroku Create New App page, set your Client ID, Secret and Callback URL for Forge.

Deploy

Further Reading

Documentation:

Other APIs:

Tips & Tricks

This sample uses .NET Core and works fine on both Windows and MacOS, see this tutorial for MacOS.

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. error setting certificate verify locations error: may happen on Windows, use the following: git config --global http.sslverify "false"

License

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

Written by

João Martins @JooPaulodeOrne2, Forge Partner Development

forge-hubs-recursive-extraction's People

Contributors

joaomartins-callmejohn avatar

Watchers

 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.