public override void Finally()
            {
                Sample1Orchestration     __svc__  = (Sample1Orchestration)_service;
                __Sample1Orchestration_1 __ctx1__ = (__Sample1Orchestration_1)(__svc__._stateMgrs[1]);

                if (__ctx1__ != null && __ctx1__.__Sample1Message != null)
                {
                    __ctx1__.UnrefMessage(__ctx1__.__Sample1Message);
                    __ctx1__.__Sample1Message = null;
                }
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISApp = null;
                }
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISVar = null;
                }
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISPkg = null;
                }
                base.Finally();
            }
        public Microsoft.XLANGs.Core.StopConditions segment2(Microsoft.XLANGs.Core.StopConditions stopOn)
        {
            Microsoft.XLANGs.Core.Segment __seg__ = _segments[2];
            Microsoft.XLANGs.Core.Context __ctx__ = (Microsoft.XLANGs.Core.Context)_stateMgrs[2];
            ____scope33_2            __ctx2__     = (____scope33_2)_stateMgrs[2];
            __Sample1Orchestration_1 __ctx1__     = (__Sample1Orchestration_1)_stateMgrs[1];

            switch (__seg__.Progress)
            {
            case 0:
                __ctx__.PrologueCompleted = true;
                if (!PostProgressInc(__seg__, __ctx__, 1))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 1;

            case 1:
                if (!PreProgressInc(__seg__, __ctx__, 2))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[6], __eventData[3], _stateMgrs[2].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 2;

            case 2:
                __ctx1__.__SSISApp = new Microsoft.SqlServer.Dts.Runtime.Application();
                if (!PostProgressInc(__seg__, __ctx__, 3))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 3;

            case 3:
                if (!PreProgressInc(__seg__, __ctx__, 4))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[7], __eventData[4], _stateMgrs[2].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 4;

            case 4:
                __ctx1__.__SSISPkg = __ctx1__.__SSISApp.LoadPackage(@"C:\testsamples\Sample1\Sample1.dtsx", null);
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISApp = null;
                }
                if (!PostProgressInc(__seg__, __ctx__, 5))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 5;

            case 5:
                __ctx1__.__SSISVar = __ctx1__.__SSISPkg.Variables["User::orders"];
                if (!PostProgressInc(__seg__, __ctx__, 6))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 6;

            case 6:
                __ctx1__.__SSISVar.Value = (System.String)__ctx1__.__Sample1Message.part.GetDistinguishedField("SaleSummary.Orders");
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISVar = null;
                }
                if (__ctx1__ != null && __ctx1__.__Sample1Message != null)
                {
                    __ctx1__.UnrefMessage(__ctx1__.__Sample1Message);
                    __ctx1__.__Sample1Message = null;
                }
                if (!PostProgressInc(__seg__, __ctx__, 7))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 7;

            case 7:
                __ctx1__.__SSISPkg.Execute();
                if (__ctx1__ != null)
                {
                    __ctx1__.__SSISPkg = null;
                }
                if (!PostProgressInc(__seg__, __ctx__, 8))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 8;

            case 8:
                if (!__ctx2__.CleanupAndPrepareToCommit(__seg__))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Blocked);
                }
                if (!PostProgressInc(__seg__, __ctx__, 9))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 9;

            case 9:
                if (!PreProgressInc(__seg__, __ctx__, 10))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                __ctx2__.OnCommit();
                goto case 10;

            case 10:
                __seg__.SegmentDone();
                _segments[1].PredecessorDone(this);
                break;
            }
            return(Microsoft.XLANGs.Core.StopConditions.Completed);
        }
        public Microsoft.XLANGs.Core.StopConditions segment1(Microsoft.XLANGs.Core.StopConditions stopOn)
        {
            Microsoft.XLANGs.Core.Envelope __msgEnv__ = null;
            Microsoft.XLANGs.Core.Segment  __seg__    = _segments[1];
            Microsoft.XLANGs.Core.Context  __ctx__    = (Microsoft.XLANGs.Core.Context)_stateMgrs[1];
            ____scope33_2                 __ctx2__    = (____scope33_2)_stateMgrs[2];
            __Sample1Orchestration_1      __ctx1__    = (__Sample1Orchestration_1)_stateMgrs[1];
            __Sample1Orchestration_root_0 __ctx0__    = (__Sample1Orchestration_root_0)_stateMgrs[0];

            switch (__seg__.Progress)
            {
            case 0:
                __ctx1__.__SSISApp        = default(Microsoft.SqlServer.Dts.Runtime.Application);
                __ctx1__.__SSISPkg        = default(Microsoft.SqlServer.Dts.Runtime.Package);
                __ctx1__.__SSISVar        = default(Microsoft.SqlServer.Dts.Runtime.Variable);
                __ctx1__.__Sample1Message = null;
                __ctx__.PrologueCompleted = true;
                if (!PostProgressInc(__seg__, __ctx__, 1))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 1;

            case 1:
                if (!PreProgressInc(__seg__, __ctx__, 2))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[0], __eventData[0], _stateMgrs[1].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 2;

            case 2:
                if (!PreProgressInc(__seg__, __ctx__, 3))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[1], __eventData[1], _stateMgrs[1].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 3;

            case 3:
                if (!Sample1Port.GetMessageId(__ctx0__.__subWrapper0.getSubscription(this), __seg__, __ctx1__, out __msgEnv__))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Blocked);
                }
                if (__ctx1__.__Sample1Message != null)
                {
                    __ctx1__.UnrefMessage(__ctx1__.__Sample1Message);
                }
                __ctx1__.__Sample1Message = new __messagetype_Sample1_SalesSchema("Sample1Message", __ctx1__);
                __ctx1__.RefMessage(__ctx1__.__Sample1Message);
                Sample1Port.ReceiveMessage(0, __msgEnv__, __ctx1__.__Sample1Message, null, (Microsoft.XLANGs.Core.Context)_stateMgrs[1], __seg__);
                if (!PostProgressInc(__seg__, __ctx__, 4))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 4;

            case 4:
                if (!PreProgressInc(__seg__, __ctx__, 5))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                {
                    Microsoft.XLANGs.RuntimeTypes.EventData __edata = new Microsoft.XLANGs.RuntimeTypes.EventData(Microsoft.XLANGs.RuntimeTypes.Operation.End | Microsoft.XLANGs.RuntimeTypes.Operation.Receive);
                    __edata.Messages.Add(__ctx1__.__Sample1Message);
                    __edata.PortName = @"Sample1Port";
                    Tracker.FireEvent(__eventLocations[2], __edata, _stateMgrs[1].TrackDataStream);
                }
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 5;

            case 5:
                __ctx1__.__SSISApp = new Microsoft.SqlServer.Dts.Runtime.Application();
                if (!PostProgressInc(__seg__, __ctx__, 6))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 6;

            case 6:
                __ctx1__.__SSISPkg = new Microsoft.SqlServer.Dts.Runtime.Package();
                if (!PostProgressInc(__seg__, __ctx__, 7))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 7;

            case 7:
                if (!PreProgressInc(__seg__, __ctx__, 8))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[4], __eventData[2], _stateMgrs[1].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 8;

            case 8:
                __ctx2__      = new ____scope33_2(this);
                _stateMgrs[2] = __ctx2__;
                if (!PostProgressInc(__seg__, __ctx__, 9))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 9;

            case 9:
                __ctx1__.StartContext(__seg__, __ctx2__);
                if (!PostProgressInc(__seg__, __ctx__, 10))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                return(Microsoft.XLANGs.Core.StopConditions.Blocked);

            case 10:
                if (!PreProgressInc(__seg__, __ctx__, 11))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[9], __eventData[5], _stateMgrs[1].TrackDataStream);
                __ctx2__.Finally();
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 11;

            case 11:
                if (!PreProgressInc(__seg__, __ctx__, 12))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                Tracker.FireEvent(__eventLocations[3], __eventData[6], _stateMgrs[1].TrackDataStream);
                if (IsDebugged)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.InBreakpoint);
                }
                goto case 12;

            case 12:
                if (!__ctx1__.CleanupAndPrepareToCommit(__seg__))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Blocked);
                }
                if (!PostProgressInc(__seg__, __ctx__, 13))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 13;

            case 13:
                if (!PreProgressInc(__seg__, __ctx__, 14))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                __ctx1__.OnCommit();
                goto case 14;

            case 14:
                __seg__.SegmentDone();
                _segments[0].PredecessorDone(this);
                break;
            }
            return(Microsoft.XLANGs.Core.StopConditions.Completed);
        }
        public Microsoft.XLANGs.Core.StopConditions segment0(Microsoft.XLANGs.Core.StopConditions stopOn)
        {
            Microsoft.XLANGs.Core.Segment __seg__  = _segments[0];
            Microsoft.XLANGs.Core.Context __ctx__  = (Microsoft.XLANGs.Core.Context)_stateMgrs[0];
            __Sample1Orchestration_1      __ctx1__ = (__Sample1Orchestration_1)_stateMgrs[1];
            __Sample1Orchestration_root_0 __ctx0__ = (__Sample1Orchestration_root_0)_stateMgrs[0];

            switch (__seg__.Progress)
            {
            case 0:
                Sample1Port = new Sample1PortType(0, this);
                __ctx__.PrologueCompleted = true;
                __ctx0__.__subWrapper0    = new Microsoft.XLANGs.Core.SubscriptionWrapper(ActivationSubGuids[0], Sample1Port, this);
                if (!PostProgressInc(__seg__, __ctx__, 1))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                if ((stopOn & Microsoft.XLANGs.Core.StopConditions.Initialized) != 0)
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Initialized);
                }
                goto case 1;

            case 1:
                __ctx1__      = new __Sample1Orchestration_1(this);
                _stateMgrs[1] = __ctx1__;
                if (!PostProgressInc(__seg__, __ctx__, 2))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 2;

            case 2:
                __ctx0__.StartContext(__seg__, __ctx1__);
                if (!PostProgressInc(__seg__, __ctx__, 3))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                return(Microsoft.XLANGs.Core.StopConditions.Blocked);

            case 3:
                if (Sample1Port != null)
                {
                    Sample1Port.Close(__ctx0__, __seg__);
                    Sample1Port = null;
                }
                if (!__ctx0__.CleanupAndPrepareToCommit(__seg__))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Blocked);
                }
                if (!PostProgressInc(__seg__, __ctx__, 4))
                {
                    return(Microsoft.XLANGs.Core.StopConditions.Paused);
                }
                goto case 4;

            case 4:
                __ctx1__.Finally();
                ServiceDone(__seg__, (Microsoft.XLANGs.Core.Context)_stateMgrs[0]);
                __ctx0__.OnCommit();
                break;
            }
            return(Microsoft.XLANGs.Core.StopConditions.Completed);
        }
        public Microsoft.XLANGs.Core.StopConditions segment0(Microsoft.XLANGs.Core.StopConditions stopOn)
        {
            Microsoft.XLANGs.Core.Segment __seg__ = _segments[0];
            Microsoft.XLANGs.Core.Context __ctx__ = (Microsoft.XLANGs.Core.Context)_stateMgrs[0];
            __Sample1Orchestration_1 __ctx1__ = (__Sample1Orchestration_1)_stateMgrs[1];
            __Sample1Orchestration_root_0 __ctx0__ = (__Sample1Orchestration_root_0)_stateMgrs[0];

            switch (__seg__.Progress)
            {
            case 0:
                Sample1Port = new Sample1PortType(0, this);
                __ctx__.PrologueCompleted = true;
                __ctx0__.__subWrapper0 = new Microsoft.XLANGs.Core.SubscriptionWrapper(ActivationSubGuids[0], Sample1Port, this);
                if ( !PostProgressInc( __seg__, __ctx__, 1 ) )
                    return Microsoft.XLANGs.Core.StopConditions.Paused;
                if ((stopOn & Microsoft.XLANGs.Core.StopConditions.Initialized) != 0)
                    return Microsoft.XLANGs.Core.StopConditions.Initialized;
                goto case 1;
            case 1:
                __ctx1__ = new __Sample1Orchestration_1(this);
                _stateMgrs[1] = __ctx1__;
                if ( !PostProgressInc( __seg__, __ctx__, 2 ) )
                    return Microsoft.XLANGs.Core.StopConditions.Paused;
                goto case 2;
            case 2:
                __ctx0__.StartContext(__seg__, __ctx1__);
                if ( !PostProgressInc( __seg__, __ctx__, 3 ) )
                    return Microsoft.XLANGs.Core.StopConditions.Paused;
                return Microsoft.XLANGs.Core.StopConditions.Blocked;
            case 3:
                if (Sample1Port != null)
                {
                    Sample1Port.Close(__ctx0__, __seg__);
                    Sample1Port = null;
                }
                if (!__ctx0__.CleanupAndPrepareToCommit(__seg__))
                    return Microsoft.XLANGs.Core.StopConditions.Blocked;
                if ( !PostProgressInc( __seg__, __ctx__, 4 ) )
                    return Microsoft.XLANGs.Core.StopConditions.Paused;
                goto case 4;
            case 4:
                __ctx1__.Finally();
                ServiceDone(__seg__, (Microsoft.XLANGs.Core.Context)_stateMgrs[0]);
                __ctx0__.OnCommit();
                break;
            }
            return Microsoft.XLANGs.Core.StopConditions.Completed;
        }