private static SOARolePropertyRowCollection PrepareSampleRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy" };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["ActivitySN"]) { Value = "10" });
            row1.Values.Add(new SOARolePropertyValue(pds["ActivityProperties"]) { Value = "{Name:\"部门领导\"}" });

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "liming" };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row2.Values.Add(new SOARolePropertyValue(pds["ActivitySN"]) { Value = "20" });
            row2.Values.Add(new SOARolePropertyValue(pds["ActivityProperties"]) { Value = "{Name:\"公司领导\"}" });

            SOARolePropertyRow row3 = new SOARolePropertyRow() { RowNumber = 3, OperatorType = SOARoleOperatorType.User, Operator = "quym" };

            row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row3.Values.Add(new SOARolePropertyValue(pds["ActivitySN"]) { Value = "10" });
            row3.Values.Add(new SOARolePropertyValue(pds["ActivityProperties"]) { Value = "{Name:\"部门领导\"}" });

            SOARolePropertyRow row4 = new SOARolePropertyRow() { RowNumber = 4, OperatorType = SOARoleOperatorType.User, Operator = "liming" };

            row4.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row4.Values.Add(new SOARolePropertyValue(pds["ActivitySN"]) { Value = "20" });
            row4.Values.Add(new SOARolePropertyValue(pds["ActivityProperties"]) { Value = "{Name:\"公司领导\"}" });

            rows.Add(row1);
            rows.Add(row2);
            rows.Add(row3);
            rows.Add(row4);

            return rows;
        }
        /// <summary>
        /// 创建一个与活动矩阵不匹配列的审批矩阵
        /// </summary>
        /// <returns></returns>
        public static WfApprovalMatrix PrepareExtrApprovalMatrix()
        {
            WfApprovalMatrix matrix = new WfApprovalMatrix() { ID = UuidHelper.NewUuidString() };

            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition() { Name = "CostCenter", SortOrder = 0 });
            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition() { Name = "ExtraApprover", SortOrder = 1 });

            SOARolePropertyDefinitionCollection pds = matrix.PropertyDefinitions;

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = string.Empty };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"]) { Value = "wangli5" });

            matrix.Rows.Add(row1);

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = string.Empty };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row2.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"]) { Value = "InvalidUser" });

            matrix.Rows.Add(row2);

            return matrix;
        }
