예제 #1
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            if (this.Request.QueryString["editMode"] == "readOnly")
            {
                throw new InvalidOperationException("只读模式不可以编辑");
            }

            RoleID = MCS.Web.Library.WebUtility.GetRequestParamString("RoleID", string.Empty);
            SOARole role = new SOARole()
            {
                ID = RoleID
            };

            SOARolePropertyRowCollection rowsColl = SOARolePropertiesAdapter.Instance.LoadByRole(role);

            /*沈峥注释,不需要这个限制
             * if (rowsColl.Count > 0)
             * {
             *      WebUtility.ShowClientMessage("矩阵定义已经被使用,无法再修改!", "", "无法进行此操作");
             *      return;
             * }
             */

            var coll = detailGrid.InitialData as SOARolePropertyDefinitionCollection;

            SOARolePropertyDefinitionAdapter.Instance.Update(role, coll);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "returnProcesses",
                                                    string.Format("window.returnValue = true; top.close();"),
                                                    true);
        }
예제 #2
0
        public void UpdateRolePropertyValuesTest()
        {
            SOARole role = PrepareSOARole();

            SOARolePropertiesAdapter.Instance.Update(role);

            SOARolePropertyRowCollection loadedRows = SOARolePropertiesAdapter.Instance.LoadByRole(role);

            Assert.AreEqual(role.Rows.Count, loadedRows.Count);

            int i = 0;

            foreach (SOARolePropertyRow row in role.Rows)
            {
                Assert.AreEqual(row.Values.Count, loadedRows[i].Values.Count);
                i++;
            }

            DataView view = loadedRows.ToDataView(role.PropertyDefinitions);

            foreach (DataRowView drv in view)
            {
                foreach (DataColumn column in view.Table.Columns)
                {
                    Console.Write("{0}={1} ", column.ColumnName, drv[column.ColumnName]);
                }

                Console.WriteLine();
            }
        }
예제 #3
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);
                    }
                }
            }
        }
        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;
        }
예제 #5
0
        public int DisplaceUserInRoleMatrix(string roleID, string userID, string[] displacingUserIDArray)
        {
            IUser originalUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID).FirstOrDefault();
            OguObjectCollection <IUser> displacingUsers = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, displacingUserIDArray);

            string originalUserCodeName = originalUser != null ? originalUser.LogOnName : string.Empty;

            List <string> desplacingUserCodeNames = new List <string>();

            foreach (IUser user in displacingUsers)
            {
                if (desplacingUserCodeNames.Contains(user.LogOnName) == false)
                {
                    desplacingUserCodeNames.Add(user.LogOnName);
                }
            }

            SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(roleID, null);

            int result = rows.ReplaceOperators(SOARoleOperatorType.User, originalUserCodeName, desplacingUserCodeNames.ToArray());

            SOARolePropertiesAdapter.Instance.Update(roleID, rows);

            return(result);
        }
예제 #6
0
        private SOARolePropertyRowCollection MergeExternalMatrix(SOARolePropertyRowCollection matrixRows, IEnumerable <SOARolePropertiesQueryParam> queryParams)
        {
            if (this.ExternalMatrixID.IsNotEmpty())
            {
                IWfMatrixContainer externalMatrix = this.GetExternalMatrix();

                SOARoleContext.DoNewContextAction(externalMatrix.PropertyDefinitions, this.ProcessInstance, (context) =>
                {
                    if (externalMatrix.PropertyDefinitions.MatrixType == WfMatrixType.ApprovalMatrix)
                    {
                        SOARolePropertyRowCollection approvalRows = externalMatrix.Rows.QueryWithoutCondition(context.QueryParams, true);

                        matrixRows.SortActivitySN();
                        matrixRows.MergeApprovalMatrix(this.PropertyDefinitions, approvalRows, externalMatrix.PropertyDefinitions);
                    }
                    else
                    {
                        SOARolePropertyRowCollection approvalRows = externalMatrix.Rows.QueryWithoutCondition(context.QueryParams, false);

                        matrixRows.SortActivitySN();
                        matrixRows.MergeActivityMatrix(this.PropertyDefinitions, approvalRows, externalMatrix.PropertyDefinitions);
                    }
                });

                matrixRows = matrixRows.FilterByConditionColumn();
            }

            return(matrixRows);
        }
