Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

How to Create a Class for Handling the 'Product' Object?

How to Create a Class for Handling the 'Product' Object?

  • Last UpdatedJun 10, 2024
  • 2 minute read

The scenario explained in the previous page can be designed by following the steps given in the examples in the next few pages.

To create a Class for Handling the 'Product' Object

Note: You can make use of any existing class to build the scenario.

'Product' class: Product information.

'OrderLineCalculator' class: Operations performed on 'Product' object.

Note: Only the objects that can be serialized can be persisted in long running workflows. Objects that need to be stored in the AVEVA Work Tasks variables should be marked as 'Serializable'.

using System;

using System.Collections.Generic;

using System.Text;

namespace Product

{

/// <summary>

/// Product Class

/// </summary>

[Serializable]  

public class Product

{

string _code = string.Empty;

string _name = string.Empty;

string _description = string.Empty;

double _unitPrice = 0.0;


/// <summary>

/// Product code

/// </summary>

public string Code

{

get { return _code; }

set { _code = value; }

}


/// <summary>

/// Product name

/// </summary>

public string Name

{

get { return _name; }

set { _name = value; }

}


/// <summary>

/// Product Description

/// </summary>

public string Description

{

get { return _description; }

set { _description = value; }

}


/// <summary>

/// Price

/// </summary>

public double UnitPrice

{

get { return _unitPrice; }

set { _unitPrice = value; }

}

public Product(string code, string name, string description, double price)

{

this._code = code;

this._name = name;

this._description = description;

this._unitPrice = price;

}

}


/// <summary>

/// Order Class

/// </summary>

public class OrderLineCalculate

{

public OrderLineCalculate() { }


/// <summary>

/// Get Total amount to be paid

/// </summary>

/// <param name="product">Product</param>

/// <param name="quantity">Quantity</param>

/// <returns>Total Price to be paid</returns>

public double GetAmount(Product product, int quantity)

{

return (product.UnitPrice * quantity);

}

}

}

 

  1. Using the above code creates an assembly. For e.g. Product.dll

  2. Place the assembly in the SOA folder, the folder from which the SOA assemblies are registered. For e.g. M:\SOA\Assemblies\Product.dll.

  3. Register the folder (M:\SOA\Assemblies) in the AVEVA Work Tasks Object Access folder.

  4. Register the 'Product' assembly [Product.dll] in SOA Assemblies from the SOA folder.

  5. The registered assembly will get displayed in the SOA assembly list.

Related Links
TitleResults for “How to create a CRG?”Also Available in