protected override void Execute(CodeActivityContext executionContext)
        {
            var factory = executionContext.GetExtension <IOrganizationServiceFactory>() as IOrganizationServiceFactory;

            CodeActivityContext = executionContext;
            TracingService      = executionContext.GetExtension <ITracingService>() as ITracingService;
            WorkflowContext     = executionContext.GetExtension <IWorkflowContext>() as IWorkflowContext;
            IOrganizationService orgService         = factory.CreateOrganizationService(WorkflowContext.UserId) as IOrganizationService;
            IOrganizationService orgServiceAsSystem = factory.CreateOrganizationService(null) as IOrganizationService;

            OrgServiceWrapper = new OrganizationServiceWrapper(orgService, orgServiceAsSystem, new TransactionalService(orgService), new TransactionalService(orgServiceAsSystem));

            InternalExecute();
        }
        internal LocalPluginContext(IServiceProvider serviceProvider, Bus bus)
        {
            serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            this.bus        = bus ?? throw new ArgumentNullException(nameof(bus));

            // Obtain the execution context service from the service provider.
            this.PluginExecutionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            // Obtain the tracing service from the service provider.
            this.TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            // Obtain the Organization Service factory service from the service provider
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            // Use the factory to generate the Organization Service.
            IOrganizationService orgService         = factory.CreateOrganizationService(this.PluginExecutionContext.UserId);
            IOrganizationService orgServiceAsSystem = factory.CreateOrganizationService(null);

            OrgServiceWrapper = new OrganizationServiceWrapper(orgService, orgServiceAsSystem, new TransactionalService(orgService), new TransactionalService(orgServiceAsSystem));
        }