Exemplo n.º 3
0
        private static object GetDataValueByBookmark(DefinedName bookmark, SOARolePropertyRow row)
        {
            object result = null;

            SOARolePropertyValue propertyValue = row.Values.FindByColumnName(bookmark.Name);

            if (propertyValue != null)
            {
                if (propertyValue.Column.DataType != ColumnDataType.String)
                {
                    result = DataConverter.ChangeType(typeof(string), propertyValue.Value, propertyValue.Column.RealDataType);
                }
                else
                {
                    result = propertyValue.Value;
                }
            }
            else
            {
                switch (bookmark.Name.ToLower())
                {
                case "operatortype":
                    result = row.OperatorType.ToString();
                    break;

                case "operator":
                    result = row.Operator;
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        private void InternalEnumMatrixRows(SCRoleEnumMatrixUsersContext context, IEnumerator <SOARolePropertyRow> enumerator)
        {
            if (enumerator.MoveNext())
            {
                SOARolePropertyRow row = enumerator.Current;

                switch (row.OperatorType)
                {
                case SOARoleOperatorType.User:
                    if (context.UsersCodeNames.ContainsKey(row.Operator) == false)
                    {
                        context.UsersCodeNames.Add(row.Operator, row.Operator);
                    }
                    break;

                case SOARoleOperatorType.Role:
                    if (row.Operator.IndexOf(":") >= 0)
                    {
                        EnumInternalRoleMatrixUsers(context, row.Operator);
                    }
                    break;
                }

                InternalEnumMatrixRows(context, enumerator);
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并,以第一个矩阵的列定义为准
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeActivityMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable<SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxRowNumber = GetMaxRowNumber(amRows);

            foreach (SOARolePropertyRow apRow in apRows)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(amRows.Role);

                newRow.RowNumber = ++maxRowNumber;
                newRow.OperatorType = apRow.OperatorType;
                newRow.Operator = apRow.Operator;

                foreach (SOARolePropertyValue srv in apRow.Values)
                {
                    if (amDefinitions.ContainsKey(srv.Column.Name))
                    {
                        SOARolePropertyValue newValue = new SOARolePropertyValue(amDefinitions[srv.Column.Name]);

                        newValue.Value = srv.Value;

                        newRow.Values.Add(newValue);
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并,以第一个矩阵的列定义为准
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeActivityMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable <SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxRowNumber = GetMaxRowNumber(amRows);

            foreach (SOARolePropertyRow apRow in apRows)
            {
                SOARolePropertyRow newRow = new SOARolePropertyRow(amRows.Role);

                newRow.RowNumber    = ++maxRowNumber;
                newRow.OperatorType = apRow.OperatorType;
                newRow.Operator     = apRow.Operator;

                foreach (SOARolePropertyValue srv in apRow.Values)
                {
                    if (amDefinitions.ContainsKey(srv.Column.Name))
                    {
                        SOARolePropertyValue newValue = new SOARolePropertyValue(amDefinitions[srv.Column.Name]);

                        newValue.Value = srv.Value;

                        newRow.Values.Add(newValue);
                    }
                }
            }
        }
        public WfApprovalMatrix ClientToServer(WfClientApprovalMatrix client, ref WfApprovalMatrix server)
        {
            client.NullCheck("client");

            if (server == null)
            {
                server = new WfApprovalMatrix();
            }

            server.ID = client.ID;

            foreach (WfClientRolePropertyDefinition cpd in client.PropertyDefinitions)
            {
                SOARolePropertyDefinition spd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ClientToServer(cpd, ref spd);

                server.PropertyDefinitions.Add(spd);
            }

            foreach (WfClientRolePropertyRow cRow in client.Rows)
            {
                SOARolePropertyRow sRow = null;

                WfClientRolePropertyRowConverter.Instance.ClientToServer(cRow, server.PropertyDefinitions, ref sRow);

                server.Rows.Add(sRow);
            }

            return(server);
        }
Exemplo n.º 9
0
        private static List <SOARolePropertyRow> FindMatchedActivityMatrixRows(
            IEnumerable <SOARolePropertyRow> amRows,
            string apColumnName,
            SOARolePropertyRow apRow,
            Func <SOARolePropertyRow, bool> condition)
        {
            List <SOARolePropertyRow> result = new List <SOARolePropertyRow>();

            foreach (SOARolePropertyRow amRow in amRows)
            {
                string activityCode = amRow.Values.GetValue(SOARolePropertyDefinition.ActivityCodeColumn, string.Empty);

                if (activityCode.IsNotEmpty())
                {
                    if (string.Compare(apColumnName, activityCode, true) == 0)
                    {
                        if (condition(amRow))
                        {
                            result.Add(amRow);
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 10
0
        private static void AppendOperator(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string apUser)
        {
            string columnName = SOARolePropertyDefinition.OperatorColumn;

            if (columns.ContainsKey(columnName))
            {
                SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName);

                if (pValue == null)
                {
                    pValue = new SOARolePropertyValue(columns[columnName]);
                    row.Values.Add(pValue);
                }

                if (apUser.IsNotEmpty())
                {
                    pValue.Value = pValue.Value.NullOrEmptyIs(row.Operator);

                    if (pValue.Value.IsNotEmpty())
                    {
                        pValue.Value += ",";
                    }
                    else
                    {
                        pValue.Value = string.Empty;
                    }

                    pValue.Value += apUser;

                    row.Operator = pValue.Value;
                }
            }
        }
Exemplo n.º 11
0
 private static List <SOARolePropertyRow> FindMatchedActivityMatrixTemplateRows(
     IEnumerable <SOARolePropertyRow> amRows,
     string apColumnName,
     SOARolePropertyRow apRow)
 {
     return(FindMatchedActivityMatrixRows(amRows, apColumnName, apRow, (amRow) => amRow.OperatorType != SOARoleOperatorType.User));
 }
Exemplo n.º 12
0
        private static SOARolePropertyRow PrepareOneRow(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRow row = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = string.Empty
            };

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row.Values.Add(new SOARolePropertyValue(pds["Approver1"])
            {
                Value = "yangrui1"
            });
            row.Values.Add(new SOARolePropertyValue(pds["Approver2"])
            {
                Value = "quym"
            });
            row.Values.Add(new SOARolePropertyValue(pds["Approver3"])
            {
                Value = "liming"
            });

            return(row);
        }
Exemplo n.º 13
0
        public override void ClientToServer(WfClientResourceDescriptor client, ref WfResourceDescriptor server)
        {
            client.NullCheck("client");

            if (server == null)
            {
                server = new WfActivityMatrixResourceDescriptor();
            }

            WfActivityMatrixResourceDescriptor       amr = (WfActivityMatrixResourceDescriptor)server;
            WfClientActivityMatrixResourceDescriptor cmr = (WfClientActivityMatrixResourceDescriptor)client;

            amr.ExternalMatrixID = cmr.ExternalMatrixID;

            foreach (WfClientRolePropertyDefinition cpd in cmr.PropertyDefinitions)
            {
                SOARolePropertyDefinition spd = null;

                WfClientRolePropertyDefinitionConverter.Instance.ClientToServer(cpd, ref spd);

                amr.PropertyDefinitions.Add(spd);
            }

            foreach (WfClientRolePropertyRow cRow in cmr.Rows)
            {
                SOARolePropertyRow sRow = null;

                WfClientRolePropertyRowConverter.Instance.ClientToServer(cRow, amr.PropertyDefinitions, ref sRow);

                amr.Rows.Add(sRow);
            }
        }
Exemplo n.º 14
0
        private static void MergeToActivityMatrixRow(
            SOARolePropertyRow amRow,
            SOARolePropertyDefinitionCollection amDefinitions,
            string apUser)
        {
            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.OperatorTypeColumn, SOARoleOperatorType.User.ToString());

            AppendOperator(amRow, amDefinitions, apUser);
        }
Exemplo n.º 15
0
        private static SOARolePropertyRow PrepareOneRow(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRow row = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = string.Empty };

            row.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row.Values.Add(new SOARolePropertyValue(pds["Approver1"]) { Value = "yangrui1" });
            row.Values.Add(new SOARolePropertyValue(pds["Approver2"]) { Value = "quym" });
            row.Values.Add(new SOARolePropertyValue(pds["Approver3"]) { Value = "liming" });

            return row;
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SOARolePropertyRow row = new SOARolePropertyRow();

            row.RowNumber = dictionary.GetValue("rowNumber", 0);
            row.Operator = dictionary.GetValue("operator", string.Empty);
            row.OperatorType = dictionary.GetValue("operatorType", SOARoleOperatorType.User);

            JSONSerializerExecute.FillDeserializedCollection(dictionary["values"], row.Values);

            return row;
        }
Exemplo n.º 17
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            SOARolePropertyRow row = new SOARolePropertyRow();

            row.RowNumber    = dictionary.GetValue("rowNumber", 0);
            row.Operator     = dictionary.GetValue("operator", string.Empty);
            row.OperatorType = dictionary.GetValue("operatorType", SOARoleOperatorType.User);

            JSONSerializerExecute.FillDeserializedCollection(dictionary["values"], row.Values);

            return(row);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 创建一个与活动矩阵不匹配列的审批矩阵
        /// </summary>
        /// <returns></returns>
        public static WfApprovalMatrix PrepareExtrApprovalMatrix()
        {
            WfApprovalMatrix matrix = new WfApprovalMatrix()
            {
                ID = UuidHelper.NewUuidString()
            };

            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition()
            {
                Name = "CostCenter", SortOrder = 0
            });
            matrix.PropertyDefinitions.Add(new SOARolePropertyDefinition()
            {
                Name = "ExtraApprover", SortOrder = 1
            });

            SOARolePropertyDefinitionCollection pds = matrix.PropertyDefinitions;

            SOARolePropertyRow row1 = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = string.Empty
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"])
            {
                Value = "wangli5"
            });

            matrix.Rows.Add(row1);

            SOARolePropertyRow row2 = new SOARolePropertyRow()
            {
                RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = string.Empty
            };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["ExtraApprover"])
            {
                Value = "InvalidUser"
            });

            matrix.Rows.Add(row2);

            return(matrix);
        }
Exemplo n.º 20
0
        public static void AreSame(this SOARolePropertyRow expected, SOARolePropertyRow actual)
        {
            AssertStringEqual(expected.Operator, actual.Operator);
            Assert.AreEqual(expected.OperatorType, actual.OperatorType);
            Assert.AreEqual(expected.RowNumber, actual.RowNumber);

            foreach (SOARolePropertyValue pve in expected.Values)
            {
                string actualValue = actual.Values.GetValue(pve.Column.Name, string.Empty);

                AssertStringEqual(pve.Value, actualValue);
            }
        }
Exemplo n.º 21
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            SOARolePropertyRow row = (SOARolePropertyRow)obj;

            dictionary.AddNonDefaultValue("rowNumber", row.RowNumber);
            dictionary.AddNonDefaultValue("operatorType", row.OperatorType);
            dictionary.AddNonDefaultValue("operator", row.Operator);

            dictionary["values"] = JSONSerializerExecute.Serialize(row.Values);

            return(dictionary);
        }
Exemplo n.º 22
0
        private static SOARolePropertyRow PrepareTwoUsersDynamicRow(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRow row1 = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "liming,liming,yangrui1"
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "30"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivitySNColumn])
            {
                Value = "20"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ConditionColumn])
            {
                Value = "RowOperators.Count > 0"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivityCodeColumn])
            {
                Value = "Approver1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivityNameColumn])
            {
                Value = "二级审批"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.AutoExtractColumn])
            {
                Value = "True"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorTypeColumn])
            {
                Value = "User"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorColumn])
            {
                Value = "liming,liming,yangrui1"
            });

            return(row1);
        }
