示例#1
0
        protected virtual void Share(IWorkflowActivityContext context, EntityReference entity)
        {
            var user = UserId.Get(context.GetExecutionContext());
            var team = TeamId.Get(context.GetExecutionContext());

            if (user != null)
            {
                Share(context, entity, user);
            }

            if (team != null)
            {
                Share(context, entity, team);
            }
        }
示例#2
0
        protected override void Execute(IWorkflowActivityContext context)
        {
            this.EnsureNotNull(context, nameof(context));

            var activityContext = context.GetExecutionContext();

            var primaryEntityId   = context.WorkflowContext.PrimaryEntityId;
            var primaryEntityName = context.WorkflowContext.PrimaryEntityName;
            var attributeName     = AttributeName.Get(activityContext);
            var primaryEntity     = RetrievePrimaryEntity(context, primaryEntityName, primaryEntityId, attributeName);

            var value = primaryEntity?.GetAttributeValue <Object>(attributeName);

            if (value == null)
            {
                return;
            }

            if (!(value is EntityReference))
            {
                throw new InvalidPluginExecutionException($"Invalid field value type {value.GetType().FullName}.");
            }

            var entityReference = (EntityReference)value;

            EntityLogicalName.Set(activityContext, entityReference.LogicalName);
            EntityId.Set(activityContext, entityReference.Id.ToString());
        }
        protected override void Execute(IWorkflowActivityContext context)
        {
            var executionContext = context.GetExecutionContext();

            var user = new EntityReference("systemuser", context.WorkflowContext.InitiatingUserId);

            User.Set(executionContext, user);
        }
示例#4
0
        protected override void Execute(IWorkflowActivityContext context)
        {
            this.EnsureNotNull(context, nameof(context));

            var activityContext = context.GetExecutionContext();

            var input = Input?.Get(activityContext);

            var output = Transform(activityContext, input);

            if (output.IsNotNull())
            {
                Output.Set(activityContext, output);
            }
        }
示例#5
0
        protected virtual AccessRights GetMask(IWorkflowActivityContext context)
        {
            var mask = AccessRights.None;

            if (Read.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.ReadAccess;
            }

            if (Append.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.AppendAccess;
            }

            if (AppendTo.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.AppendToAccess;
            }

            if (Read.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.ReadAccess;
            }

            if (Write.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.WriteAccess;
            }

            if (Delete.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.DeleteAccess;
            }

            if (AssignAccess.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.AssignAccess;
            }

            if (ShareAccess.Get(context.GetExecutionContext()))
            {
                mask = mask | AccessRights.ShareAccess;
            }

            return(mask);
        }
        protected override void Execute(IWorkflowActivityContext context)
        {
            this.EnsureNotNull(context, nameof(context));

            var activityContext = context.GetExecutionContext();

            var email   = TargetEmail.Get(activityContext);
            var applyTo = ApplyTo.Get(activityContext);

            if (email == null)
            {
                return;
            }

            if (applyTo.IsNullOrWhiteSpace())
            {
                return;
            }

            var role = Role.Get(activityContext);
            var team = Team.Get(activityContext);

            if (role == null && team == null)
            {
                return;
            }

            var roleUsers = GetRoleUsers(context, role);

            context.TracingService.Trace($"Found {roleUsers?.Count()} for role {role?.Id}");

            var teamUsers = GetTeamUsers(context, team);

            context.TracingService.Trace($"Found {teamUsers?.Count()} for team {team?.Id}");

            var users = roleUsers.Union(teamUsers).ToArray();

            if (users.Any())
            {
                UpdateEmail(
                    context,
                    email,
                    applyTo,
                    users);
            }
        }
示例#7
0
        protected override void Execute(IWorkflowActivityContext context)
        {
            var executionContext = context.GetExecutionContext();

            var email = Email.Get(executionContext);

            if (email.IsNullOrEmpty())
            {
                return;
            }

            var user = GetUser(context, email);

            if (user == null)
            {
                return;
            }

            User.Set(executionContext, user.ToEntityReference());
        }
示例#8
0
        protected override void Execute(IWorkflowActivityContext context)
        {
            var executionContext = context.GetExecutionContext();

            var user = User.Get(executionContext);

            if (user == null)
            {
                return;
            }

            var manager = context.OrganizationService.Retrieve(
                user.LogicalName,
                user.Id,
                SystemUserEntity.ManagerFieldName)?.GetAttributeValue <EntityReference>(SystemUserEntity.ManagerFieldName);

            if (manager == null)
            {
                return;
            }

            Manager.Set(executionContext, manager);
        }