예제 #1
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));
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据用户的登录名,去除重复的数据,生成登录名和用户对象的字典
        /// </summary>
        /// <param name="userLogonNames"></param>
        /// <returns></returns>
        private static Dictionary <string, IUser> GetUsersDictionary(IEnumerable <string> userLogonNames)
        {
            Dictionary <string, string> userLogonNamesDict = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (string logonName in userLogonNames)
            {
                userLogonNamesDict[logonName] = logonName;
            }

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

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

            return(GenerateUserDictionary(users));
        }