PDIM Library

by onezero
3 months ago
221 Views

Table of Contents


Voodoo Code Step: Main Class

The below design enables the user to write and use their own codes in scenario flow. Below is the default code version of the code step produced in C# selection. The target code needs to be written in the ExecuteComputation method. In scenario flow, when coming to this step, this main method is called. After this method completed, the scenario goes on to other steps. To integrate your code into the scenario, you can use one of the Voodoo Built-In Library namely Voodoo Plan Data Instance Manager (PDIM).

namespace VoodooImplementation
{
    using System;
    using System.Windows.Forms;
    using VooDooCommonData.CommonInterface;
    using VooDooCommonData.InstanceData;

    public class ComputationEvaluator : System.MarshalByRefObject, IPlugInComputation
    {
        private bool result_;
        private VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager_;

        public ComputationEvaluator()
        {
        }

        public bool result
        {
            get
            {
                return result_;
            }
        }

        public virtual VooDooCommonData.InstanceData.PlanDataInstanceManager planDataInstanceManager
        {
            get
            {
                return planDataInstanceManager_;
            }
            set
            {
                planDataInstanceManager_ = value;
            }
        }

        public virtual void ExecuteComputation()
        {
            //First Initialized Method: Your Code Here
        }
    }
}

PlanDataInstanceManager Class

Constructors

Property Description
PlanDataInstanceManager() Create a new instance of an object.

Note: Object for this class is automatically created by Voodoo as shown above in default class schema. So, there is no need to manually create that.

Methods

Property Description
void SetDataRowIndex (long dataDefinitionId, long dataRowIndex) Move the pointer to the target index in DataSource.

dataDefinitionId: DataSource Id

dataRowIndex: Index to be set

Example: You create DataSource that’s Id is 3. And, you want to set the pointer of DataSource into the first row. So, you need to call the below code.

planDataInstanceManager_.SetDataRowIndex(3, 0);

 

long GetDataRowIndex(long dataDefinitionId) Return the active row’s index in DataSource.

dataDefinitionId: DataSource Id

Example: You create a DataSource that’s Id is 3. And, you want to get the pointer location of DataSource. So, you need to call the below code.

long curRowIndex = planDataInstanceManager_.GetDataRowIndex(3);

 

void IncrementDataRowIndex(long dataDefinitionId) Increment the index of active row in DataSource.

dataDefinitionId: DataSource Id

Example: You have a data source that’s Id is 3 and in there are 10 records. Active row is 0 at initialization of DataSource during scenario process execution. And, you want to increment the pointer of DataSource up to next row. So, you need to call the below code.

planDataInstanceManager_.IncrementDataRowIndex(3);

 

bool CheckIfDataRowIndexLessThanDataRowCount(long dataDefinitionId) Return true if active row is smaller than data table row count else return false.
Especially, use to get to know when loop through whether last row is passing on the DataTable.

dataDefinitionId: DataSource Id

Example: You have a data source that’s Id is 3 and in there are some records. And, you want to know the last pointer of DataSource and whether there is a new row. So, you need to call the below code.

if (planDataInstanceManager_.CheckIfDataRowIndexLessThanDataRowCount(3))
{
    result_ = true;
}
else
{
    result_ = false;
}

 

object GetDataTableValueFromCurrentDataRowIndex(long dataDefinitionId, string columnName) Return the column value that is given as parameter on active row in DataTable as object type.

dataDefinitionId: DataSource Id

Example: You have a DataSource that’s Id is 3 and in there are 5 records. And, you need to get the value of active row at “Ad” column in this DataSource. So, you need to call the below code.

string ad = planDataInstanceManager_.GetDataTableValueFromCurrentDataRowIndex(3, “Ad”).ToString();

 

void SetDataTableValueFromCurrentDataRowIndex(long dataDefinitionId, string columnName, object value) Set the value given to the column value given as a parameter in the active row in the data table.

dataDefinitionId: DataSource Id