Exemplo n.º 23
0
        private static void SetCellValue(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string columnName, string cellValue)
        {
            if (columns.ContainsKey(columnName))
            {
                SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName);

                if (pValue == null)
                {
                    pValue = new SOARolePropertyValue(columns[columnName]);
                    row.Values.Add(pValue);
                }

                pValue.Value = cellValue;
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 将活动矩阵与审批矩阵进行合并
        /// </summary>
        /// <param name="amRows"></param>
        /// <param name="amDefinitions"></param>
        /// <param name="apRows"></param>
        /// <param name="apDefinitions"></param>
        public static void MergeApprovalMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable <SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        {
            amDefinitions.NullCheck("amDefinitions");
            amRows.NullCheck("amRows");
            apDefinitions.NullCheck("apDefinitions");
            apRows.NullCheck("apRows");

            int maxActivitySN = GetMaxActivitySN(amRows);
            int maxRowNumber  = GetMaxRowNumber(amRows);

            List <SOARolePropertyRow> newAmRows = new List <SOARolePropertyRow>();

            foreach (SOARolePropertyRow apRow in apRows)
            {
                int columnIndex = 1;

                while (columnIndex < apDefinitions.Count)
                {
                    List <SOARolePropertyRow> amUserRows     = FindMatchedActivityMatrixUserRows(amRows, apDefinitions[columnIndex].Name, apRow);
                    List <SOARolePropertyRow> amTemplateRows = FindMatchedActivityMatrixTemplateRows(amRows, apDefinitions[columnIndex].Name, apRow);

                    string apUser = apRow.Values.GetValue(apDefinitions[columnIndex].Name, string.Empty);

                    if (amUserRows.Count == 0 && apUser.IsNotEmpty())
                    {
                        SOARolePropertyRow templateRow = amTemplateRows.LastOrDefault();

                        maxActivitySN += 10;
                        SOARolePropertyRow amRow = CreateNewActivityMatrixRow(maxActivitySN, ++maxRowNumber, amDefinitions, templateRow);

                        newAmRows.Add(amRow);

                        MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                    }
                    else
                    {
                        foreach (SOARolePropertyRow amRow in amUserRows)
                        {
                            MergeToActivityMatrixRow(amRow, amDefinitions, apUser);
                        }
                    }

                    columnIndex++;
                }
            }

            amRows.CopyFrom(newAmRows);
        }
Exemplo n.º 25
0
        private static SOARolePropertyRow PrepareOneRow(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRow row1 = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy"
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "30"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivitySNColumn])
            {
                Value = "10"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ConditionColumn])
            {
                Value = "RowOperators.Count > 0"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivityCodeColumn])
            {
                Value = "Approver1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.ActivityNameColumn])
            {
                Value = "一级审批"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorTypeColumn])
            {
                Value = "User"
            });
            row1.Values.Add(new SOARolePropertyValue(pds[SOARolePropertyDefinition.OperatorColumn])
            {
                Value = "fanhy"
            });

            return(row1);
        }
