How to include subprocesses in business operation

StatusIDPriorityType
Closed39718MajorQuestion
ProfileReply
SesenteClient

I want to convert the provided business operation to synchronous
With subprocesses.

Replies

UserDescriptionPosted On
MariyaVoytovichAgent

Hello!

You can create your own Managed Business Operationthat will be performed by subprocesses.
To do this, you need to create a Business Operation, which will be implemented by the IBusinessOperationMangaed interface. For more infomation see Managed Business Operation Class
For example:

public abstract class CustomManagedBusinessOperation : BusinessOperationBase, IBusinessOperationManaged
    {
        private IManagedOperation _process;

        [Browsable(false)]
        public IManagedOperation Process
        {
            get { return _process ?? (_process = CreateManagedOperationStub()); }
            set { _process = value; }
        }

        /// 
        /// Executes the Business Operation in context of a managed operation.
        /// 
        /// This method also initializes  property with value returned by the  virtual method.
        /// A  object in which the Business Operation is executed.
        public IManagedOperation ExecuteManaged()
        {
            Process = CreateManagedOperation();
            this.CreateSubProcess(Process);
            Process.Start();
            return Process;
        }

        protected abstract void CreateSubProcess(IManagedOperation managedOperation);

        /// 
        /// Rollbacks the Business Operation in context of a managed operation.
        /// 
        /// This method also initializes  property with value returned by the  virtual method.
        /// A  object in which the Business Operation is executed.
        public IManagedOperation RollbackManaged()
        {
            Process = CreateManagedOperation();
            Process.ProcessCode = pc => Rollback();
            Process.Start();
            return Process;
        }

        /// 
        /// Factory method that creates  object.
        /// 
        /// A  object in which the Business Operation is executed.
        protected virtual IManagedOperation CreateManagedOperation()
        {
            var mo = new ManagedOperation(BusinessOperationManager.Instance.Application)
            {
                Name = this.Name,
                ZoneType = ManagedOperationZoneTypes.Local
            };
            return mo;
        }

        /// 
        /// Factory method that creates the  object.
        /// 
        /// For more information see the  property's description.
        /// The  object.
        protected virtual IManagedOperation CreateManagedOperationStub()
        {
            return new ManagedOperationStub();
        }
    }

Further in your business operations, you can override the CreateSubProcces method and create subprocesses.

       protected override void CreateSubProcess(IManagedOperation managedOperation)
       {
            (managedOperation as ManagedOperation).CreateSubProcess("ManagedOperationsSubprocesses1", item => Execute());
       }

Feel free to contact us if you need further assistance or have additional questions.

Regards,
Mariya
On behalf of Xafari Client Services Team

× This ticket is closed.

Write US