Exemplo n.º 1
0
        public SOARolePropertyDefinitionCollection LoadByRoleID(string roleID)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");

            string sql = string.Format("SELECT * FROM WF.ROLE_PROPERTIES_DEFINITIONS WHERE {0} ORDER BY SORT_ORDER",
                                       roleID.ToRoleIDCriteria());

            using (TransactionScope scope = TransactionScopeFactory.Create(TransactionScopeOption.Suppress))
            {
                DataTable table = DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0];

                SOARolePropertyDefinitionCollection result = new SOARolePropertyDefinitionCollection();

                foreach (DataRow row in table.Rows)
                {
                    SOARolePropertyDefinition property = new SOARolePropertyDefinition();

                    ORMapping.DataRowToObject(row, property);

                    result.Add(property);
                }

                return(result);
            }
        }
Exemplo n.º 2
0
        public void Update(IRole role, SOARolePropertyDefinitionCollection properties)
        {
            role.NullCheck("role");
            properties.NullCheck("properties");

            this.Update(role.ID, properties);
        }
Exemplo n.º 3
0
        public static SOARoleContext CreateContext(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process)
        {
            propertyDefines.NullCheck("propertyDefines");

            SOARolePropertiesQueryParamCollection queryParams = CreateQueryParams(propertyDefines, process);

            SOARoleContext context = SOARoleContext.CreateContext(queryParams, process);

            context.PropertyDefinitions = propertyDefines;

            return(context);
        }
Exemplo n.º 4
0
        //沈峥注释掉,2015/6/21.必须提供列定义
        //public void FillCreateActivityParams(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        //{
        //    SOARolePropertyDefinitionCollection definitions = null;

        //    SOARole role = this._Role as SOARole;

        //    if (role != null)
        //        definitions = role.PropertyDefinitions;
        //    else
        //        definitions = new SOARolePropertyDefinitionCollection();

        //    this.FillCreateActivityParams(capc, definitions, definedProperties);
        //}

        public void FillCreateActivityParams(WfCreateActivityParamCollection capc, SOARolePropertyDefinitionCollection definitions, PropertyDefineCollection definedProperties)
        {
            capc.NullCheck("capc");
            definitions.NullCheck("definitions");

            SOARolePropertyRowUsersCollection rowsUsers = GenerateRowsUsers();

            rowsUsers.ForEach(rowUsers => capc.Add(WfCreateActivityParam.FromRowUsers(rowUsers, definitions, definedProperties)));

            if (definitions.MatrixType == WfMatrixType.ActivityMatrix)
            {
                capc.MergeSameActivityParamBySN();
            }

            capc.ForEach(cap => InitTransitionTemplatesProperties(cap, definitions, cap.Source));
        }
Exemplo n.º 5
0
        public SOARolePropertyDefinitionCollection GetByRoleID(string roleID)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");

            SOARolePropertyDefinitionCollection result = SOARolePropertiesDefinitionCache.Instance.GetOrAddNewValue(roleID.ToRoleIDCacheKey(), (cache, key) =>
            {
                SOARolePropertyDefinitionCollection properties = LoadByRoleID(roleID);

                MixedDependency dependency = new MixedDependency(new UdpNotifierCacheDependency(), new MemoryMappedFileNotifierCacheDependency());

                cache.Add(key, properties, dependency);

                return(properties);
            });

            return(result);
        }
        /// <summary>
        /// 根据roleID加载角色矩阵。role参数可以为空
        /// </summary>
        /// <param name="roleID"></param>
        /// <param name="role"></param>
        /// <returns></returns>
        public SOARolePropertyRowCollection LoadByRoleID(string roleID, IRole role)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");

            if (role == null)
            {
                role = new SOARole()
                {
                    ID = roleID
                }
            }
            ;

            SOARolePropertyDefinitionCollection definition = SOARolePropertyDefinitionAdapter.Instance.GetByRoleID(roleID);

            return(LoadByRoleID(roleID, role, definition));
        }
