none
Pass an object from one custom .net activity to another. RRS feed

  • Question

  • Hi,

    I want to pass an object from one custom .net activity to another activity. But I am not able to pass the whole object. At the end I can only subscribe the public properties from the first activity's output to the next activity's input. Actually I am only able to use the public properties(declared as opalis output) of a class(declared as opalis data) as a input in another activity but not the object of this class itself.

    Is there any way to do that?

    I am using QIK 6.3. and system center orchestrator 2012.

    For the better understanding let me put some more information about my class:-

    ================My opalis data class which i am using for output================== 

    namespace test

    {
    [OpalisData("Custom Output Data")]
    public class Output
    {
    private string distinguishedNames;

    public Output(string info)
    {
    this.distinguishedNames = info;
    }

    [OpalisOutput]
    public string DistinguishedNames
    {
    get { return distinguishedNames; }
    set { distinguishedNames = value; }
    }
    }
    }
    ================My OpalisObject class===================
    namespace test
    {
    [OpalisObject("GetChassis")]
    public class GetChassis
    {
    public override void Design(IOpalisDesigner designer)
    {
    designer.AddInput("Chassis ID");
    designer.AddOutput("Chassis Count");
    designer.AddCorellatedData(typeof(Output));
    }

    protected override void ProcessSingleInstance(AuthenticateHandle handle, IOpalisRequest request, IOpalisResponse response)
    {
    List<string> moInfoList = new List<string>();

    ConfOutPut crc = MethodFactory.ConfOutPut(handle, NamingClassId.CHASSIS_CLASS_NAME, YesOrNo.FALSE);
    if (crc.ErrorCode == 0)
    {
    foreach (var chassisObject in crc.OutConf.GetChild<Chassis_class_name>())
    moInfoList.Add(chassisObject.Dn);
    IEnumerable moData = getMoData(moInfoList);
    int numMos = response.PublishRange(moData);
    response.Publish("Chassis Count", numMos);
    }
    else
    {
    response.ReportErrorEvent(crc.ErrorDescr, "Not able to do the required job.");
    }
    }

    protected IEnumerable<Output> getMoData(List<string> moList)
    {
    foreach (string moInfoData in moList)
    {
    yield return new Output(moInfoData);
    }
    }
    }
    }
    Now in the end as we are publishing the object of the Output class, then why i am only getting "DistinguishedNames" as published output instead of the object of the "Output" class.

    Can any one help?

     

    Regards,

    Vinay

     



    Monday, October 3, 2011 11:05 AM

Answers

  • Unfortunately, you cannot pass objects across the published data bus. Everything that is passed is converted to strings and then converted back to the data type needed by the next activity. The only way you can pass an object is via a continuously-open channel in the background like PowerShell (which you'd have to physically keep open, otherwise it opens and closes for each activity).


    Robert Hearn • Sr. Program Manager
    Opalis / System Center Orchestrator

    • Marked as answer by Vinay Ravish Tuesday, October 4, 2011 3:28 AM
    Monday, October 3, 2011 3:56 PM

All replies

  • Unfortunately, you cannot pass objects across the published data bus. Everything that is passed is converted to strings and then converted back to the data type needed by the next activity. The only way you can pass an object is via a continuously-open channel in the background like PowerShell (which you'd have to physically keep open, otherwise it opens and closes for each activity).


    Robert Hearn • Sr. Program Manager
    Opalis / System Center Orchestrator

    • Marked as answer by Vinay Ravish Tuesday, October 4, 2011 3:28 AM
    Monday, October 3, 2011 3:56 PM
  • Thank you Robert for your quick response and time.

     

    Regards,

    Vinay

    Tuesday, October 4, 2011 4:34 AM
  • Vinay

    (Sorry for dragging up this topic - I've come across a need to do this too, and thought I'd chip in my thoughts)

    Whilst you can't pass objects between activities on the databus, you can keep them in memory and reuse them in later activities. The way I'm proposing to do this is to keep a static dictionary of GUID -> object mappings. I'll hand out GUIDs in place of the objects on outputs, and retrieve the objects by GUID on the way in.

    This works in SCORCH right now because activities all run within the same AppDomain. Microsoft might change this in future versions of SCORCH - but they'll probably find integration packs out there right now that rely on caching objects for the life of a runbook that break if they split activities into seperate AppDomains. Plus doing that would be pretty awful for runbook performance - so hopefully this won't happen.

    Friday, April 6, 2012 5:08 PM