Documentation

Installation Guide

Before .NetKS can be used for creating Knowledge Scripts® and  QMLs, it needs to be installed on development machines. We have prepared a setup for .NetKS in form of MSI package that needs to be executed in order to install all necessary components and libraries.
Execute MSI package. Welcome screen will appear. Select Next button to proceed.
Select Visual Studio versions for which .NetKS components should be installed. Select Next button to proceed.
Select destination folder, where .NetKS libraries and components should be installed. Select Next button to proceed.
Confirm installation by selecting Next Button. Installation of .NetKS will start instantly.
Wait for all components to be installed. Select Next button to proceed to final step.
Select Close button to finish installation procedure.

.NetKS Registration

After successful installation it is time to start developing. Before developers can do that it’s necessary to register .NetKS. If You don’t have License Key yet, please visit our Pricing Section.
Open Visual Studio and select .NetKS > Register from Menu Bar.
Provide Username, Email and License Key in order to register .NetKS. Select Register button to finish registration process.

Creating .NetKS Project

When .NetKS components are already installed and .NetKS is registered, it is time to  start developing Knowledge Scripts® with .Net Framework. Because of full Visual Studio Integration this is easy and painless activity.

Visual Studio New Project window

To start developing with .NetKS open Visual Studio and select File > New > Project. From Templates select C# > .NetKS and then pick .NetKS Knowledge Script® from the list of available templates. After all necessary fields contains desired values select OK button and wait few moments, while Your new project is being configured.

Initial .NetKS project created from template

When the project is configured You are ready to start coding Knowledge Scripts® in .Net. Visit “.NetKS Project Overview” and “Sample Knowledge Script®” sections for more info.

.NetKS Project Overview

Each .NetKS Knowledge Script® contains three main files:

  • .DNKS file
  • .CS file
  • .DESIGNER.CS file

In this section it will be described what are these files for, and which of them may be used in development process.

.DNKS File
DNKS file contains Knowledge Script® related data, that are necessary in process of compiling .NetKS project into QML. So here basic script properties may be found as well as input parameters.

Built-in editor allows to change Knowledge Script® header properties and parameters in easy way.

.CS File
CS file is the place to put user code. Best way to achieve desired functionality is to override Execute and implement own handling in body that method.
.DESIGNER.CS File
Designer.Cs is automatically generated file that reflects DNKS properties. It is regenerated each time DNKS is changed. It is not recommended to edit this file – changes may cause incorrect behaviur and will be lost after file is rewritten. In that file input paramters, that were set by changing DNKS, are created.

Sample Knowledge Script® created with .NetKS

In this section we will create Sample (and simple!) Knowledge Script® that will introduce basic concepts of building logic in .NetKS.

The purpose of this Knowledge Script® will be to monitor available disk space on a drive. Both drive name and valid disk size will be parameters for Knowledge Script®.

1. Create new .NetKS project

First of all we need to create a new .NetKS project called Sample Knowledge Script®. In case of concerns please visit Create New Project section.

2. Edit DNKS Properties
DNKS Properties editor

Knowledge Script® description is going to be changed to reflect its functionality. Sample Knowledge Script® will target Windows servers and AppManager version 6.0.2. Knowledge Script® type is Normal.

3. Add Paremeter to DNKS
DNKS Add Parameters window

Now we’re going to add 2 parameters for our Sample Knowledge Script®:

  1. ValidSize:
    • Data Type: Integer
    • Description: Valid Size
    • Unit: GB
    • Default value: 20
  2. Drive:
    • Data Type: String
    • Description:Disk Drive
    • Default value: c
Sample Knowledge Script® parameters shown in DNKS Parameters Window
4. Adding Implementation to SampleKS.cs
First we may indroduce method to check available disk space on specified disk drive.
Then we may create another method that will run in a loop and periodically check available space on a given disk drive. If the available space is lower than ValidSize NetIQ event is raised. Also when disk drive is not found NetIQ event is raised.

In our example script will execute available disk space check once an hour.

The last thing is to execute our method that checks available space and raises events in additional thread. We will use ThreadPool for that. The implementaion needs to be done in Execute method in order to run it from NetIQ.

 

Full code may be found below:

Sample Knowledge Script® full code

QML Check-in with .NetKS

With .NetKS Users can check-in their scripts in the same way, as they would do in AppManager. .NetKS provides possibility to check-in QML straight from Visual Studio IDE as well as using command-line tools.

1. Check-in from command-line

To check in a knowledge script® via command user should type the following with the appropriate parameters:

dnkscheckin <SQLSERVER>:<DBNAME>[:<USER>:<PASSWORD>] <PROJECTFILE|QML>

When <User>:<Password> are not provided command will assume to connect with Windows Authentication turned on.
User may use <ProjectFile> (in example .csproj) to build Your .NetKS project and check-in al qmls that were produced in the process. When providing path to QML only select Knowledge Script® will be checked-in.

Dnkscheckin tool example.

2. Check-in from Visual Studio IDE

Check-in is also integrated within Visual Studio IDE for easy-of-use, agile development of Knowledge Scripts®
To check in a knowledge script® from Visual Studio IDE user should pick .dnks file and select Check-in DNKS from context menu.
User will be prompted for Server and Repository. Additionally User may choose authentication type.
After logon Knowledge Script® will be compiled and checked-in to NetIQ Repository. User will be notified about successful check-in operation.