예제 #1
0
        private static SOARolePropertyRow AddSOARoleRow(SOARole role, SOARoleOperatorType operatorType, string opUser, string constCenter, string activitySN, Action <SOARolePropertyRow, SOARolePropertyDefinitionCollection> action = null)
        {
            SOARolePropertyRow row = new SOARolePropertyRow(role)
            {
                RowNumber = role.Rows.Count + 1, OperatorType = operatorType, Operator = opUser
            };

            SOARolePropertyDefinitionCollection pds = role.PropertyDefinitions;

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = constCenter
            });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivitySNColumn])
            {
                Value = activitySN
            });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorTypeColumn])
            {
                Value = operatorType.ToString()
            });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorColumn])
            {
                Value = opUser
            });

            if (action != null)
            {
                action(row, pds);
            }

            role.Rows.Add(row);

            return(row);
        }
        /// <summary>
        /// 从DataRow构造行信息
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="definitions"></param>
        /// <param name="func"></param>
        public void FromDataTable(DataRowCollection rows, IEnumerable <SOARolePropertyDefinition> definitions, Func <DataRow, SOARolePropertyRow, bool> func = null)
        {
            rows.NullCheck("rows");
            definitions.NullCheck("definitions");

            this.Clear();

            int rowIndex = 1;

            foreach (DataRow row in rows)
            {
                SOARolePropertyRow mRow = new SOARolePropertyRow()
                {
                    RowNumber = rowIndex++
                };

                foreach (SOARolePropertyDefinition definition in definitions)
                {
                    if (row.Table.Columns.Contains(definition.Name))
                    {
                        SOARolePropertyValue mCell = new SOARolePropertyValue(definition);
                        mCell.Value = row[definition.Name].ToString();

                        switch (definition.Name)
                        {
                        case SOARolePropertyDefinition.OperatorColumn:
                            mRow.Operator = row[definition.Name].ToString();
                            break;

                        case SOARolePropertyDefinition.OperatorTypeColumn:
                            SOARoleOperatorType opType = SOARoleOperatorType.User;
                            Enum.TryParse(row[definition.Name].ToString(), out opType);
                            mRow.OperatorType = opType;
                            break;

                        default:
                            break;
                        }

                        mRow.Values.Add(mCell);
                    }
                }

                bool canAdd = true;

                if (func != null)
                {
                    canAdd = func(row, mRow);
                }

                if (canAdd)
                {
                    this.Add(mRow);
                }
            }
        }
예제 #3
0
        private void Save(Stream strem)
        {
            DataTable dt = DocumentHelper.GetRangeValuesAsTable(strem, "Matrix", "A3");

            string[] itemsInfo = this.MCRolePropertyEditTemplate.RequestContext.Split(';');

            string roleID = itemsInfo[1];
            string defID  = itemsInfo[2];

            SOARole role = PrepareRole(roleID, defID);

            role.Rows.Clear();
            int rowIndex = 0;

            foreach (DataRow row in dt.Rows)
            {
                SOARolePropertyRow mRow = new SOARolePropertyRow(role)
                {
                    RowNumber = rowIndex
                };

                foreach (var dimension in role.PropertyDefinitions)
                {
                    SOARolePropertyValue mCell = new SOARolePropertyValue(dimension);
                    mCell.Value = row[dimension.Name].ToString();

                    switch (dimension.Name)
                    {
                    case "Operator":
                        mRow.Operator = row[dimension.Name].ToString();
                        break;

                    case "OperatorType":
                        SOARoleOperatorType opType = SOARoleOperatorType.User;
                        Enum.TryParse(row[dimension.Name].ToString(), out opType);
                        mRow.OperatorType = opType;
                        break;

                    default:
                        break;
                    }

                    mRow.Values.Add(mCell);
                }

                rowIndex++;
                role.Rows.Add(mRow);
            }

            //更新数据库
            SOARolePropertiesAdapter.Instance.Update(role);
        }