예제 #7
0
        public void FilterAndMergeNotMatchedActivityMatrixAndApprovalMatrixTest()
        {
            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            resource.Rows.ForEach(row => row.Values.FindByColumnName(SOARolePropertyDefinition.ActivityCodeColumn).Value = "NotMatched");

            SOARolePropertyRowCollection activityRows = resource.Rows.Query(queryParam);

            int originalActivityCount = activityRows.Count;

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            int originalApprovalCount = approvalMatrix.PropertyDefinitions.Count - 1;

            activityRows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            activityRows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(originalActivityCount + originalApprovalCount, activityRows.Count);
        }
예제 #8
0
파일: SCRole.cs 프로젝트: wooln/AK47Source
        private static void InternalEnumMatrixUsers(SCRole role, SCRoleEnumMatrixUsersContext context)
        {
            SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(role.ID, null);

            IEnumerator <SOARolePropertyRow> enumerator = rows.GetEnumerator();

            role.InternalEnumMatrixRows(context, enumerator);
        }
예제 #9
0
        public static void AreSame(this SOARolePropertyRowCollection expected, SOARolePropertyRowCollection actual)
        {
            Assert.AreEqual(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                AreSame(expected[i], actual[i]);
            }
        }
예제 #10
0
        public static void FillMatrixSheetData(this IWfMatrixContainer matrix, WorkSheet sheet)
        {
            matrix.NullCheck("matrix");
            sheet.NullCheck("sheet");

            int rowIndex = 4;
            SOARolePropertyRowCollection rows = matrix.Rows;

            foreach (SOARolePropertyRow row in rows)
            {
                foreach (DefinedName name in sheet.Names)
                {
                    var propertyValue = row.Values.FindByColumnName(name.Name);

                    object dataValue = null;

                    if (propertyValue != null)
                    {
                        if (propertyValue.Column.DataType != Data.DataObjects.ColumnDataType.String)
                        {
                            dataValue = DataConverter.ChangeType(typeof(string),
                                                                 propertyValue.Value,
                                                                 propertyValue.Column.RealDataType);
                        }
                        else
                        {
                            dataValue = propertyValue.Value;
                        }
                    }
                    else
                    {
                        if (matrix.MatrixType != WfMatrixType.ApprovalMatrix)
                        {
                            switch (name.Name.ToLower())
                            {
                            case "operatortype":
                                dataValue = row.OperatorType.ToString();
                                break;

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

                    if (dataValue != null)
                    {
                        sheet.Cells[rowIndex, name.Address.StartColumn].Value = dataValue;
                    }
                }

                rowIndex++;
            }
        }
예제 #11
0
        private static void Output(SOARolePropertyRowCollection rows)
        {
            foreach (SOARolePropertyRow row in rows)
            {
                foreach (SOARolePropertyValue v in row.Values)
                {
                    Console.Write("{0}: {1} ", v.Column.Name, v.Value);
                }

                Console.WriteLine();
            }
        }
        private static void FillColumnInfoToRowValues(SOARolePropertyDefinitionCollection columns, SOARolePropertyRowCollection rows)
        {
            foreach (SOARolePropertyRow row in rows)
            {
                foreach (SOARolePropertyValue pv in row.Values)
                {
                    SOARolePropertyDefinition column = columns[pv.Column.Name];

                    pv.SetColumnInfo(column);
                }
            }
        }
예제 #13
0
        public void QueryRoleSingleProperty()
        {
            SOARole role = PrepareSOARole();

            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            SOARolePropertyRowCollection rows = role.Rows.Query(queryParam);

            Assert.AreEqual(1, rows.Count);
        }
예제 #14
0
        public void Fill(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties)
        {
            SOARoleContext.DoAction(this.PropertyDefinitions, this.ProcessInstance, (context) =>
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.QueryWithoutCondition(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows = this.MergeExternalMatrix(matchedRows, context.QueryParams);

                matchedRows = matchedRows.FilterByConditionColumn();

                matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties);
            });
        }
예제 #15
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);
        }
예제 #16
0
        public void ReplaceRoleOperatorToNullTest()
        {
            SOARole role = PrepareSOARole();

            SOARolePropertiesAdapter.Instance.Update(role);

            role.Rows.ReplaceOperators(SOARoleOperatorType.User, "wanhw");

            SOARolePropertiesAdapter.Instance.Update(role);

            SOARolePropertyRowCollection loadedRows = SOARolePropertiesAdapter.Instance.LoadByRole(role);

            Console.WriteLine(loadedRows[0].Operator);

            Assert.AreEqual("fanhy", loadedRows[0].Operator);
        }
