protected internal virtual IList <IHistoricIdentityLink> GetLinksForTask(ICommandContext commandContext)
        {
            IHistoricTaskInstanceEntity task = commandContext.HistoricTaskInstanceEntityManager.FindById <IHistoricTaskInstanceEntity>(new KeyValuePair <string, object>("historicTaskInstanceId", taskId));

            if (task == null)
            {
                throw new ActivitiObjectNotFoundException("No historic task exists with the given id: " + taskId, typeof(IHistoricTaskInstance));
            }

            IList <IHistoricIdentityLink> identityLinks = (IList <IHistoricIdentityLink>)commandContext.HistoricIdentityLinkEntityManager.FindHistoricIdentityLinksByTaskId(taskId);

            // Similar to GetIdentityLinksForTask, return assignee and owner as
            // identity link
            if (task.Assignee is object)
            {
                IHistoricIdentityLinkEntity identityLink = commandContext.HistoricIdentityLinkEntityManager.Create();
                identityLink.UserId = task.Assignee;
                identityLink.TaskId = task.Id;
                identityLink.Type   = IdentityLinkType.ASSIGNEE;
                identityLinks.Add(identityLink);
            }
            if (task.Owner is object)
            {
                IHistoricIdentityLinkEntity identityLink = commandContext.HistoricIdentityLinkEntityManager.Create();
                identityLink.TaskId = task.Id;
                identityLink.UserId = task.Owner;
                identityLink.Type   = IdentityLinkType.OWNER;
                identityLinks.Add(identityLink);
            }

            return(identityLinks);
        }
Example #2
0
        // Identity link related history

        /// <summary>
        ///
        /// </summary>
        /// <param name="identityLink"></param>
        public virtual void RecordIdentityLinkCreated(IIdentityLinkEntity identityLink)
        {
            // It makes no sense storing historic counterpart for an identity-link
            // that is related
            // to a process-definition only as this is never kept in history
            if (IsHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.ProcessInstanceId is object || identityLink.TaskId is object))
            {
                IHistoricIdentityLinkEntity historicIdentityLinkEntity = HistoricIdentityLinkEntityManager.Create();
                historicIdentityLinkEntity.Id                = identityLink.Id;
                historicIdentityLinkEntity.GroupId           = identityLink.GroupId;
                historicIdentityLinkEntity.ProcessInstanceId = identityLink.ProcessInstanceId;
                historicIdentityLinkEntity.TaskId            = identityLink.TaskId;
                historicIdentityLinkEntity.Type              = identityLink.Type;
                historicIdentityLinkEntity.UserId            = identityLink.UserId;
                HistoricIdentityLinkEntityManager.Insert(historicIdentityLinkEntity, false);
            }
        }