Exemplo n.º 26
0
        private static SOARolePropertyRowCollection PrepareServerRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy"
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "30"
            });

            SOARolePropertyRow row2 = new SOARolePropertyRow()
            {
                RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "wangli5"
            };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1002"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "2"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "40"
            });

            rows.Add(row1);
            rows.Add(row2);

            return(rows);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        public static void AssertAndOutputMatrixOperators(this SOARolePropertyRowCollection rows)
        {
            if (rows != null)
            {
                for (int i = 0; i < rows.Count; i++)
                {
                    SOARolePropertyRow row = rows[i];
                    Console.Write("Number: {0}", row.RowNumber);

                    foreach (SOARolePropertyValue v in row.Values)
                    {
                        Console.Write("; {0}: {1}", v.Column.Name, v.Value);
                    }

                    Console.WriteLine();

                    Assert.AreEqual(row.Operator, row.Values.GetValue("Operator", string.Empty));
                }
            }
        }
Exemplo n.º 30
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);
        }
		public WfClientRolePropertyRow ServerToClient(SOARolePropertyRow server, WfClientRolePropertyDefinitionCollection clientColumns, ref WfClientRolePropertyRow client)
		{
			server.NullCheck("server");

			if (client == null)
				client = new WfClientRolePropertyRow();

			client.RowNumber = server.RowNumber;
			client.Operator = server.Operator;
			client.OperatorType = server.OperatorType.ToClientRoleOperatorType();

			foreach (SOARolePropertyValue spv in server.Values)
			{
				WfClientRolePropertyValue cpv = null;

				WfClientRolePropertyValueConverter.Instance.ServerToClient(spv, clientColumns, ref cpv);

				client.Values.Add(cpv);
			}

			return client;
		}