예제 #17
0
        public void OperatorBelongToRoleMatrixTest()
        {
            IRole role = GetTestRole();

            SOARole soaRole = SOARoleHelper.PrepareSOARole(role);

            IUser user = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy").First();

            List <string> roleIDs = SOARolePropertiesAdapter.Instance.OperatorBelongToRoleIDsDirectly(user.ID);

            foreach (string roleID in roleIDs)
            {
                SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.GetByRoleID(roleID);

                Output(rows);
            }
        }
예제 #18
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);
        }
예제 #19
0
        public void ReplaceUserInSOARoleTest()
        {
            SOARole role = PrepareSOARole();

            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            SOARolePropertyRowCollection rows = role.Rows.Query(queryParam);

            Assert.AreEqual(1, rows.Count);

            foreach (var rowUsers in rows.GenerateRowsUsers())
            {
                rowUsers.Users.ForEach(u => Console.WriteLine(u.LogOnName));
            }
        }
예제 #20
0
        public void QueryRoleSingleRemovedProperty()
        {
            SOARole role = PrepareSOARole();

            role.PropertyDefinitions.Remove(spd => spd.Name == "CostCenter");

            SOARolePropertyDefinitionAdapter.Instance.Update(role, role.PropertyDefinitions);

            SOARole roleLoaded = new SOARole(role.FullCodeName);

            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            SOARolePropertyRowCollection rows = roleLoaded.Rows.Query(queryParam);

            Assert.AreEqual(0, rows.Count);
        }
예제 #21
0
파일: SCRole.cs 프로젝트: wooln/AK47Source
        /// <summary>
        /// 枚举矩阵中的人员
        /// </summary>
        /// <returns></returns>
        private void EnumMatrixUsers(SchemaObjectCollection result)
        {
            if (this.CurrentApplication != null)
            {
                SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(this.ID, null);

                SCRoleEnumMatrixUsersContext context = new SCRoleEnumMatrixUsersContext();

                context.CachedApplication.Add(this.CurrentApplication.CodeName, this.CurrentApplication);

                string fullCodeName = this.GetFullCodeName();

                context.CalculatedRolesCodeNames.Add(fullCodeName, fullCodeName);

                InternalEnumMatrixUsers(this, context);

                FillMatrixUsers(context, result);
            }
        }
예제 #22
0
        private static void AppendApplicationName(IRole role, List <AppListItem> appList)
        {
            SOARolePropertyRowCollection allRows = SOARolePropertiesAdapter.Instance.GetByRole(role);
            SOARolePropertyRowCollection rows    = allRows;

            if (!RolesDefineConfig.GetConfig().IsCurrentUserInRoles("ProcessAdmin"))
            {
                rows = allRows.Query(r => r.Operator == DeluxeIdentity.Current.User.LogOnName);
            }

            foreach (var row in rows)
            {
                string      appName = row.Values.GetValue("ApplicationName", string.Empty);
                AppListItem obj     = new AppListItem(appName);
                if (!appList.Exists(a => a.Name == obj.Name))
                {
                    appList.Add(obj);
                }
            }
        }
예제 #23
0
        private void ExportExcelXPXml()
        {
            SOARolePropertyDefinitionCollection definition = SOARolePropertyDefinitionAdapter.Instance.LoadByRoleID(ExportRoleProperty.DefinitionID);
            string PropertySheetName = "Matrix";

            WorkbookNode workbook = ExportToExcelXml(definition, PropertySheetName);
            SOARole      role     = new SOARole(definition)
            {
                ID = RoleID
            };

            SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRole(role, definition);

            if (rows.Count > 0)
            {
                FillMatrixRowsToWorksheet(workbook, rows);
            }

            workbook.Response(GetFileNameByRole(RoleID));
        }
예제 #24
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));
                }
            }
        }
예제 #25
0
        public void FilterAndMergeEmptyActivityMatrixAndApprovalMatrixTest()
        {
            WfActivityMatrixResourceDescriptor resource = new WfActivityMatrixResourceDescriptor();

            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1001";

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            resource.Rows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            //输出的只有RowNumber。因为活动矩阵没有列
            resource.Rows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(3, resource.Rows.Count);
        }