예제 #4
0
        public int ReplaceOperators(SOARoleOperatorType typeFilter, string originalOperator, params string[] replaceOperators)
        {
            int result = 0;

            foreach (SOARolePropertyRow row in this)
            {
                if (row.OperatorType == typeFilter)
                {
                    result += row.ReplaceOperator(originalOperator, replaceOperators);
                }
            }

            return(result);
        }
        private SOARolePropertyRow GenerateMatrixRow(SOARole role, RowNode rowNode, NamedLocationCollection locations, int index)
        {
            SOARolePropertyRow mRow = new SOARolePropertyRow(role);

            mRow.RowNumber = index;

            int emptyCellCount = 0;

            foreach (var row in this.Definition)
            {
                CellLocation location = locations[row.Name];

                CellNode cell = rowNode.GetCellByIndex(location.Column);

                SOARolePropertyValue mCell = new SOARolePropertyValue(row);

                mCell.Value = cell.Data.InnerText.Trim();

                mRow.Values.Add(mCell);

                switch (row.Name)
                {
                case "Operator":
                    mRow.Operator = cell.Data.InnerText;
                    break;

                case "OperatorType":
                    SOARoleOperatorType opType = SOARoleOperatorType.User;
                    Enum.TryParse(cell.Data.InnerText, out opType);
                    mRow.OperatorType = opType;
                    break;

                default:
                    if (mCell.Value.IsNullOrEmpty())
                    {
                        emptyCellCount++;
                    }
                    break;
                }
            }

            role.Rows.Add(mRow);

            return(mRow);
        }
예제 #6
0
        /// <summary>
        /// 从DataRow构造行信息
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="definitions"></param>
        internal void FromDataTable(DataRowCollection rows, IEnumerable <SOARolePropertyDefinition> definitions)
        {
            rows.NullCheck("rows");
            definitions.NullCheck("definitions");

            this.Clear();

            int rowIndex = 1;

            foreach (DataRow row in rows)
            {
                SOARolePropertyRow mRow = new SOARolePropertyRow()
                {
                    RowNumber = rowIndex++
                };

                foreach (SOARolePropertyDefinition definition in definitions)
                {
                    SOARolePropertyValue mCell = new SOARolePropertyValue(definition);
                    mCell.Value = row[definition.Name].ToString();

                    switch (definition.Name)
                    {
                    case SOARolePropertyDefinition.OperatorColumn:
                        mRow.Operator = row[definition.Name].ToString();
                        break;

                    case SOARolePropertyDefinition.OperatorTypeColumn:
                        SOARoleOperatorType opType = SOARoleOperatorType.User;
                        Enum.TryParse(row[definition.Name].ToString(), out opType);
                        mRow.OperatorType = opType;
                        break;

                    default:
                        break;
                    }

                    mRow.Values.Add(mCell);
                }

                this.Add(mRow);
            }
        }
예제 #7
0
        /// <summary>
        /// 将角色类型的操作人填充到用户集合中
        /// </summary>
        /// <param name="users"></param>
        /// <param name="operatorType"></param>
        /// <param name="operatorDesp"></param>
        private static void FillRoleTypeOperatorToUsers(SOARoleOperatorType operatorType, string operatorDesp, OguDataCollection <IUser> users)
        {
            switch (operatorType)
            {
            case SOARoleOperatorType.Role:
                if (operatorDesp.IndexOf(":") < 0)
                {
                    SOARolePropertyRow.FillInternalDynamicRoleUsers(operatorDesp, users);
                }
                else
                {
                    FillRoleUsers(operatorDesp, users);
                }
                break;

            case SOARoleOperatorType.AURole:
                FillAURoleUsers(operatorDesp, users);
                break;
            }
        }
예제 #8
0
        private static SOARolePropertyRow AddSOARoleRow(SOARole role, SOARoleOperatorType operatorType, string opUser, string constCenter, string activitySN)
        {
            SOARolePropertyRow row = new SOARolePropertyRow(role)
            {
                RowNumber = role.Rows.Count + 1, OperatorType = operatorType, Operator = opUser
            };

            SOARolePropertyDefinitionCollection pds = role.PropertyDefinitions;

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = constCenter
            });
            row.Values.Add(new SOARolePropertyValue(pds["ActivitySN"])
            {
                Value = activitySN
            });
            role.Rows.Add(row);

            return(row);
        }
        private static SOARolePropertyRow AddSOARoleRow(SOARole role, SOARoleOperatorType operatorType, string opUser, string constCenter, string activitySN, Action<SOARolePropertyRow, SOARolePropertyDefinitionCollection> action = null)
        {
            SOARolePropertyRow row = new SOARolePropertyRow(role) { RowNumber = role.Rows.Count + 1, OperatorType = operatorType, Operator = opUser };

            SOARolePropertyDefinitionCollection pds = role.PropertyDefinitions;

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = constCenter });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivitySNColumn]) { Value = activitySN });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorTypeColumn]) { Value = operatorType.ToString() });
            row.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorColumn]) { Value = opUser });

            if (action != null)
                action(row, pds);

            role.Rows.Add(row);

            return row;
        }
