Exemple #1
0
        /// <inheritdoc />
        public override IList <IUserInfo> Execute(ICommandContext commandContext)
        {
            IUserServiceProxy proxy = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            string id = Condition.QueryCondition.FirstOrDefault().Id;

            string[] users      = null;
            var      hisService = commandContext.ProcessEngineConfiguration.HistoryService;

            if (string.IsNullOrWhiteSpace(id))
            {
                var uid = hisService.CreateHistoricProcessInstanceQuery()
                          .SetProcessInstanceId(this.Execution.ProcessInstanceId)
                          .SingleResult().StartUserId;
                users = new string[] { uid };
            }
            else
            {
                users = hisService.CreateHistoricTaskInstanceQuery()
                        .SetProcessInstanceId(this.Execution.ProcessInstanceId)
                        .SetTaskDefinitionKey(id)
                        .List()
                        .Select(x => x.Assignee)
                        .ToArray();
            }

            return(proxy.GetUsers(externalConnector.GetUserByDirectReporter, new RequestUserParameter
            {
                IdList = users,
                Category = RequestUserCategory.GETUSER_DIRECTREPOT
            }).ConfigureAwait(false).GetAwaiter().GetResult());
        }
Exemple #2
0
        private IUserInfo GetUser(IExecutionEntity execution, string authenticatedUserId)
        {
            IUserInfo         starter;
            IUserServiceProxy userService = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            try
            {
                starter = userService.GetUser(authenticatedUserId)
                          .ConfigureAwait(false)
                          .GetAwaiter()
                          .GetResult();
                starter.TenantId = execution.TenantId;
            }
            catch (Exception ex)
            {
                logger.LogError(ex, ex.Message);
                starter = new UserInfo
                {
                    Id       = execution.StartUserId,
                    FullName = execution.StartUserId,
                    TenantId = execution.TenantId
                };
            }

            return(starter);
        }
        public void Notify(IDelegateTask task)
        {
            string assignee = task.Assignee;

            if (string.IsNullOrWhiteSpace(assignee))
            {
                return;
            }

            IUserInfo user = task.GetVariableLocal <IUserInfo>($"{assignee}");

            if (!(user is null) && user.Id == assignee)
            {
                return;
            }

            IUserServiceProxy userService = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            user = AsyncHelper.RunSync(() => userService.GetUser(assignee));
            if (user == null)
            {
                logger.LogError($"找不到执行人{assignee}");
            }
            else
            {
                user.TenantId     = task.TenantId;
                task.AssigneeUser = user.FullName;
            }

            task.SetVariableLocal($"{assignee}", user);
        }
Exemple #4
0
        public AddCountersignCmd(string taskId, string[] assignees, string tenantId)
        {
            this.taskId    = taskId;
            this.assignees = assignees;
            this.tenantId  = tenantId;

            userService = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();
        }
        /// <inheritdoc />
        public override IList <IUserInfo> Execute(ICommandContext commandContext)
        {
            IUserServiceProxy proxy = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            return(AsyncHelper.RunSync(() => proxy.GetUsers(externalConnector.GetUserByDeptLeader, new
            {
                idList = Condition.QueryCondition.Select(x => x.Id).ToArray()
            })));
        }
Exemple #6
0
 public AddIdentityLinkCmd(string taskId, string identityId, int identityIdType, string identityType) : base(taskId)
 {
     ValidateParams(taskId, identityId, identityIdType, identityType);
     this.taskId         = taskId;
     this.identityId     = identityId;
     this.identityIdType = identityIdType;
     this.identityType   = identityType;
     userService         = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();
 }
Exemple #7
0
 public CommentAppService(IDbUnitOfWork dbUnitOfWork, IUserServiceProxy userServiceProxy, ICommentRepository commentRepository, ICommentTagRepository commentTagRepository, ICommentImageRepository commentImageRepository, IAuthServiceProxy authServiceProxy)
 {
     _commentRepository      = commentRepository;
     _commentTagRepository   = commentTagRepository;
     _dbUnitOfWork           = dbUnitOfWork;
     _commentImageRepository = commentImageRepository;
     _authServiceProxy       = authServiceProxy;
     _userServiceProxy       = userServiceProxy;
 }