예제 #26
0
        private static int FillMatrixSheetData(WorkSheet sheet, WfActivityMatrixResourceDescriptor activityMatrix, int startRowIndex)
        {
            SOARolePropertyRowCollection rows = activityMatrix.Rows;

            foreach (SOARolePropertyRow row in rows)
            {
                foreach (DefinedName bookmark in sheet.Names)
                {
                    object dataValue = GetDataValueByBookmark(bookmark, row);

                    if (dataValue != null)
                    {
                        sheet.Cells[startRowIndex, bookmark.Address.StartColumn].Value = dataValue;
                    }
                }

                startRowIndex++;
            }

            return(startRowIndex);
        }
        private static string[] AllApplicationNames()
        {
            List <string> appList = new List <string>();

            IRole[] roles = RolesDefineConfig.GetConfig().GetRolesInstances("DesignerRoleMatrix");
            foreach (var role in roles)
            {
                SOARolePropertyRowCollection allRows = SOARolePropertiesAdapter.Instance.GetByRole(role);
                SOARolePropertyRowCollection rows    = allRows.Query(r => r.Operator == DeluxeIdentity.Current.User.LogOnName);
                foreach (var row in rows)
                {
                    string appName = row.Values.GetValue("ApplicationName", string.Empty);
                    if (!appList.Contains(appName))
                    {
                        appList.Add(appName);
                    }
                }
            }
            appList.Add(" ");
            return(appList.ToArray());
        }
        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;
        }
예제 #29
0
        public void FilterAndMergeMatchedActiveMatrixWithRoleAndApprovalMatrixTest()
        {
            SOARolePropertiesQueryParam queryParam = new SOARolePropertiesQueryParam();

            queryParam.QueryName  = "CostCenter";
            queryParam.QueryValue = "1002";

            WfActivityMatrixResourceDescriptor resource = ActivityMatrixHelper.PrepareActivityMatrixResourceDescriptor();

            SOARolePropertyRowCollection activityRows = resource.Rows.Query(queryParam);

            int originalCount = activityRows.Count;

            WfApprovalMatrix approvalMatrix = ApprovalMatrixHelper.PrepareApprovalMatrix();

            SOARolePropertyRowCollection approvalRows = approvalMatrix.Rows.Query(queryParam);

            activityRows.MergeApprovalMatrix(resource.PropertyDefinitions, approvalRows, approvalMatrix.PropertyDefinitions);

            activityRows.AssertAndOutputMatrixOperators();

            Assert.AreEqual(3, activityRows.Count);
        }
예제 #30
0
        public OguDataCollection <IUser> GetUsersFromSOARole(SOARolePropertiesQueryParamCollection qps)
        {
            SOARolePropertyRowCollection rows  = null;
            OguDataCollection <IUser>    users = new OguDataCollection <IUser>();
            var schemaRoleID = txtSchemaRoleID.Text;
            var roleRows     = AU.Adapters.AUMatrixHelper.LoadSchemaRolePropertyRows(schemaRoleID);

            if (qps != null)
            {
                rows = roleRows.Query(qps);
            }

            foreach (SOARolePropertyRowUsers rowUsers in rows.GenerateRowsUsers())
            {
                foreach (IUser user in rowUsers.Users)
                {
                    if (users.Contains(user) == false)
                    {
                        users.Add(user);
                    }
                }
            }
            return(users);
        }