예제 #10
0
        /// <summary>
        /// 导入Open Xml格式的文件
        /// </summary>
        /// <param name="importStream"></param>
        /// <param name="notifier"></param>
        private void ImportFromExcel2007(Stream importStream, Action notifier)
        {
            WorkBook workbook = WorkBook.Load(importStream);

            SOARole role = null;

            ServiceBrokerContext.Current.SaveContextStates();

            try
            {
                ServiceBrokerContext.Current.UseLocalCache  = false;
                ServiceBrokerContext.Current.UseServerCache = false;

                if (this.AppCodeName.IsNotEmpty() && this.RoleCodeName.IsNotEmpty())
                {
                    role = new SOARole(this.AppCodeName + ":" + this.RoleCodeName);
                }
                else
                {
                    role = new SOARole(this.Definition)
                    {
                        ID = RoleID
                    }
                };

                if (NeedValidateSource)
                {
                    CheckImportSource(role, workbook);
                }

                DataTable dt = DocumentHelper.GetRangeValuesAsTable(workbook, "Matrix", "A3");

                role.Rows.Clear();

                int rowIndex = 0;
                foreach (DataRow row in dt.Rows)
                {
                    SOARolePropertyRow mRow = new SOARolePropertyRow(role)
                    {
                        RowNumber = rowIndex
                    };

                    foreach (var dimension in this.Definition)
                    {
                        SOARolePropertyValue mCell = new SOARolePropertyValue(dimension);
                        mCell.Value = row[dimension.Name].ToString();

                        switch (dimension.Name)
                        {
                        case "Operator":
                            mRow.Operator = row[dimension.Name].ToString();
                            break;

                        case "OperatorType":
                            SOARoleOperatorType opType = SOARoleOperatorType.User;
                            Enum.TryParse(row[dimension.Name].ToString(), out opType);
                            mRow.OperatorType = opType;
                            break;

                        default:
                            break;
                        }
                        mRow.Values.Add(mCell);
                    }

                    if (notifier != null)
                    {
                        notifier();
                    }

                    rowIndex++;
                    role.Rows.Add(mRow);
                }

                //插入记录
                SOARolePropertiesAdapter.Instance.Update(role);
            }
            finally
            {
                ServiceBrokerContext.Current.RestoreSavedStates();
            }
        }
예제 #11
0
 public static WfClientRoleOperatorType ToClientRoleOperatorType(this SOARoleOperatorType opType)
 {
     return((WfClientRoleOperatorType)opType);
 }
예제 #12
0
        private static void AddOneActivityMatrixRow(SOARole role, string auCodeName, int rowNumber, int activitySN, SOARoleOperatorType operatorType, string op)
        {
            SOARolePropertyDefinitionCollection definition = role.PropertyDefinitions;

            SOARolePropertyRow row = new SOARolePropertyRow(role)
            {
                RowNumber = rowNumber, OperatorType = operatorType, Operator = op
            };

            row.Values.Add(new SOARolePropertyValue(definition["AdministrativeUnit"])
            {
                Value = auCodeName
            });
            row.Values.Add(new SOARolePropertyValue(definition["ActivitySN"])
            {
                Value = activitySN.ToString()
            });

            role.Rows.Add(row);
        }
예제 #13
0
        private static SOARolePropertyRow AddSOARoleRow(SOARole role, SOARoleOperatorType operatorType, string opUser, string constCenter, string activitySN)
        {
            SOARolePropertyRow row = new SOARolePropertyRow(role) { RowNumber = role.Rows.Count + 1, OperatorType = operatorType, Operator = opUser };

            SOARolePropertyDefinitionCollection pds = role.PropertyDefinitions;

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = constCenter });
            row.Values.Add(new SOARolePropertyValue(pds["ActivitySN"]) { Value = activitySN });
            role.Rows.Add(row);

            return row;
        }