예제 #1
0
        /// <summary>
        /// 从上下文和流程中得到值
        /// </summary>
        /// <param name="pd"></param>
        /// <param name="process"></param>
        /// <returns></returns>
        private static object GetQueryValueFromContext(SOARolePropertyDefinition pd, IWfProcess process)
        {
            WfApplicationParametersContext apContext = WfApplicationParametersContext.Current;

            object arpValue = null;

            if (apContext != null)
            {
                arpValue = apContext.ApplicationRuntimeParameters.GetValue(pd.Name, (string)null);
            }

            if (arpValue == null && process != null)
            {
                arpValue = process.ApplicationRuntimeParameters.GetValueRecursively(pd.Name, (string)null);
            }

            return(arpValue);
        }
예제 #2
0
        private static SOARolePropertiesQueryParamCollection CreateQueryParams(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process)
        {
            SOARolePropertiesQueryParamCollection queryParams = new SOARolePropertiesQueryParamCollection();

            WfApplicationParametersContext apContext = WfApplicationParametersContext.Current;

            //如果是审批矩阵,只取第一列作为条件
            if (propertyDefines.MatrixType == WfMatrixType.ApprovalMatrix)
            {
                if (propertyDefines.Count > 0)
                {
                    SOARolePropertyDefinition pd = propertyDefines[0];

                    object arpValue = GetQueryValueFromContext(pd, process);

                    queryParams.Add(new SOARolePropertiesQueryParam()
                    {
                        QueryName  = pd.Name,
                        QueryValue = arpValue
                    });
                }
            }
            else
            {
                //活动矩阵和角色矩阵,排除保留字
                foreach (SOARolePropertyDefinition pd in propertyDefines)
                {
                    //是否是可查询的列
                    if (IsQueryableColumn(pd, propertyDefines))
                    {
                        object arpValue = GetQueryValueFromContext(pd, process);

                        queryParams.Add(new SOARolePropertiesQueryParam()
                        {
                            QueryName  = pd.Name,
                            QueryValue = arpValue
                        });
                    }
                }
            }

            return(queryParams);
        }
예제 #3
0
        public void QueryRoleUserByContext()
        {
            SOARole role = PrepareSOARole();

            WfRoleResourceDescriptor       roleDescriptor = new WfRoleResourceDescriptor(role);
            WfResourceDescriptorCollection roles          = new WfResourceDescriptorCollection();

            roles.Add(roleDescriptor);

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["CostCenter"] = "1002";
            parameters["FormType"]   = "Form1";

            WfApplicationParametersContext.CreateContext(parameters);

            OguDataCollection <IUser> users = roles.ToUsers();

            Assert.AreEqual(4, users.Count);
        }