Example: You have a DataSource that’s Id is 3 and in there are 5 records. And, you need to set the value as “Ahmet” to active row of “Ad” column in this DataSource. So, you need to call the below code.

Note: Variable type of column and set value type must be same.
planDataInstanceManager_.SetDataTableValueFrom(3, “Ad”, “Ahmet”);

 

object GetVariableValue(long dataDefinitionId) Return the value given to the column value given as a parameter in the active row in the data table.

dataDefinitionId: DataSource Id

Example: You have a DataSource that’s Id is 3 and in there are 5 records. And, you need to get the value from active row of first column. So, you need to call the below code.

string deger = planDataInstanceManager_. GetDataTableValueFrom(3).ToString();

 

void SetVariableValue(long dataDefinitionId, object value) Set the value given to the value of the first column in the active row in the DataSource.

dataDefinitionId: DataSource Id
Value: Set value

Example: You have a DataSource that’s Id is 3 and in there are 5 records. And, you need to set the value as “Suna” to active row of first column in this DataSource. So, you need to call the below code.

Note: Variable type of column and set value type must be same.
planDataInstanceManager_.SetDataTableValueFrom(3, “Suna”);

 

Type GetDataTypeOfColumn(long dataDefinitionId, string columnName) Return the value of requested column type in the DataSource.

dataDefinitionId: DataSource Id
columnName: Column name requested data type

Example: You have a DataSource that’s Id is 3. And, you need to get “Ad” column type whether is string. So, you need to call the below code.

if (columnType ==  
    System.Type.GetType("System.String"))
{
    // ..
}

 

int SetDataTableValueFromCurrentDataRowIndexWithTypeConversion(long dataDefinitionId, string columnName, string stringValue) Set the value given to the column value given as a parameter in the active row in the DataSource. Since the given value is a string, it assigns the value of the string to the column data type, if necessary, by looking at the type of the column.

dataDefinitionId: DataSource Id
columnName: Column name requested data type
Value: Set value

Example: You have a DataSource that’s Id is 3 and in there are 5 records. And, you need to call the value to set “123” value to active column of “Adet” column in the DataSource. So, you need to call the below code. During the set time, function set the “123” string value as number in case the column type is number.

Note: System.String, System.Int32, System.Int64, System.Decimal types are supported.
planDataInstanceManager_.SetDataTableValueFromCurrentDataRowIndexWithTypeConversion(3, “Adet”, “123”);

 

System.Data.DataRow GetNewRow(long dataDefinitionId) Create a new row to add in the DataSource.

dataDefinitionId: DataSource Id
dataRow: Adding row

Example: You have a DataSource that’s Id is 3. And, you need to add a new row to the end of the DataSource with 3 columns. So, you need to call the below code.

Note: This function does not increment the pointer by 1.

DataRow dr = planDataInstanceManager_.GetNewRow(3);
            dr[0] = 0;
            dr[1] = "";
            dr[2] = "";
            planDataInstanceManager_.AddRowToDataTable(3, dr);

 

System.Data.DataRow GetNewRow(long dataDefinitionId) Add given row to the DataSource.

dataDefinitionId: DataSource Id
dataRow: Adding row

Example: You have a DataSource that’s Id is 3. And, you need to add the given row to the end of the DataSource with 2 columns. So, you need to call the below code.

DataRow dr1 = planDataInstanceManager_.GetNewRow(3);
            dr1[0] = "1";
            dr1[1] = "Pelin";
            planDataInstanceManager_.AddRowToDataTable(3, dr1);

 

void DeleteRowFromDataTable(long dataDefinitionId, int rowIndexToDelete) Delete a row from DataSoruce.

dataDefinitionId: DataSource Id
Value: Set value

Example: You have a DataSource that’s Id is 3. And, you need to delete a row from the DataSource. So, you need to call the below code.
planDataInstanceManager_.DeleteRowFromDataTable(3, 0);