Exemplo n.º 32
0
        private static SOARolePropertyRowCollection PrepareServerRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver1"]) { Value = "yangrui1" });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver2"]) { Value = "quym" });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver3"]) { Value = "liming" });

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver1"]) { Value = string.Empty });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver2"]) { Value = "quym" });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver3"]) { Value = "liming" });

            SOARolePropertyRow row3 = new SOARolePropertyRow() { RowNumber = 3, OperatorType = SOARoleOperatorType.User };

            row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1003" });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver1"]) { Value = string.Empty });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver2"]) { Value = string.Empty });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver3"]) { Value = "liming" });

            SOARolePropertyRow row4 = new SOARolePropertyRow() { RowNumber = 4, OperatorType = SOARoleOperatorType.User };

            row4.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1003" });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver1"]) { Value = "yangrui1" });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver2"]) { Value = string.Empty });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver3"]) { Value = "liming" });

            rows.Add(row1);
            rows.Add(row2);
            rows.Add(row3);
            rows.Add(row4);

            return rows;
        }
		public SOARolePropertyRow ClientToServer(WfClientRolePropertyRow client, SOARolePropertyDefinitionCollection serverColumns, ref SOARolePropertyRow server)
		{
			client.NullCheck("client");

			if (server == null)
				server = new SOARolePropertyRow();

			server.RowNumber = client.RowNumber;
			server.Operator = client.Operator;
			server.OperatorType = client.OperatorType.ToRoleOperatorType();

			foreach (WfClientRolePropertyValue cpv in client.Values)
			{
				SOARolePropertyValue spv = null;

				WfClientRolePropertyValueConverter.Instance.ClientToServer(cpv, serverColumns, ref spv);

				server.Values.Add(spv);
			}

			return server;
		}
Exemplo n.º 34
0
        public WfClientRolePropertyRow ServerToClient(SOARolePropertyRow server, WfClientRolePropertyDefinitionCollection clientColumns, ref WfClientRolePropertyRow client)
        {
            server.NullCheck("server");

            if (client == null)
            {
                client = new WfClientRolePropertyRow();
            }

            client.RowNumber    = server.RowNumber;
            client.Operator     = server.Operator;
            client.OperatorType = server.OperatorType.ToClientRoleOperatorType();

            foreach (SOARolePropertyValue spv in server.Values)
            {
                WfClientRolePropertyValue cpv = null;

                WfClientRolePropertyValueConverter.Instance.ServerToClient(spv, clientColumns, ref cpv);

                client.Values.Add(cpv);
            }

            return(client);
        }
Exemplo n.º 35
0
        public SOARolePropertyRow ClientToServer(WfClientRolePropertyRow client, SOARolePropertyDefinitionCollection serverColumns, ref SOARolePropertyRow server)
        {
            client.NullCheck("client");

            if (server == null)
            {
                server = new SOARolePropertyRow();
            }

            server.RowNumber    = client.RowNumber;
            server.Operator     = client.Operator;
            server.OperatorType = client.OperatorType.ToRoleOperatorType();

            foreach (WfClientRolePropertyValue cpv in client.Values)
            {
                SOARolePropertyValue spv = null;

                WfClientRolePropertyValueConverter.Instance.ClientToServer(cpv, serverColumns, ref spv);

                server.Values.Add(spv);
            }

            return(server);
        }
Exemplo n.º 36
0
        ///// <summary>
        ///// 将活动矩阵与审批矩阵进行合并
        ///// </summary>
        ///// <param name="amRows"></param>
        ///// <param name="amDefinitions"></param>
        ///// <param name="apRows"></param>
        ///// <param name="apDefinitions"></param>
        //public static void MergeApprovalMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable<SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        //{
        //    amDefinitions.NullCheck("amDefinitions");
        //    amRows.NullCheck("amRows");
        //    apDefinitions.NullCheck("apDefinitions");
        //    apRows.NullCheck("apRows");

        //    int maxActivitySN = GetMaxActivitySN(amRows);
        //    int maxRowNumber = GetMaxRowNumber(amRows);

        //    List<SOARolePropertyRow> newAmRows = new List<SOARolePropertyRow>();

        //    foreach (SOARolePropertyRow apRow in apRows)
        //    {
        //        int columnIndex = 1;

        //        while (columnIndex < apDefinitions.Count)
        //        {
        //            SOARolePropertyRow templateRow = null;

        //            SOARolePropertyRow amRow = FindMatchedActivityMatrixRow(amRows, apDefinitions[columnIndex].Name, apRow, out templateRow);

        //            string apUser = apRow.Values.GetValue(apDefinitions[columnIndex].Name, string.Empty);

        //            if (amRow == null && apUser.IsNotEmpty())
        //            {
        //                maxActivitySN += 10;

        //                amRow = CreateNewActivityMatrixRow(maxActivitySN, ++maxRowNumber, amDefinitions, templateRow);

        //                newAmRows.Add(amRow);
        //            }

        //            if (amRow != null)
        //                MergeToActivityMatrixRow(amRow, amDefinitions, apUser);

        //            columnIndex++;
        //        }
        //    }

        //    amRows.CopyFrom(newAmRows);
        //}

        private static SOARolePropertyRow CreateNewActivityMatrixRow(int activitySN, int rowNumber, SOARolePropertyDefinitionCollection amDefinitions, SOARolePropertyRow templateRow)
        {
            SOARolePropertyRow amRow = null;

            if (templateRow != null)
            {
                amRow = new SOARolePropertyRow(templateRow, rowNumber);
            }
            else
            {
                amRow = new SOARolePropertyRow()
                {
                    RowNumber = rowNumber
                }
            };

            amRow.OperatorType = SOARoleOperatorType.User;
            amRow.Operator     = string.Empty;

            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.OperatorColumn, string.Empty);
            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.ActivitySNColumn, activitySN.ToString());

            return(amRow);
        }
