/// <summary>
        /// 侦听接收通知处理
        /// </summary>
        /// <param name="execution"></param>
        public void Notify(IExecutionEntity execution)
        {
            if (execution.CurrentFlowElement is UserTask userTask && userTask.HasMultiInstanceLoopCharacteristics())
            {
                var varName = userTask.LoopCharacteristics.GetCollectionVarName();

                if (execution.GetVariable(varName) == null)
                {
                    List <IUserInfo> users         = new List <IUserInfo>();
                    string           getUserPolicy = userTask.GetUsersPolicy();
                    if (string.IsNullOrWhiteSpace(getUserPolicy) == false)
                    {
                        if (EXPR_PATTERN.IsMatch(getUserPolicy))
                        {
                            getUserPolicy = EXPR_PATTERN.Replace(getUserPolicy, (m) =>
                            {
                                var value     = m.Groups[1].Value;
                                var variables = execution.Variables;
                                object roles  = ExpressionManager.GetValue(variables, value, variables);
                                return(roles.ToString());
                            });
                        }

                        QueryBookmark[] actors = JsonConvert.DeserializeObject <QueryBookmark[]>(getUserPolicy);

                        IGetBookmarkRuleProvider ruleProvider = ProcessEngineServiceProvider.Resolve <IGetBookmarkRuleProvider>();

                        foreach (QueryBookmark query in actors)
                        {
                            IGetBookmarkRule rule = ruleProvider.CreateBookmarkRule(query.RuleType.ToString());
                            rule.Execution = execution;
                            rule.Condition = query;
                            var us = Context.ProcessEngineConfiguration.CommandExecutor.Execute(rule);
                            users.AddRange(us);
                        }
                    }

                    if (users.Count == 0)
                    {
                        users.Add(Authentication.AuthenticatedUser);
                        logger.LogWarning($"调用查询人员服务失败,分组没有人,重新指到当前提交人,Duty={getUserPolicy}");
                        //throw new NoneCountersignUsersException(execution.CurrentFlowElement.Name);
                    }

                    execution.SetVariable(varName, users.Count == 0 ? new string[] { "" } : users.Select(x => x.Id).Distinct().ToArray());
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 进行表达式运算
        /// </summary>
        /// <param name="contextObject"></param>
        /// <param name="expstr"></param>
        /// <param name="variables"></param>
        /// <returns></returns>
        private object GetValue(ExpandoObject contextObject, string expstr, IDictionary <string, object> variables)
        {
            if (string.IsNullOrWhiteSpace(expstr))
            {
                return(null);
            }

            //存在动态参数,进行替换
            if (EXPR_PATTERN.IsMatch(expstr))
            {
                string vexpre = GetExpression(expstr);
                return(ExpressionManager.GetValue(contextObject, vexpre, variables));
            }

            return(expstr);
        }
Esempio n. 3
0
            public override bool IsCondition(RequestContext context)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(Test))
                    {
                        var obj = ExpressionManager.GetValue(context.Request, Test, context.RequestParameters);

                        if (bool.TryParse(obj?.ToString(), out var ret) == false)
                        {
                            return(false);
                        }

                        return(ret);
                    }
                    else
                    {
                        var reqVal = GetPropertyValue(context);
                        if (reqVal == null)
                        {
                            return(false);
                        }
                        string reqValStr = string.Empty;
                        if (reqVal is Enum)
                        {
                            reqValStr = reqVal.GetHashCode().ToString();
                        }
                        else if (reqVal is bool)
                        {
                            bool.TryParse(reqVal.ToString(), out bool ret);
                            return(ret);
                        }
                        else
                        {
                            reqValStr = reqVal.ToString();
                        }
                        return(reqValStr.Equals(CompareValue));
                    }
                }
                catch (Exception e)
                {
                    throw new BuildSqlException($"构造SQL语句发生错误({LineInfo.LineNumber},{LineInfo.LinePosition}):{e.Message}", e);
                }
            }
Esempio n. 4
0
        protected virtual object GetPropertyValue(RequestContext context)
        {
            var reqParams = context.RequestParameters;

            if (reqParams == null)
            {
                return(null);
            }

            if (Property == null)
            {
                throw new PropertyArgumentNullException($"Tag property null {ToString()}");
            }

            if (!string.IsNullOrWhiteSpace(Property) && context.Request != null)
            {
                return(ExpressionManager.GetValue(context.Request, Property, context.RequestParameters));
            }

            reqParams.TryGetValue(Property, out object propVal);

            return(propVal);
        }