So i made my own Custom NativeActivity and it worked as expected untill i tried putting Itself as a childActivity. Now i get this Error.
Full text : The private implementation of Activity ‘1.14: Time agent’ has the following validation error: Compile error encountered processing expressing ‘table’
Variable is not declared. It may be inaccessible due to its protection level.
As seen the variable is declared. and it also work when my activity doesn’t contain the a copy of itself.
Instantiating a new Table, errorstate and title for the innner sequence still raises the same error.
Anyone have any clues to what could be the cause ?
public class TimeAgent : NativeActivity
{
private Stopwatch stopwatch;
private Sequence innerSequence = new Sequence();
[Browsable(false)]
public Collection<Activity> Activities
{
get
{
return innerSequence.Activities;
}
}
[Browsable(false)]
public Collection<Variable> Variables
{
get
{
return innerSequence.Variables;
}
}
private string value_taskname = "Title";
private string value_elapsedtime = "Time";
[Category("Input")]
[RequiredArgument]
public InArgument<DataTable> DataTable { get; set; }
[Category("Input")]
[RequiredArgument]
public InArgument<string> Title { get; set; }
[Category("Input")]
[RequiredArgument]
public InArgument<bool> ErrorState { get; set; }
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
God.AddStopwatch();
stopwatch = God.GetStopwatch();
metadata.AddImplementationChild(innerSequence);
RuntimeArgument argErrorState = new RuntimeArgument("RTA_ErrorState", ErrorState.ArgumentType, ArgumentDirection.In);
metadata.Bind(ErrorState, argErrorState);
metadata.AddArgument(argErrorState);
RuntimeArgument argDataTable = new RuntimeArgument("RTA_DataTable", DataTable.ArgumentType, ArgumentDirection.In);
metadata.Bind(DataTable, argDataTable);
metadata.AddArgument(argDataTable);
RuntimeArgument argTaskname = new RuntimeArgument("RTA_Taskname", Title.ArgumentType, ArgumentDirection.In);
metadata.Bind(Title, argTaskname);
metadata.AddArgument(argTaskname);
}
protected override void Execute(NativeActivityContext context)
{
bool errorstate = ErrorState.Get(context);
if (!errorstate)
{
InstantiateDatatableColumns(DataTable.Get(context));
stopwatch.Reset();
stopwatch.Start();
context.ScheduleActivity(innerSequence, OnCompleted, OnFaulted);
}
else
{
DataTable dataTable = DataTable.Get(context);
dataTable.Rows.Add(Title.Get(context), 0);
}
}
private void OnCompleted(NativeActivityContext context, ActivityInstance completedInstance)
{
double elapsedtime;
God.FinishStopwatch(out elapsedtime);
DataTable dataTable = DataTable.Get(context);
dataTable.Rows.Add(Title.Get(context), elapsedtime);
}
private void OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
{
stopwatch.Stop();
faultContext.CancelChild(propagatedFrom);
}
}