Exemple #8
0
        /// <inheritdoc />
        public override IList <IUserInfo> Execute(ICommandContext commandContext)
        {
            IUserServiceProxy proxy = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            return(proxy.GetUsers(externalConnector.GetUserByDuty, new RequestUserParameter
            {
                IdList = Condition.QueryCondition.Select(x => x.Id).ToArray(),
                Category = RequestUserCategory.GETUSERS_DUTY
            }).ConfigureAwait(false).GetAwaiter().GetResult());
        }
Exemple #9
0
 public ServicerAppService(IServicerRepository servicerRepository, IUserServiceProxy userProxy, IServicerImageRepository servicerImageRepository, IDbUnitOfWork dbUnitOfWork, IImageServiceProxy imageServiceProxy, IOrganizationServiceProxy organizationServiceProxy, IAmapProxy amapProxy)
 {
     _servicerRepository       = servicerRepository;
     _servicerImageRepository  = servicerImageRepository;
     _dbUnitOfWork             = dbUnitOfWork;
     _imageServiceProxy        = imageServiceProxy;
     _organizationServiceProxy = organizationServiceProxy;
     _amapProxy = amapProxy;
     _userProxy = userProxy;
 }
 public CreateNewSubtaskCmd(string taskName, string description, DateTime?dueDate, int?priority, string parentTaskId, string assignee, string tenantId)
 {
     this.taskName     = taskName;
     this.description  = description;
     this.dueDate      = dueDate;
     this.parentTaskId = parentTaskId;
     this.priority     = priority;
     this.assignee     = assignee;
     this.tenantId     = tenantId;
     this.userService  = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();
 }