Exemplo n.º 7
0
        private static bool IsQueryableColumn(SOARolePropertyDefinition pd, SOARolePropertyDefinitionCollection propertyDefines)
        {
            bool isReservered = true;

            switch (propertyDefines.MatrixType)
            {
            case WfMatrixType.RoleMatrix:
                isReservered = SOARolePropertyDefinition.IsRoleMatrixReservedPropertyName(pd.Name);
                break;

            case WfMatrixType.ActivityMatrix:
                isReservered = SOARolePropertyDefinition.IsActivityMatrixReservedPropertyName(pd.Name);
                break;
            }

            return(isReservered == false);
        }
        public SOARolePropertyRowCollection GetByRole(IRole role, SOARolePropertyDefinitionCollection definition)
        {
            role.NullCheck("role");

            SOARolePropertyRowCollection result = SOARolePropertiesCache.Instance.GetOrAddNewValue(role.ID.ToRoleIDCacheKey(), (cache, key) =>
            {
                SOARolePropertyRowCollection properties = LoadByRole(role, definition);

                MixedDependency dependency = new MixedDependency(new UdpNotifierCacheDependency(), new MemoryMappedFileNotifierCacheDependency());

                cache.Add(key, properties, dependency);

                return(properties);
            });

            return(result);
        }
Exemplo n.º 9
0
        internal SOARolePropertyDefinitionCollection GetPropertyDefinitions()
        {
            SOARolePropertyDefinitionCollection result = SOARolePropertyDefinition.EmptyInstance;

            if (SOARoleContext.Current != null)
            {
                result = SOARoleContext.Current.PropertyDefinitions;
            }
            else
            {
                if (this.Role != null)
                {
                    result = ((SOARole)this.Role).PropertyDefinitions;
                }
            }

            return(result);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 创建一个新的上下文,并且使用它进行计算。计算完成后恢复上下文。
        /// </summary>
        /// <param name="propertyDefines"></param>
        /// <param name="process"></param>
        /// <param name="action"></param>
        public static void DoNewContextAction(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process, Action <SOARoleContext> action)
        {
            if (action != null)
            {
                SOARoleContext originalRoleContext = SOARoleContext.Current;

                try
                {
                    SOARoleContext.Current = null;
                    SOARoleContext.CreateContext(propertyDefines, process);

                    action(SOARoleContext.Current);
                }
                finally
                {
                    SOARoleContext.Current = originalRoleContext;
                }
            }
        }
        /// <summary>
        /// 根据RoleID加载行信息
        /// </summary>
        /// <param name="roleID"></param>
        /// <param name="role"></param>
        /// <param name="definition">列定义</param>
        /// <returns></returns>
        public SOARolePropertyRowCollection LoadByRoleID(string roleID, IRole role, SOARolePropertyDefinitionCollection definition)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            definition.NullCheck("definition");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_ROWS WHERE {0} ORDER BY ROW_NUMBER", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_CELLS WHERE {0} ORDER BY PROPERTIES_ROW_ID", roleID.ToRoleIDCriteria());

            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection(role);

            using (TransactionScope scope = TransactionScopeFactory.Create(TransactionScopeOption.Suppress))
            {
                DataSet ds = DbHelper.RunSqlReturnDS(strB.ToString(), GetConnectionName());
                Dictionary <int, SOARolePropertyValueCollection> propertyValues = SOARolePropertyValueCollection.LoadAndGroup(ds.Tables[1].DefaultView, definition);

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    SOARolePropertyRow property = new SOARolePropertyRow(role);

                    ORMapping.DataRowToObject(row, property);

                    SOARolePropertyValueCollection values = null;

                    if (propertyValues.TryGetValue(property.RowNumber, out values))
                    {
                        property.Values.CopyFrom(values);
                    }

                    result.Add(property);
                }
            }

            return(result);
        }
