Adventure Works example application
This sample provides a template and simple application to get you started on ThoughtFarmer custom application development.
Requirements
You should have a ThoughtFarmer development instance along with access to the SQL server instance hosting its data. For development you will require the following:- Visual Studio
- The latest .Net Core SDK
- AdventureWorks2017 OLTP test database. The .bak file should be restored on your SQL instance.
- Download and extract the sample ORC.TF.Custom.AdventureWorksSample.zip, which is attached to this article.
Database setup
Once the AdventureWorks2017 database is downloaded and restored we can update a record in the [HumanResources].[Employee] table so that it is linked to a ThoughtFarmer user.Single user script:
update [HumanResources].[Employee] set LoginID = 'TFUserName', VacationHours = 110, SickLeaveHours = 38 where LoginID = 'adventure-works\roberto0'Multi-user script:
This will associate test data for all your users. This is helpful if you would like to test this on multiple accounts, or to extend the custom application in other ways.
update aw set aw.LoginID = ps.Username from [AdventureWorks2017].[HumanResources].[Employee] aw inner join [THOUGHTFARMER-DATABASENAME].[dbo].[User] ps on ps.UserID = aw.BusinessEntityID
Building the application
The sample application can be built using the tools provided with Visual Studio 2017 and the .Net core SDK.Because this application is a sub-application of the main ThoughtFarmer site, the publishing process for the code is slightly different. To publish from the command line execute (from the folder containing the file ORC.TF.Custom.AdventureWorksSample.sln)
dotnet publish /p:IsTransformWebConfigDisabled=true
Deploy the application
The publish folder will be found in a subfolder of the application. It is typically found in \bin\Debug\netcoreapp2.1\publish. The exact location may vary depending on your specific settings. You will need to zip this folder and deploy it to your ThoughtFarmer server.This folder is the one you will use to add a new sub-application in IIS. Please see Configure a custom application for more details.
Configure the cards
This example comes with 2 available custom cards. One is a Global application meaning that it always runs on all pages. The other is a Page template application. These will behave like other custom cards and can be added to any page template anywhere on the site.Please see Configure an application for details on setting this up.
AdventureWorks Employee
If the currently logged in user accesses their own profile page, and their username matches data found in the [AdventureWorks2017].[HumanResources].[Employee] table, then a custom tab will be added to display data and emulate a basic sick\vacation day request feature.Configuration:
- Add a new Global application
- Server url:
- /ccadventureworks/api/employee
- Javascript url:
- /ccadventureworks/js/employee.jsx
- Save the card.
- Activate the card.
AdventureWorks Category
This customization will pull in data from the AdventureWorks2017 database. It also demonstrates how to pass along configuration from an instance of a card to the custom application code.Configuration:
- Add a new Page template application.
- Server url:
- /ccadventureworks/api/products
- Javascript url:
- /ccadventureworks/js/products.jsx
- CSS url:
- /ccadventureworks/css/products.css
- Go to Details > Default configuration and add:
- { "configuration": "" }
- Check the option "Allow card configuration on edit page".
- Save the card.
- Activate the card.
- Go to any page and add the Custom card to the page.
- Click the gear icon to modify the configuration.
- Update the configuration:
- { "configuration": "Clothing" }
- Supported values are Bikes, Clothing, Components, Accessories as taken from the [Production].[ProductCategory] table from the AdventureWorks2017 database.
- Save the changes.
Comments
0 comments
Please sign in to leave a comment.