<< Click to Display Table of Contents >> Component Library example for .NET edition |
In the following example, we will use the Component Library feature to include a developed component that uses an external API.
For more information about this possibility, refer back to Custom components.
To use the Component library feature, these steps are carried out:
1. Building your component (a compiled output).
2. Registering the component in Bizagi.
3. Creating the business rule which invokes the component.
When developing a component for the .NET edition, you need to make sure that this component is compiled and works for the supported framework used by Bizagi.
In Bizagi 11.x versions, the framework used in a .NET platform is version number 4.8.
This may imply that if your component was being used in 10.x Bizagi versions (which used .NET version 4.0), you need to make sure that it is still compatible to run with the updated 4.8 version.
We will illustrate this through a sample Credit Request Process.
Notice that this is a simplified example, in which we will validate that the Applicant is not reported in a central Black List in the service task called Verify Blacklist.
In this service task, we will create a business rules that accesses our developed component to make use of that given API. Through this API, we invoke a method that returns whether or not the applicant's id is listed in the Blacklist (true or false).
We will illustrate how to use the Component library feature for a .NET project.
Building your component (a compiled output)
Our first step is to develop the component as a class library project.
In our sample component called MyCreditBureauComponent, we make use of a CreditBureau.dll, which represents an example API.
Notice we include the reference in our component.
For the .NET edition, we build the class library project as a dll assembly.
Notice our component’s namespace is called MyCreditBureauComponent, and that our Class is public (called “Class1”). The method we will use in this example is called IsCustomerInBlackList.
Registering the component in Bizagi
Having built the component’s assembly in our previous step, we will use the MyCreditBureauComponent.dll output to register the component in Bizagi's component library.
To do this, we go to Bizagi Studio’s Tools and add a new component:
Find the .dll file and then click open, we upload the MyCreditBureauComponent.dll assembly:
Once the component is added, give a Display name and a Description.
Given that this component references and uses another class library (the API), we need to register and include this API into our component library as well.
Therefore, we repeat the steps to add a component, but this time we do it for the CreditBureau.dll assembly.
In the end, we need to have registered our 2 assemblies as 2 separate components:
Creating the business rule which invokes the component
Now that we have registered our component in the Component library, we proceed to create a business rule which invokes the component’s method.
For the sake of simplicity, the following example shows how to call this component from directly within a business rule.
However, as a best practice in terms of maintainability of your solution, it is recommended to create a global rule (a library rule) that receives input parameters, invokes the component and returns output parameters. This way, business rules call this global rule, and you have a single point in Bizagi coupled to your component. Members of your team working on the same project just need to know which global rule to use. For more information about global rules (library rules), refer to Reusing business rules. |
To do this, we go to the Activity Actions view from our Process wizard, and select the Verify black list service task. We include a business rule in this point in the Process:
In the expression, we invoke our MyCreditBureauComponent’s method with the following syntax:
Class.Method
Notice that our Class is not defined as a static class, and therefore we can previously create an instance of it, to invoke its methods. In our example, the complete expression invokes the IsCustomerInBlackList method by:
•Sending out the Applicant’s id.
•Storing the method’s result in the CreditRequest.InBlackList Boolean-type attribute.
This is the expression’s content:
var temp = new Class1();
Me.setXPath("CreditRequest.InBlackList",temp.IsCustomerInBlackList(Me.getXPath("CreditRequest.ApplicantId")));
At this point, we are set using a custom developed component with the Component library feature in Bizagi!
To see this example working, we execute our Process in Bizagi's Work Portal by clicking in the Work Portal option:
We can see that after the Verify black list service task, our next Activity will show the result of our component’s method invocation:
Last Updated 2/28/2024 9:30:07 AM