Esempio n. 1
0
 public void FillClonedRows(SOARolePropertyRowCollection cloned)
 {
     foreach (SOARolePropertyRow row in this)
     {
         cloned.Add(new SOARolePropertyRow(row, row.RowNumber));
     }
 }
        private SOARolePropertyRowCollection MergeActivityRowPropertiesByOperators(IEnumerable <string> operators)
        {
            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection();

            int index      = 0;
            int activitySN = this.Values.GetValue(SOARolePropertyDefinition.ActivitySNColumn, 0);

            foreach (string op in operators)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(this, 0);

                if (this.GetPropertyDefinitions().MatrixType == WfMatrixType.ActivityMatrix)
                {
                    SOARolePropertyValue pv = newRow.Values.Find(v => string.Compare(v.Column.Name, SOARolePropertyDefinition.ActivitySNColumn, true) == 0);

                    if (pv == null)
                    {
                        pv = new SOARolePropertyValue(this.GetPropertyDefinitions()[SOARolePropertyDefinition.ActivitySNColumn]);
                        newRow.Values.Add(pv);
                    }

                    pv.Value = string.Format("{0}.{1:0000}", activitySN, ++index);
                }

                newRow.OperatorType = SOARoleOperatorType.User;
                newRow.Operator     = op;

                result.Add(newRow);
            }

            return(result);
        }
        /// <summary>
        /// 如果行的内容是角色,则将这些行扩展出来
        /// </summary>
        public SOARolePropertyRowCollection ExtractMatrixRows()
        {
            SOARolePropertyRowCollection extractedRows = new SOARolePropertyRowCollection();
            bool extracted = false;

            if (this.Operator.IsNotEmpty())
            {
                if (this.Operator.IndexOf(":") != -1)
                {
                    switch (this.OperatorType)
                    {
                    case SOARoleOperatorType.Role:
                        extracted = this.ExtractSOARoleRows(new SOARole(this.Operator), extractedRows);
                        break;

                    case SOARoleOperatorType.AURole:
                        WrappedAUSchemaRole wrappedRole = WrappedAUSchemaRole.FromCodeName(this.Operator);

                        if (wrappedRole != null)
                        {
                            wrappedRole.DoCurrentRoleAction(SOARoleContext.CurrentProcess,
                                                            (role, auCodeName) => extracted = this.ExtractSOARoleRows(role, extractedRows));
                        }
                        break;
                    }
                }
                else
                {
                    if (this.Values.GetValue(SOARolePropertyDefinition.AutoExtractColumn, false))
                    {
                        switch (this.OperatorType)
                        {
                        case SOARoleOperatorType.Role:
                            extracted = this.ExtractDynamicRoleMatrixRows(this.Operator, extractedRows);
                            break;

                        case SOARoleOperatorType.User:
                            extracted = this.ExtractUserMatrixRows(this.Operator, extractedRows);
                            break;
                        }
                    }
                }
            }

            //如果没有展开行,则将当前行添加到结果中
            if (extracted == false)
            {
                extractedRows.Add(this);
            }

            return(extractedRows);
        }
        private SOARolePropertyRowCollection MergeActivityRowPropertiesByRows(SOARolePropertyRowCollection subExtractedRows)
        {
            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection();

            foreach (SOARolePropertyRow subRow in subExtractedRows)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(this.Role);

                newRow.Values.CopyFrom(this.Values);
                newRow.OperatorType = subRow.OperatorType;
                newRow.Operator     = subRow.Operator;

                result.Add(newRow);
            }

            return(result);
        }
        private static OguDataCollection <IUser> CalculateRowOperators()
        {
            OguDataCollection <IUser> result = new OguDataCollection <IUser>();

            if (ObjectContextCache.Instance.ContainsKey("RoleMatrixCurrentRow"))
            {
                SOARolePropertyRow row = (SOARolePropertyRow)ObjectContextCache.Instance["RoleMatrixCurrentRow"];

                SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();
                rows.Add(row);

                SOARolePropertyRowUsersCollection rowsUsers = rows.GenerateRowsUsers();

                rowsUsers.ForEach(ru => result.CopyFrom(ru.Users));
            }

            return(result);
        }
Esempio n. 6
0
        public SOARolePropertyRowCollection Query(Predicate <SOARolePropertyRow> predicate)
        {
            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection(this._Role);

            foreach (SOARolePropertyRow row in this)
            {
                bool matched = true;

                matched = predicate(row);

                //if (matched)
                //    result.Add(row);
                if (matched)
                {
                    result.Add(new SOARolePropertyRow(row, row.RowNumber));
                }
            }

            return(result);
        }
        /// <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);
        }