Пример #1
0
        private static string BuildRowsUsersSql(WfMatrixRowUsersCollection rowsUsers)
        {
            StringBuilder strB = new StringBuilder();

            foreach (WfMatrixRowUsers rowUsers in rowsUsers)
            {
                foreach (IUser user in rowUsers.Users)
                {
                    InsertSqlClauseBuilder builder = new InsertSqlClauseBuilder();

                    builder.AppendItem("MATRIX_ID", rowUsers.Row.Matrix.MatrixID);
                    builder.AppendItem("MATRIX_ROW_ID", rowUsers.Row.RowNumber);
                    builder.AppendItem("USER_ID", user.ID);
                    builder.AppendItem("USER_NAME", user.DisplayName);
                    builder.AppendTenantCode();

                    if (strB.Length > 0)
                    {
                        strB.Append(TSqlBuilder.Instance.DBStatementSeperator);
                    }

                    strB.AppendFormat("INSERT INTO WF.MATRIX_ROWS_USERS {0}", builder.ToSqlString(TSqlBuilder.Instance));
                }
            }

            return(strB.ToString());
        }
Пример #2
0
        internal void GenerateCandidatesFromMatrix(WfMatrix matrix)
        {
            WfMatrixRowCollection rows = FilterRowsByActivity(matrix);

            WfMatrixRowUsersCollection rowsUsers = rows.GenerateRowsUsers();

            foreach (WfMatrixRowUsers ru in rowsUsers)
            {
                this.Candidates.Add(ru.Users);
            }

            Candidates.Distinct((a1, a2) => string.Compare(a1.User.ID, a2.User.ID, true) == 0 && a1.AssigneeType == a2.AssigneeType);
        }
Пример #3
0
        private static void FillPersonTypeUsers(WfMatrixRowUsersCollection rowsUsers)
        {
            Dictionary <string, string> userIDs = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (WfMatrixRowUsers rowUsers in rowsUsers)
            {
                if (rowUsers.Row.OperatorType == WfMatrixOperatorType.Person)
                {
                    foreach (string id in rowUsers.ObjectIDs)
                    {
                        userIDs[id] = id;
                    }
                }
            }

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

            foreach (KeyValuePair <string, string> kp in userIDs)
            {
                logonNames.Add(kp.Key);
            }

            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, logonNames.ToArray());

            if (WfRuntime.ProcessContext.CurrentProcess != null)
            {
                users = users.FilterUniqueSidelineUsers(WfRuntime.ProcessContext.CurrentProcess.OwnerDepartment);
            }

            Dictionary <string, IUser> userDicts = GenerateUserDictionary(users);

            foreach (WfMatrixRowUsers rowUsers in rowsUsers)
            {
                if (rowUsers.Row.OperatorType == WfMatrixOperatorType.Person)
                {
                    foreach (string id in rowUsers.ObjectIDs)
                    {
                        IUser user = null;
                        if (userDicts.TryGetValue(id, out user))
                        {
                            if (rowUsers.Users.Exists(u => string.Compare(u.ID, user.ID, true) == 0) == false)
                            {
                                rowUsers.Users.Add((IUser)OguUser.CreateWrapperObject(user));
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 输出矩阵行中直接包含的人员,人员不会重复
        /// </summary>
        /// <returns></returns>
        public WfMatrixRowUsersCollection GenerateRowsDirectUsers()
        {
            WfMatrixRowUsersCollection result = new WfMatrixRowUsersCollection();

            foreach (WfMatrixRow row in this)
            {
                WfMatrixRowUsers rowUsers = new WfMatrixRowUsers(row);

                rowUsers.ObjectIDs = GenerateObjectIDs(row);

                result.Add(rowUsers);
            }

            FillPersonTypeUsers(result);

            return(result);
        }
Пример #5
0
        private void FillRoleTypeUsers(WfMatrixRowUsersCollection result)
        {
            foreach (var rowUsers in result)
            {
                if (rowUsers.Row.OperatorType == WfMatrixOperatorType.Role)
                {
                    var users = WfMatrix.GetUsersInRole(rowUsers.Row.Operator);

                    foreach (IUser userInRole in users)
                    {
                        if (rowUsers.Users.Exists(u => string.Compare(u.ID, userInRole.ID, true) == 0) == false)
                        {
                            rowUsers.Users.Add(userInRole);
                        }
                    }
                }
            }
        }
Пример #6
0
        protected override void AfterInnerUpdate(WfMatrix data, Dictionary <string, object> context)
        {
            DeleteRelatedData(data.MatrixID);

            WfMatrixRowUsersCollection rowsUsers = (WfMatrixRowUsersCollection)context["MatrixRowsUsers"];

            string rowsUsersSql = BuildRowsUsersSql(rowsUsers);

            if (rowsUsersSql.IsNotEmpty())
            {
                DbHelper.RunSql(rowsUsersSql, GetConnectionName());
            }

            StringBuilder sqlClause = new StringBuilder();

            foreach (var row in data.Rows)
            {
                if (sqlClause.Length > 0)
                {
                    sqlClause.Append(TSqlBuilder.Instance.DBStatementSeperator);
                }

                sqlClause.Append(BuildInsertRowSql(data.MatrixID, row));

                foreach (var cell in row.Cells)
                {
                    sqlClause.Append(BuildInsertCellSql(data.MatrixID, row, cell));
                }
            }

            if (sqlClause.Length > 0)
            {
                DbHelper.RunSql(sqlClause.ToString(), GetConnectionName());
            }

            CacheNotifyData notifyData = new CacheNotifyData(typeof(WfMatrixProcessKeyCache), CalculateCacheKey(data.ProcessKey), CacheNotifyType.Invalid);

            UdpCacheNotifier.Instance.SendNotifyAsync(notifyData);
            MmfCacheNotifier.Instance.SendNotify(notifyData);
        }