Exemplo n.º 37
0
        private static SOARole PrepareSOARole()
        {
            IRole originalRole = GetTestRole();

            SOARolePropertyDefinitionCollection pds = UpdateRolePropertiesDefinition(originalRole);

            SOARole role = new SOARole(originalRole.FullCodeName);

            role.Rows.Clear();

            SOARolePropertyRow row1 = new SOARolePropertyRow(role)
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy,wanhw"
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "30"
            });

            SOARolePropertyRow row2 = new SOARolePropertyRow(role)
            {
                RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "wangli5"
            };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1002"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "2"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "40"
            });

            SOARolePropertyRow row3 = new SOARolePropertyRow(role)
            {
                RowNumber = 3, OperatorType = SOARoleOperatorType.Role, Operator = RolesDefineConfig.GetConfig().RolesDefineCollection["nestedRole"].Roles
            };

            row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1002"
            });
            row3.Values.Add(new SOARolePropertyValue(pds["PayMethod"])
            {
                Value = "2"
            });
            row3.Values.Add(new SOARolePropertyValue(pds["Age"])
            {
                Value = "60"
            });

            role.Rows.Add(row1);
            role.Rows.Add(row2);
            role.Rows.Add(row3);

            SOARolePropertiesAdapter.Instance.Update(role);

            return(role);
        }
Exemplo n.º 38
0
 private static List<SOARolePropertyRow> FindMatchedActivityMatrixTemplateRows(
     IEnumerable<SOARolePropertyRow> amRows,
     string apColumnName,
     SOARolePropertyRow apRow)
 {
     return FindMatchedActivityMatrixRows(amRows, apColumnName, apRow, (amRow) => amRow.OperatorType != SOARoleOperatorType.User);
 }
        /// <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;
        }
        private static SOARolePropertyRowCollection PrepareServerRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy" };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "1" });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "30" });

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "wangli5" };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row2.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "2" });
            row2.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "40" });

            rows.Add(row1);
            rows.Add(row2);

            return rows;
        }
Exemplo n.º 41
0
        ///// <summary>
        ///// 将活动矩阵与审批矩阵进行合并
        ///// </summary>
        ///// <param name="amRows"></param>
        ///// <param name="amDefinitions"></param>
        ///// <param name="apRows"></param>
        ///// <param name="apDefinitions"></param>
        //public static void MergeApprovalMatrix(this SOARolePropertyRowCollection amRows, SOARolePropertyDefinitionCollection amDefinitions, IEnumerable<SOARolePropertyRow> apRows, SOARolePropertyDefinitionCollection apDefinitions)
        //{
        //    amDefinitions.NullCheck("amDefinitions");
        //    amRows.NullCheck("amRows");
        //    apDefinitions.NullCheck("apDefinitions");
        //    apRows.NullCheck("apRows");

        //    int maxActivitySN = GetMaxActivitySN(amRows);
        //    int maxRowNumber = GetMaxRowNumber(amRows);

        //    List<SOARolePropertyRow> newAmRows = new List<SOARolePropertyRow>();

        //    foreach (SOARolePropertyRow apRow in apRows)
        //    {
        //        int columnIndex = 1;

        //        while (columnIndex < apDefinitions.Count)
        //        {
        //            SOARolePropertyRow templateRow = null;

        //            SOARolePropertyRow amRow = FindMatchedActivityMatrixRow(amRows, apDefinitions[columnIndex].Name, apRow, out templateRow);

        //            string apUser = apRow.Values.GetValue(apDefinitions[columnIndex].Name, string.Empty);

        //            if (amRow == null && apUser.IsNotEmpty())
        //            {
        //                maxActivitySN += 10;

        //                amRow = CreateNewActivityMatrixRow(maxActivitySN, ++maxRowNumber, amDefinitions, templateRow);

        //                newAmRows.Add(amRow);
        //            }

        //            if (amRow != null)
        //                MergeToActivityMatrixRow(amRow, amDefinitions, apUser);

        //            columnIndex++;
        //        }
        //    }

        //    amRows.CopyFrom(newAmRows);
        //}

        private static SOARolePropertyRow CreateNewActivityMatrixRow(int activitySN, int rowNumber, SOARolePropertyDefinitionCollection amDefinitions, SOARolePropertyRow templateRow)
        {
            SOARolePropertyRow amRow = null;

            if (templateRow != null)
                amRow = new SOARolePropertyRow(templateRow, rowNumber);
            else
                amRow = new SOARolePropertyRow() { RowNumber = rowNumber };

            amRow.OperatorType = SOARoleOperatorType.User;
            amRow.Operator = string.Empty;

            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.OperatorColumn, string.Empty);
            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.ActivitySNColumn, activitySN.ToString());

            return amRow;
        }
