Using the .NET library

To use the .NET library you first need to install powerLoad (bcpToolkit) on your development machine.
The library contains all the API’s to create your own BCP-package.

It requires your project targeting at least .NET framework 4.7 !

1. Reference the bcpDevKit assembly

In Visual Studio right-click on References and click “Add References”.
Search for the assembly “bcpDevKit” in Assemblies-tab and add it to your project.

../../_images/add_reference_to_vs.png

The assembly will be referenced from the GAC, therefore set “Copy Local” to “false”.

2. Create the BcpServiceBuilder and set the PackageLocation

In order to gain access to the bcpDevKit API’s, following namespaces should be imported:

using bcpDevKit;
using bcpDevKit.Entities;

Root entry point is the class BcpServiceBuilder:

var bcpSvcBuilder = new BcpServiceBuilder();

First we set the target BCP Version for which the package should be created:

bcpSvcBuilder.Version = BcpVersion._2024;

Then we set the PackageLocation, where the Package should be exported to:

bcpSvcBuilder.SetPackageLocation("C:\\Temp\\HelloWorldPackage");
3. Build the BcpService and start working

After preparing the BcpServiceBuilder with the desired settings we can now build the BcpService:

var bcpService = bcpServiceBuilder.Build();

The BcpService gives us access to all the functionality for creating a importable BCP package.
We can start to add Files and Items to our package:

var file = bcpService.FileService.AddFileWithIteration("$/HelloWorldFiles/Hello.iam", @"C:\HelloWorldFiles\Hello.iam");
var item = bcpService.ItemService.AddItem("999", "World", "Title 999", "Desc 999");
4. Create the BCP package

Finally we can create and export our BCP package to our package location by calling Flush on the BcpService:

bcpService.Flush();

After calling the function you can find the created package in your packageDirectory:

../../_images/helloworldpackage.png

The package can now be used to import the data into Vault.

Install powerLoad (bcpToolkit) on customer machine

When shipping the binaries of your project to the customer, also the customers machine requires a powerLoad (bcpToolkit) installation.
Therefore delivering the bcpDevKit assembly within your project should be avoided, so that new bcpDevKit versions can continue to be easily updated at the customer’s site.

See the complete example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using bcpDevKit;
using bcpDevKit.Entities;

namespace HelloWorldPackage
{
	class Program
	{
	        static void Main(string[] args)
	        {
	                var bcpSvcBuilder = new BcpServiceBuilder();
	                bcpSvcBuilder.Version = BcpVersion._2024;
	                bcpSvcBuilder.SetPackageLocation("C:\\Temp\\HelloWorldPackage");

	                var bcpService = bcpSvcBuilder.Build();

	                var file = bcpService.FileService.AddFileWithIteration("$/HelloWorldFiles/Hello.iam", @"C:\HelloWorldFiles\Hello.iam");
	                var item = bcpService.ItemService.AddItem("999", "World", "Title 999", "Desc 999");

	                bcpService.Flush();
	        }
	}
}