Workload Manager (WLM)
======================

General Installataion and Configuration
======================================
You will find the latest versino of this document in \PresentationLayer\scripts\wlm\readme.md

# Be sure that you have "npm" the Node Package Manager installed on your Windows. Google for npm and install it.

# TypeScript 2.2.x is Required and will not work with > 2.2

## Please upgrade the "built in" Typescript for VisualStudio (2015 or later) by [TypeScript for Visual Sturi 2015|https://www.microsoft.com/en-us/download/details.aspx?id=48593]

## If You Accidentally Installed TypeScript > 2.2.2 or Your Visual Studio is with Later Version

	npm uninstall -g typescript
	npm install -g typescript@2.2.2

Compile manually with
	
	cd scripts
	tsc -p .





If you do not do this, you will get a strange 'JsErrorScriptException (0x30001)' error message.

# Once you pull the sources, cd to \PresentationLayer\scripts\
# Then execute the following npm command

	npm install

Now you can build and run everything from Visual Studio.

# Handy Tip to Just Develop TypeScript codes

Make the app run under the IIS first.

If open the shell at \PresentationLayer\scripts\ directory then type in

	tsc --watch

You can edit Typescript code, have it compiled and by refreshing the browser are all set to test.
This can save you a tremendous time in building.

IMPORTANT SCHEMA INFORMATION
============================

* IMPORTANT Schema Dependencies and Update Steps

If you change the schema in the database the following areas must be closedly examined and updated.

# In the SQL Server, be sure that the View vw_wlm_List refects dbo.wlm_List

# "\foundations-v2\HealthLevel\DataLayer\WordkLoadManager.dbml"
## Remove the existing item for example wlm_List and vw_wlm_List
## Drag and Drop the new Tables and Views to the dblm design surface.
# "\foundations-v2\HealthLevel\DataLayer\WorkLoadManagerListDal.cs"
## You will need to fix the copying of fields for Create, Insert or Updates
# \foundations-v2\HealthLevel\Wlm_Db
# "\foundations-v2\HealthLevel\PresentationLayer\Controllers\API V2\WlmApiController.cs"
# "\foundations-v2\HealthLevel\PresentationLayer\scripts\wlm\wlmDto.ts"

Overall Design Notes
====================

* New Tables and Views

There is now a new subproject dedicated for SQL called FoundationsDB.

In this project if you look under dbo, you will find many SQL Create Table scripts that starts with wlm_. Run all those.
There also is a few views also starts with vw_wlm_, run any that are applicable.

Some tables have initial data in them,

You can load them from the script(s) in the Inert folder.

In theory, you can create all the tables, views, functions and stored procedures from this project if you maintain it.

** Local Testing

In the WLMTests project is the DALBasic.cs test. In there you will find public void TestDataGenerator().
If you run this, it will auto-fill the wlm tables with some usable fake data while it also excercises the DAL codes.

If you want to truncate all of the wlm data, you will find foundations-v2\HealthLevel\Wlm_Db\Cleanups\clean_wlmData.sql
script handy.


* BACKEND Area of Interest

** DataLayer\WorkLoadManagerListDal.cs: Performs the Database Access using LINQ to SQL
** DataLayer\WordkLoadManager.dbml: defined the Entity mapping for LINQ to SQL used in above. If any of wml_, dbo.Users
or Sites changes, you will need to remake this file.

* FRONTEND JavaScript/TypeScript Area of Interest

** TypeScript 2.2.x is Required

Please upgrade the "built in" Typescript for VisualStudio (2015 or later) by [TypeScript for Visual Sturi 2015|https://www.microsoft.com/en-us/download/details.aspx?id=48593]

If you do not do this, you will get a strange 'JsErrorScriptException (0x30001)' error message.

** scripts\foundations.vantpworkloadmanager.js: This is where the Mithril modules are hooked up to the page.
** \bundleconfig.json: This defines how the JS files are bundled.
** app\home.aspx: Includes the wlmBundle.js script. It is a bundle of Mithril, Lodash etc.

* Web Form Scripts

** scripts\wlm\wlmApp.ts: is the Main app. It is mounted via \scripts\foundations.vantpworkloadmanager.js

Note it does not bundle the web app (until it is stable) as debugging would be difficult that way.