Exemplo n.º 42
0
        private static SOARolePropertyRowCollection PrepareRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow()
            {
                RowNumber = 1, OperatorType = SOARoleOperatorType.User
            };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1001"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver1"])
            {
                Value = "yangrui1"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver2"])
            {
                Value = "quym"
            });
            row1.Values.Add(new SOARolePropertyValue(pds["Approver3"])
            {
                Value = "liming"
            });

            SOARolePropertyRow row2 = new SOARolePropertyRow()
            {
                RowNumber = 2, OperatorType = SOARoleOperatorType.User
            };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1002"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver1"])
            {
                Value = string.Empty
            });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver2"])
            {
                Value = "quym"
            });
            row2.Values.Add(new SOARolePropertyValue(pds["Approver3"])
            {
                Value = "liming"
            });

            SOARolePropertyRow row3 = new SOARolePropertyRow()
            {
                RowNumber = 3, OperatorType = SOARoleOperatorType.User
            };

            row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1003"
            });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver1"])
            {
                Value = string.Empty
            });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver2"])
            {
                Value = string.Empty
            });
            row3.Values.Add(new SOARolePropertyValue(pds["Approver3"])
            {
                Value = "liming"
            });

            SOARolePropertyRow row4 = new SOARolePropertyRow()
            {
                RowNumber = 4, OperatorType = SOARoleOperatorType.User
            };

            row4.Values.Add(new SOARolePropertyValue(pds["CostCenter"])
            {
                Value = "1003"
            });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver1"])
            {
                Value = "yangrui1"
            });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver2"])
            {
                Value = string.Empty
            });
            row4.Values.Add(new SOARolePropertyValue(pds["Approver3"])
            {
                Value = "liming"
            });

            rows.Add(row1);
            rows.Add(row2);
            rows.Add(row3);
            rows.Add(row4);

            return(rows);
        }
        /// <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();
            }
        }
        public static void AreSame(this SOARolePropertyRow expected, SOARolePropertyRow actual)
        {
            AssertStringEqual(expected.Operator, actual.Operator);
            Assert.AreEqual(expected.OperatorType, actual.OperatorType);
            Assert.AreEqual(expected.RowNumber, actual.RowNumber);

            foreach (SOARolePropertyValue pve in expected.Values)
            {
                string actualValue = actual.Values.GetValue(pve.Column.Name, string.Empty);

                AssertStringEqual(pve.Value, actualValue);
            }
        }
Exemplo n.º 45
0
        private static void MergeToActivityMatrixRow(
            SOARolePropertyRow amRow,
            SOARolePropertyDefinitionCollection amDefinitions,
            string apUser)
        {
            SetCellValue(amRow, amDefinitions, SOARolePropertyDefinition.OperatorTypeColumn, SOARoleOperatorType.User.ToString());

            AppendOperator(amRow, amDefinitions, apUser);
        }
        private void Save(Stream strem)
        {
            DataTable dt = DocumentHelper.GetRangeValuesAsTable(strem, "Matrix", "A3");
            string[] itemsInfo = this.materialCtrlForMatrix.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);
        }
Exemplo n.º 47
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;
        }
Exemplo n.º 48
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;
        }
Exemplo n.º 49
0
        private static SOARolePropertyRowCollection PrepareRows(SOARolePropertyDefinitionCollection pds)
        {
            SOARolePropertyRowCollection rows = new SOARolePropertyRowCollection();

            SOARolePropertyRow row1 = new SOARolePropertyRow() { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy" };

            row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
            row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "1" });
            row1.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "30" });

            SOARolePropertyRow row2 = new SOARolePropertyRow() { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "wangli5" };

            row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row2.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "2" });
            row2.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "40" });

            SOARolePropertyRow row3 = new SOARolePropertyRow() { RowNumber = 3, OperatorType = SOARoleOperatorType.Role, Operator = RolesDefineConfig.GetConfig().RolesDefineCollection["nestedRole"].Roles };

            row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
            row3.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "2" });
            row3.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "60" });

            rows.Add(row1);
            rows.Add(row2);
            rows.Add(row3);

            return rows;
        }