Exemple #11
0
 public ServiceAppService(
     IServiceRepository serviceRepository,
     IServiceImageRepository serviceImageRepository,
     IDbUnitOfWork unitOfWork,
     IImageServiceProxy imageServiceProxy,
     IOrganizationServiceProxy organizationServiceProxy,
     IAmapProxy amapProxy,
     TmpInstanceGenerate tmp,
     IUserServiceProxy userServiceProxy, IServicerRepository servicerRepository, IGoodsServiceProxy goodsServiceProxy)
 {
     _tmp = tmp;
     _serviceRepository        = serviceRepository;
     _serviceImageRepository   = serviceImageRepository;
     _dbUnitOfWork             = unitOfWork;
     _imageServiceProxy        = imageServiceProxy;
     _organizationServiceProxy = organizationServiceProxy;
     _amapProxy          = amapProxy;
     _userServiceProxy   = userServiceProxy;
     _servicerRepository = servicerRepository;
     _goodsServiceProxy  = goodsServiceProxy;
 }
        public void Notify(IDelegateTask task)
        {
            string assignee = task.Assignee;

            if (string.IsNullOrWhiteSpace(assignee))
            {
                return;
            }

            IUserInfo user;

            if (task.HasVariableLocal(assignee))
            {
                user = task.GetVariableLocal <IUserInfo>(assignee);
                if (user is object && string.Equals(user.Id, assignee, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
            }

            IUserServiceProxy userService = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            user = userService.GetUser(assignee)
                   .ConfigureAwait(false)
                   .GetAwaiter()
                   .GetResult();
            if (user == null)
            {
                logger.LogError($"找不到执行人{assignee}");
            }
            else
            {
                user.TenantId     = task.TenantId;
                task.AssigneeUser = user.FullName;
            }

            task.SetVariableLocal($"{assignee}", user);
        }
Exemple #13
0
 public GoodsAppService(
     IDbUnitOfWork dbUnitOfWork,
     IEventBus eventBus,
     IGoodsRepository goodsRepository,
     IOnlineGoodsRepository onlineGoodsRepository,
     IGoodsImageRepository goodsImageRepository,
     IGrouponConditionRepository grouponConditionRepository,
     IOnlineGoodsImageRepository onlineGoodsImageRepository,
     IOnlineGrouponConditionRepository onlineGrouponConditionRepository,
     IImageServiceProxy imageServiceProxy,
     IOrganizationServiceProxy organizationServiceProxy,
     IAmapProxy amapProxy,
     IActivityServiceProxy activityServiceProxy,
     IOrderServiceProxy orderServiceProxy,
     IAuthServiceProxy authServiceProxy,
     IUserServiceProxy userServiceProxy,
     IFancyServiceProxy fancyServiceProxy,
     TmpInstanceGenerate tmp)
 {
     _tmp                              = tmp;
     _dbUnitOfWork                     = dbUnitOfWork;
     _eventBus                         = eventBus;
     _goodsRepository                  = goodsRepository;
     _onlineGoodsRepository            = onlineGoodsRepository;
     _goodsImageRepository             = goodsImageRepository;
     _grouponConditionRepository       = grouponConditionRepository;
     _onlineGoodsImageRepository       = onlineGoodsImageRepository;
     _onlineGrouponConditionRepository = onlineGrouponConditionRepository;
     _imageServiceProxy                = imageServiceProxy;
     _organizationServiceProxy         = organizationServiceProxy;
     _amapProxy                        = amapProxy;
     _activityServiceProxy             = activityServiceProxy;
     _orderServiceProxy                = orderServiceProxy;
     _authServiceProxy                 = authServiceProxy;
     _userServiceProxy                 = userServiceProxy;
     _fancyServiceProxy                = fancyServiceProxy;
 }
        /// <inheritdoc />
        public override IList <IUserInfo> Execute(ICommandContext commandContext)
        {
            IList <IHistoricTaskInstance> hisTasks = commandContext.ProcessEngineConfiguration.HistoryService
                                                     .CreateHistoricTaskInstanceQuery()
                                                     .SetExecutionId(this.Execution.Id)
                                                     .List();

            IList <IUserInfo> users = hisTasks.Where(x => Condition.QueryCondition.Any(y => y.Id == x.TaskDefinitionKey))
                                      .Select(x => new UserInfo
            {
                Id = x.Assignee
            })
                                      .ToList <IUserInfo>();

            if (Condition.QueryCondition.Any(x => string.Equals("", x.Id)))
            {
                var hisInst = commandContext.ProcessEngineConfiguration.HistoryService
                              .CreateHistoricProcessInstanceQuery()
                              .SetProcessInstanceId(this.Execution.ProcessInstanceId)
                              .SingleResult();

                string uid = hisInst == null ? this.Execution.Parent.StartUserId : hisInst.StartUserId;
                users.Add(new UserInfo
                {
                    Id = uid
                });
            }

            IUserServiceProxy proxy = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

            return(proxy.GetUsers(externalConnector.GetUser, new RequestUserParameter
            {
                IdList = users.Select(x => x.Id).ToArray(),
                Category = RequestUserCategory.GETUSER_EXECUTOR
            }).ConfigureAwait(false).GetAwaiter().GetResult());
        }
Exemple #15
0
        // CREATE METHODS

        public virtual IExecutionEntity CreateProcessInstanceExecution(IProcessDefinition processDefinition, string businessKey, string tenantId, string initiatorVariableName)
        {
            IExecutionEntity processInstanceExecution = executionDataManager.Create();

            if (ExecutionRelatedEntityCountEnabledGlobally)
            {
                ((ICountingExecutionEntity)processInstanceExecution).IsCountEnabled = true;
            }

            processInstanceExecution.ProcessDefinitionId      = processDefinition.Id;
            processInstanceExecution.ProcessDefinitionKey     = processDefinition.Key;
            processInstanceExecution.ProcessDefinitionName    = processDefinition.Name;
            processInstanceExecution.ProcessDefinitionVersion = processDefinition.Version;
            processInstanceExecution.BusinessKey = businessKey;
            processInstanceExecution.IsScope     = true; // process instance is always a scope for all child executions

            // Inherit tenant id (if any)
            if (tenantId is object)
            {
                processInstanceExecution.TenantId = tenantId;
            }

            string authenticatedUserId = Authentication.AuthenticatedUser.Id;

            processInstanceExecution.StartTime   = Context.ProcessEngineConfiguration.Clock.CurrentTime;
            processInstanceExecution.StartUserId = authenticatedUserId;
            processInstanceExecution.StartUser   = Authentication.AuthenticatedUser.FullName;

            // Store in database
            Insert(processInstanceExecution, false);

            if (string.IsNullOrWhiteSpace(processInstanceExecution.StartUserId) == false)
            {
                IUserInfo                 starter           = null;
                IUserServiceProxy         userService       = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();
                ExternalConnectorProvider externalConnector = ProcessEngineServiceProvider.Resolve <ExternalConnectorProvider>();

                starter = new UserInfo
                {
                    Id       = processInstanceExecution.StartUserId,
                    FullName = processInstanceExecution.StartUserId
                };
                //TODO: 考虑性能问题,暂时不要获取人员信息
                //try
                //{
                //    starter = AsyncHelper.RunSync<IUserInfo>(() => userService.GetUser(processInstanceExecution.StartUserId));
                //    starter.TenantId = processInstanceExecution.TenantId;
                //}
                //catch (Exception ex)
                //{
                //    logger.LogError(ex, ex.Message);
                //    starter = new UserInfo
                //    {
                //        Id = processInstanceExecution.StartUserId,
                //        FullName = processInstanceExecution.StartUserId
                //    };
                //}

                //保存调用用户变量
                processInstanceExecution.SetVariable(processInstanceExecution.StartUserId, starter);
            }

            if (initiatorVariableName is object)
            {
                processInstanceExecution.SetVariable(initiatorVariableName, authenticatedUserId);
            }

            // Need to be after insert, cause we need the id
            processInstanceExecution.ProcessInstanceId     = processInstanceExecution.Id;
            processInstanceExecution.RootProcessInstanceId = processInstanceExecution.Id;
            //TODO: 当没有用户任务的时候,添加identity会报错
            if (authenticatedUserId is object)
            {
                IdentityLinkEntityManager.AddIdentityLink(processInstanceExecution, authenticatedUserId, null, IdentityLinkType.STARTER);
            }

            // Fire events
            if (EventDispatcher.Enabled)
            {
                EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_CREATED, processInstanceExecution));
            }

            return(processInstanceExecution);
        }