Exemplo n.º 13
0
        public void Update(string roleID, SOARolePropertyDefinitionCollection properties)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            properties.NullCheck("properties");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("DELETE WF.ROLE_PROPERTIES_DEFINITIONS WHERE {0}", roleID.ToRoleIDCriteria());

            foreach (SOARolePropertyDefinition property in properties)
            {
                if (strB.Length > 0)
                {
                    strB.Append(TSqlBuilder.Instance.DBStatementSeperator);
                }

                property.RoleID = roleID;

                strB.AppendFormat(ORMapping.GetInsertSql(property, TSqlBuilder.Instance));
            }

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DbHelper.RunSql(strB.ToString(), GetConnectionName());

                scope.Complete();
            }

            string cacheKey = roleID.ToRoleIDCacheKey();

            CacheNotifyData notifyData1 = new CacheNotifyData(typeof(SOARolePropertiesDefinitionCache), cacheKey, CacheNotifyType.Invalid);
            CacheNotifyData notifyData2 = new CacheNotifyData(typeof(SOARolePropertiesCache), cacheKey, CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData1, notifyData2);
            MmfCacheNotifier.Instance.SendNotify(notifyData1, notifyData2);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 初始化出线的属性
        /// </summary>
        /// <param name="cap"></param>
        /// <param name="row"></param>
        private static void InitTransitionTemplatesProperties(WfCreateActivityParam cap, SOARolePropertyDefinitionCollection definitions, SOARolePropertyRow row)
        {
            string json = row.Values.GetValue(SOARolePropertyDefinition.TransitionsColumn,
                                              row.GetPropertyDefinitions().GetColumnDefaultValue(SOARolePropertyDefinition.TransitionsColumn, string.Empty));

            if (json.IsNotEmpty())
            {
                cap.TransitionTemplates.FromJson(json);
            }
        }
        public SOARolePropertyRowCollection LoadByRole(IRole role, SOARolePropertyDefinitionCollection definition)
        {
            role.NullCheck("role");

            return(LoadByRoleID(role.ID, role, definition));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 将所有行的单元格信息按照列定义,形成每一行的Values的内容
        /// </summary>
        /// <param name="view">ROLE_PROPERTIES_CELLS表的每一行信息,每一行表示一个单元格的值</param>
        /// <param name="definition">列定义信息</param>
        /// <returns></returns>
        internal static Dictionary <int, SOARolePropertyValueCollection> LoadAndGroup(DataView view, SOARolePropertyDefinitionCollection definition)
        {
            Dictionary <int, SOARolePropertyValueCollection> result = new Dictionary <int, SOARolePropertyValueCollection>();

            foreach (DataRowView drv in view)
            {
                SOARolePropertyDefinition rpd = definition[drv["PROPERTY_NAME"].ToString()];

                //如果找到了列定义...
                if (rpd != null)
                {
                    SOARolePropertyValue pv = new SOARolePropertyValue(rpd);

                    pv.Value = drv["STRING_VALUE"].ToString();

                    object objRowNumber = drv["PROPERTIES_ROW_ID"];
                    int    rowNumber    = 0;

                    if (objRowNumber is int)
                    {
                        rowNumber = (int)objRowNumber;
                    }

                    SOARolePropertyValueCollection values = null;

                    if (result.TryGetValue(rowNumber, out values) == false)
                    {
                        values = new SOARolePropertyValueCollection();
                        result.Add(rowNumber, values);
                    }

                    values.Add(pv);
                }
            }

            foreach (KeyValuePair <int, SOARolePropertyValueCollection> kp in result)
            {
                kp.Value.Sort((v1, v2) => v1.Column.SortOrder - v2.Column.SortOrder);
            }

            return(result);
        }
Exemplo n.º 17
0
 /// <summary>
 /// 通过预先定义好的列定义来构造
 /// </summary>
 /// <param name="definitions"></param>
 public SOARole(SOARolePropertyDefinitionCollection definitions)
 {
     this._PropertyDefinitions = definitions;
 }