Exemplo n.º 50
0
        private static object GetDataValueByBookmark(DefinedName bookmark, SOARolePropertyRow row)
        {
            object result = null;

            SOARolePropertyValue propertyValue = row.Values.FindByColumnName(bookmark.Name);

            if (propertyValue != null)
            {
                if (propertyValue.Column.DataType != ColumnDataType.String)
                    result = DataConverter.ChangeType(typeof(string), propertyValue.Value, propertyValue.Column.RealDataType);
                else
                    result = propertyValue.Value;
            }
            else
            {
                switch (bookmark.Name.ToLower())
                {
                    case "operatortype":
                        result = row.OperatorType.ToString();
                        break;
                    case "operator":
                        result = row.Operator;
                        break;
                }
            }

            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;
        }
Exemplo n.º 52
0
        private static void AppendOperator(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string apUser)
        {
            string columnName = SOARolePropertyDefinition.OperatorColumn;

            if (columns.ContainsKey(columnName))
            {
                SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName);

                if (pValue == null)
                {
                    pValue = new SOARolePropertyValue(columns[columnName]);
                    row.Values.Add(pValue);
                }

                if (apUser.IsNotEmpty())
                {
                    pValue.Value = pValue.Value.NullOrEmptyIs(row.Operator);

                    if (pValue.Value.IsNotEmpty())
                        pValue.Value += ",";
                    else
                        pValue.Value = string.Empty;

                    pValue.Value += apUser;

                    row.Operator = pValue.Value;
                }
            }
        }
        private static string PrepareRowSql(string roleID, SOARolePropertyRow row)
        {
            InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(row);

            builder.AppendItem("ROLE_ID", roleID);

            return "INSERT INTO WF.ROLE_PROPERTIES_ROWS" + builder.ToSqlString(TSqlBuilder.Instance);
        }
        private static string PrepareValueSql(string roleID, SOARolePropertyRow row, SOARolePropertyValue propValue)
        {
            InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(propValue);

            builder.AppendItem("ROLE_ID", roleID);
            builder.AppendItem("PROPERTIES_ROW_ID", row.RowNumber);
            builder.AppendItem("PROPERTY_NAME", propValue.Column.Name);

            return "INSERT INTO WF.ROLE_PROPERTIES_CELLS" + builder.ToSqlString(TSqlBuilder.Instance);
        }
Exemplo n.º 55
0
		private static SOARole PrepareSOARole()
		{
			IRole originalRole = GetTestRole();

			SOARolePropertyDefinitionCollection pds = UpdateRolePropertiesDefinition(originalRole);

			SOARole role = new SOARole(originalRole.FullCodeName);

			role.Rows.Clear();

			SOARolePropertyRow row1 = new SOARolePropertyRow(role) { RowNumber = 1, OperatorType = SOARoleOperatorType.User, Operator = "fanhy,wanhw" };

			row1.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1001" });
			row1.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "1" });
			row1.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "30" });

			SOARolePropertyRow row2 = new SOARolePropertyRow(role) { RowNumber = 2, OperatorType = SOARoleOperatorType.User, Operator = "wangli5" };

			row2.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
			row2.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "2" });
			row2.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "40" });

			SOARolePropertyRow row3 = new SOARolePropertyRow(role) { RowNumber = 3, OperatorType = SOARoleOperatorType.Role, Operator = RolesDefineConfig.GetConfig().RolesDefineCollection["nestedRole"].Roles };

			row3.Values.Add(new SOARolePropertyValue(pds["CostCenter"]) { Value = "1002" });
			row3.Values.Add(new SOARolePropertyValue(pds["PayMethod"]) { Value = "2" });
			row3.Values.Add(new SOARolePropertyValue(pds["Age"]) { Value = "60" });

			role.Rows.Add(row1);
			role.Rows.Add(row2);
			role.Rows.Add(row3);

			SOARolePropertiesAdapter.Instance.Update(role);

			return role;
		}
Exemplo n.º 56
0
        private static void SetCellValue(SOARolePropertyRow row, SOARolePropertyDefinitionCollection columns, string columnName, string cellValue)
        {
            if (columns.ContainsKey(columnName))
            {
                SOARolePropertyValue pValue = row.Values.FindByColumnName(columnName);

                if (pValue == null)
                {
                    pValue = new SOARolePropertyValue(columns[columnName]);
                    row.Values.Add(pValue);
                }

                pValue.Value = cellValue;
            }
        }
Exemplo n.º 57
0
        private static List<SOARolePropertyRow> FindMatchedActivityMatrixRows(
            IEnumerable<SOARolePropertyRow> amRows,
            string apColumnName,
            SOARolePropertyRow apRow,
            Func<SOARolePropertyRow, bool> condition)
        {
            List<SOARolePropertyRow> result = new List<SOARolePropertyRow>();

            foreach (SOARolePropertyRow amRow in amRows)
            {
                string activityCode = amRow.Values.GetValue(SOARolePropertyDefinition.ActivityCodeColumn, string.Empty);

                if (activityCode.IsNotEmpty())
                {
                    if (string.Compare(apColumnName, activityCode, true) == 0)
                    {
                        if (condition(amRow))
                            result.Add(amRow);
                    }
                }
            }

            return result;
        }