locked
how to use defined variable and use it in code RRS feed

  • Question

  • I'm trying to assign OutArgument to a variable, and use it in next activity with VB expression, but there are many errors happening when I invoke run method, as below. 

    I want to know what is a correct way to create and use variable and how to assign value to InArgument like UI designer do

    -------------------------------------------------------------------------

    The following errors were encountered while processing the workflow tree:

    'VisualBasicValue<Boolean>': Compiler error(s) encountered processing expression "var_workItem is nothing".

    'var_workItem' is not declared. It may be inaccessible due to its protection level.

     

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression "out_InstanceID".

    'out_InstanceID' is not declared. It may be inaccessible due to its protection level.

     

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression ""Work Item (" + var_workItem.Id.ToString() + ") has been Created"".

    'var_workItem' is not declared. It may be inaccessible due to its protection level.

     

    'LogInformation': The activity 'VisualBasicValue<String>' cannot be referenced by activity 'LogInformation' because the latter is not in another activity's implementation.  An activity can only be referenced by the implementation of an activity which specifies that activity as a child or import.  Activity 'VisualBasicValue<String>' is declared by activity 'LogInformation'.

    'CreateWorkItem': The activity 'VisualBasicValue<String>' cannot be referenced by activity 'CreateWorkItem' because the latter is not in another activity's implementation.  An activity can only be referenced by the implementation of an activity which specifies that activity as a child or import.  Activity 'VisualBasicValue<String>' is declared by activity 'LogInformation'.

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression "in_Os".

    'in_Os' is not declared. It may be inaccessible due to its protection level.

     

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression "in_Sp".

    'in_Sp' is not declared. It may be inaccessible due to its protection level.

     

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression "in_Version".

    'in_Version' is not declared. It may be inaccessible due to its protection level.

     

    'VisualBasicValue<String>': Compiler error(s) encountered processing expression "in_BCAbbrName".

    'in_BCAbbrName' is not declared. It may be inaccessible due to its protection level.

     

    'Assign': Value for a required activity argument 'To' was not supplied.

    ------------------------------------------------------------------------------------------

     

    code section:

       protected override void Execute(CodeActivityContext context)
        {
          var extension = context.GetExtension<Extentions.MyExtention>();
          string in_Sp = context.GetValue(in_SpIn);
          string in_BcAbbrName = context.GetValue(in_BcAbbrNameIn);
          string in_Os = context.GetValue(in_OsIn);
          string in_Version = context.GetValue(in_VersionIn);
          InArgument<string> ina = new InArgument<string>("$/IGT_0803/release/BC/rel/" + in_BcAbbrName + "/" + in_Os + "_" + in_Version + "/" + in_Sp + "/EGS");
    
    
          Sequence root = new Sequence();
          Variable var_workItem= new Variable<WorkItem>("var_workItem");
          root.Variables.Add(var_workItem);
    
    
          root. Activities.Add( new Assign{To=ReleaseBranchRootOut, Value=ina});
          root.Activities.Add(new CreateWorkItem 
          {
            BcAbbrName = in_BcAbbrNameIn, 
            InstanceID = in_InstanceIDIn, 
            OsVersion = in_OsIn, 
            SP = in_SpIn, 
            Version = in_VersionIn,
            Result =new OutArgument<WorkItem>(var_workItem)
          });
    
      
          root.Activities.Add(
            new If 
            { 
              //use vb expression and variable to apply
              Condition = new VisualBasicValue<bool>("var_workItem is nothing"), 
              Else = new LogInformation { 
                InstanceID = in_InstanceIDIn, 
                LogInfo =new VisualBasicValue<string>("\"Work Item (\" + var_workItem.Id.ToString() + \") has been Created\""),
                LogType = new InArgument<string>("MSG") }, 
             Then = new LogInformation { 
               InstanceID = in_InstanceIDIn, 
               LogInfo = new InArgument<string>("Work Item Creation Task failed~!"), 
               LogType = new InArgument<string>("ERROR") }
            });
    
          AutoResetEvent completed = new AutoResetEvent(false);
          WorkflowApplication app = new WorkflowApplication(root);
          app.Extensions.Add(extension);
          app.Completed = (WorkflowApplicationCompletedEventArgs eArgs) => { completed.Set(); };
          app.Run();
        }
    



    pluto_sun
    Thursday, July 14, 2011 3:47 AM

Answers

All replies