Exemple #16
0
 public ShowCommand(IMainRepositoryServiceProxy mainRepositoryServiceProxy, IUserServiceProxy userServiceProxy)
 {
     this.mainRepositoryServiceProxy = mainRepositoryServiceProxy;
     this.userServiceProxy = userServiceProxy;
 }
Exemple #17
0
 public VerificationCodeValidator(IUserServiceProxy userServiceProxy, IVerificationServiceProxy verificationServiceProxy)
 {
     _userServiceProxy         = userServiceProxy;
     _verificationServiceProxy = verificationServiceProxy;
 }
Exemple #18
0
 public PartnerAuthCodeValidator(IUserServiceProxy userServiceProxy)
 {
     _userServiceProxy = userServiceProxy;
 }
 public BillingController(IBillingRepository repository, IUserServiceProxy proxy)
 {
     _repository = repository;
     _proxy      = proxy;
 }
Exemple #20
0
 public WechatAppletValidator(IUserServiceProxy userServiceProxy)
 {
     _userServiceProxy = userServiceProxy;
 }
Exemple #21
0
 public ResourceOwnerPasswordValidator(IUserServiceProxy userServiceProxy)
 {
     _userServiceProxy = userServiceProxy;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="taskEntityManager"></param>
        /// <param name="assignee"></param>
        /// <param name="owner"></param>
        /// <param name="candidateUsers"></param>
        /// <param name="candidateGroups"></param>
        /// <param name="task"></param>
        /// <param name="expressionManager"></param>
        /// <param name="execution"></param>
        protected internal virtual void HandleAssignments(ITaskEntityManager taskEntityManager, string assignee, string owner, IList <string> candidateUsers, IList <string> candidateGroups, ITaskEntity task, ExpressionManager expressionManager, IExecutionEntity execution)
        {
            if (!string.IsNullOrWhiteSpace(assignee))
            {
                object assigneeExpressionValue = expressionManager.CreateExpression(assignee).GetValue(execution);
                string assigneeValue           = null;
                if (assigneeExpressionValue != null)
                {
                    assigneeValue = assigneeExpressionValue.ToString();
                }
                string assigneeUser = null;

                if (string.IsNullOrWhiteSpace(assigneeValue) == false)
                {
                    IUserServiceProxy userService = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();

                    var user = userService.GetUser(assigneeValue)
                               .ConfigureAwait(false)
                               .GetAwaiter()
                               .GetResult();

                    assigneeUser = user?.FullName;

                    task.SetVariableLocal(assigneeValue, user);
                }
                taskEntityManager.ChangeTaskAssigneeNoEvents(task, assigneeValue, assigneeUser);
            }

            if (!string.IsNullOrWhiteSpace(owner))
            {
                object ownerExpressionValue = expressionManager.CreateExpression(owner).GetValue(execution);
                string ownerValue           = null;
                if (ownerExpressionValue != null)
                {
                    ownerValue = ownerExpressionValue.ToString();
                }

                taskEntityManager.ChangeTaskOwner(task, ownerValue);
            }

            if (candidateGroups != null && candidateGroups.Count > 0)
            {
                foreach (string candidateGroup in candidateGroups)
                {
                    IExpression groupIdExpr = expressionManager.CreateExpression(candidateGroup);
                    object      value       = groupIdExpr.GetValue(execution);
                    if (value is string @string)
                    {
                        IList <string> candidates = ExtractCandidates(@string);
                        task.AddCandidateGroups(candidates);
                    }
                    else if (value is ICollection)
                    {
                        task.AddCandidateGroups((ICollection <string>)value);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Expression did not resolve to a string or collection of strings");
                    }
                }
            }

            if (candidateUsers != null && candidateUsers.Count > 0)
            {
                foreach (string candidateUser in candidateUsers)
                {
                    IExpression userIdExpr = expressionManager.CreateExpression(candidateUser);
                    object      value      = userIdExpr.GetValue(execution);
                    if (value is string @string)
                    {
                        IList <string> candidates = ExtractCandidates(@string);
                        task.AddCandidateUsers(candidates);
                    }
                    else if (value is ICollection)
                    {
                        task.AddCandidateUsers((ICollection <string>)value);
                    }
                    else
                    {
                        throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                    }
                }
            }

            if (userTask.CustomUserIdentityLinks != null && userTask.CustomUserIdentityLinks.Count > 0)
            {
                foreach (string customUserIdentityLinkType in userTask.CustomUserIdentityLinks.Keys)
                {
                    foreach (string userIdentityLink in userTask.CustomUserIdentityLinks[customUserIdentityLinkType])
                    {
                        IExpression idExpression = expressionManager.CreateExpression(userIdentityLink);
                        object      value        = idExpression.GetValue(execution);
                        if (value is string @string)
                        {
                            IList <string> userIds = ExtractCandidates(@string);
                            foreach (string userId in userIds)
                            {
                                task.AddUserIdentityLink(userId, customUserIdentityLinkType);
                            }
                        }
                        else if (value is ICollection collection)
                        {
                            IEnumerator userIdSet = collection.GetEnumerator();
                            while (userIdSet.MoveNext())
                            {
                                task.AddUserIdentityLink((string)userIdSet.Current, customUserIdentityLinkType);
                            }
                        }
                        else
                        {
                            throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                        }
                    }
                }
            }

            if (userTask.CustomGroupIdentityLinks != null && userTask.CustomGroupIdentityLinks.Count > 0)
            {
                foreach (string customGroupIdentityLinkType in userTask.CustomGroupIdentityLinks.Keys)
                {
                    foreach (string groupIdentityLink in userTask.CustomGroupIdentityLinks[customGroupIdentityLinkType])
                    {
                        IExpression idExpression = expressionManager.CreateExpression(groupIdentityLink);
                        object      value        = idExpression.GetValue(execution);
                        if (value is string @string)
                        {
                            IList <string> groupIds = ExtractCandidates(@string);
                            foreach (string groupId in groupIds)
                            {
                                task.AddGroupIdentityLink(groupId, customGroupIdentityLinkType);
                            }
                        }
                        else if (value is ICollection collection)
                        {
                            IEnumerator groupIdSet = collection.GetEnumerator();
                            while (groupIdSet.MoveNext())
                            {
                                task.AddGroupIdentityLink((string)groupIdSet.Current, customGroupIdentityLinkType);
                            }
                        }
                        else
                        {
                            throw new ActivitiException("Expression did not resolve to a string or collection of strings");
                        }
                    }
                }
            }
        }
Exemple #23
0
 public VerifyCodeValidator(IUserServiceProxy userServiceProxy)
 {
     _userServiceProxy = userServiceProxy;
 }
Exemple #24
0
 public UpdateTaskCmd(IUpdateTaskCmd cmd)
 {
     this.updateTaskCmd = cmd;
     userService        = ProcessEngineServiceProvider.Resolve <IUserServiceProxy>();
 }