예제 #31
0
        protected internal override void FillUsers(OguDataCollection <IUser> users)
        {
            SOARoleContext.DoAction(this.PropertyDefinitions, this.ProcessInstance, (context) =>
            {
                SOARolePropertyRowCollection matchedRows = this.Rows.QueryWithoutCondition(context.QueryParams);

                matchedRows = matchedRows.ExtractMatrixRows();

                matchedRows = this.MergeExternalMatrix(matchedRows, context.QueryParams);

                matchedRows = matchedRows.FilterByConditionColumn();

                foreach (SOARolePropertyRowUsers rowUsers in matchedRows.GenerateRowsUsers())
                {
                    foreach (IUser user in rowUsers.Users)
                    {
                        if (users.Contains(user) == false)
                        {
                            users.Add(user);
                        }
                    }
                }
            });
        }
        private SOARolePropertyRowCollection MergeExternalMatrix(SOARolePropertyRowCollection matrixRows, IEnumerable<SOARolePropertiesQueryParam> queryParams)
        {
            if (this.ExternalMatrixID.IsNotEmpty())
            {
                IWfMatrixContainer externalMatrix = this.GetExternalMatrix();

                SOARoleContext.DoNewContextAction(externalMatrix.PropertyDefinitions, this.ProcessInstance, (context) =>
                {
                    if (externalMatrix.PropertyDefinitions.MatrixType == WfMatrixType.ApprovalMatrix)
                    {
                        SOARolePropertyRowCollection approvalRows = externalMatrix.Rows.QueryWithoutCondition(context.QueryParams, true);

                        matrixRows.SortActivitySN();
                        matrixRows.MergeApprovalMatrix(this.PropertyDefinitions, approvalRows, externalMatrix.PropertyDefinitions);
                    }
                    else
                    {
                        SOARolePropertyRowCollection approvalRows = externalMatrix.Rows.QueryWithoutCondition(context.QueryParams, false);

                        matrixRows.SortActivitySN();
                        matrixRows.MergeActivityMatrix(this.PropertyDefinitions, approvalRows, externalMatrix.PropertyDefinitions);
                    }
                });

                matrixRows = matrixRows.FilterByConditionColumn();
            }

            return matrixRows;
        }
        private static void PrepareRowsSql(string roleID, SOARolePropertyRowCollection rows, StringBuilder strB)
        {
            foreach (SOARolePropertyRow row in rows)
            {
                strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

                strB.Append(PrepareRowSql(roleID, row));

                foreach (SOARolePropertyValue propValue in row.Values)
                {
                    strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

                    strB.Append(PrepareValueSql(roleID, row, propValue));
                }
            }
        }
        public void Update(string roleID, SOARolePropertyRowCollection rows)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            rows.NullCheck("rows");

            StringBuilder strB = new StringBuilder(1024);

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

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

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

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

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

            PrepareRowsSql(roleID, rows, strB);

            SOARolePropertyRowUsersCollection rowsUsers = rows.GenerateRowsUsersDirectly();
            SOARolePropertyRowRolesCollection rowsRoles = rows.GenerateRowsRolesDirectly();

            PrepareUserContainers(roleID, rowsUsers, strB);
            PrepareRoleContainers(roleID, rowsRoles, strB);

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

            CacheNotifyData notifyData = new CacheNotifyData(typeof(SOARolePropertiesCache), roleID.ToRoleIDCacheKey(), CacheNotifyType.Invalid);
            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }
        /// <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;
        }
		//导出带数据的Excel
		private static void FillMatrixRowsToWorksheet(WorkbookNode workbook, SOARolePropertyRowCollection rows)
		{
			NamedLocationCollection locations = workbook.Names.ToLocations();

			locations.SortByColumn();

			WorksheetNode worksheet = workbook.Worksheets[GetWorksheet(locations)];
			int startRowIndex = GetStartRow(locations);
			int currentRowIndex = -1;

			foreach (SOARolePropertyRow matrixRow in rows)
			{
				RowNode row = new RowNode();

				if (currentRowIndex == -1)
				{
					currentRowIndex = startRowIndex + 1;
					row.Index = currentRowIndex;
				}

				for (int i = 0; i < locations.Count; i++)
				{
					CellNode cell = new CellNode();

					CellLocation location = locations[i];

					SOARolePropertyValue propertyValue = matrixRow.Values.FindByColumnName(location.Name);

					string dataValue = null;

					if (propertyValue != null)
						dataValue = propertyValue.Value;
					else
					{
						switch (location.Name.ToLower())
						{
							case "operatortype":
								dataValue = matrixRow.OperatorType.ToString();
								break;
							case "operator":
								dataValue = matrixRow.Operator;
								break;
						}
					}

					if (dataValue != null)
						cell.Data.Value = dataValue;
					else
						cell.Data.Value = string.Empty;

					row.Cells.Add(cell);
				}

				worksheet.Table.Rows.Add(row);
			}
		}
        public static void AreSame(this SOARolePropertyRowCollection expected, SOARolePropertyRowCollection actual)
        {
            Assert.AreEqual(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                AreSame(expected[i], actual[i]);
            }
        }
예제 #38
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);
        }
        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);
        }
        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;
        }
예제 #41
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;
        }