コード例 #1
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 返回机构对象的子对象
        /// </summary>
        /// <typeparam name="T">期望返回的结果对象的类型,IOrganization、IUser、IGroup或IOguObject</typeparam>
        /// <param name="parent">父机构对象</param>
        /// <param name="includeSideline">对象的类型</param>
        /// <param name="searchLevel">查询的深度,单级或所有子对象</param>
        /// <returns></returns>
        public OguObjectCollection <T> GetChildren <T>(IOrganization parent, bool includeSideline, SearchLevel searchLevel) where T : IOguObject
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(parent != null, "parent");

            SchemaType objType = OguObjectHelper.GetSchemaTypeFromInterface <T>();

            if (includeSideline)
            {
                objType |= SchemaType.Sideline;
            }

            DataTable table = OguReaderServiceBroker.Instance.GetOrganizationChildren(
                parent.ID,
                (int)SearchOUIDType.Guid,
                (int)objType,
                (int)ServiceBrokerContext.Current.ListObjectCondition,
                (int)searchLevel,
                string.Empty,
                string.Empty,
                string.Empty,
                Common.DefaultAttrs).Tables[0];

            if ((objType & SchemaType.Organizations) == SchemaType.Organizations)
            {
                RemoveParentDeptRow(table.Rows, parent);
            }

            return(new OguObjectCollection <T>(Common.BuildObjectsFromTable <T>(table, parent)));
        }
コード例 #2
0
        /// <summary>
        /// 查询指定部门范围下,指定应用系统中,指定角色下的所有人员
        /// </summary>
        /// <param name="orgRoot">部门范围的全路径,空串时不做限制,多个时用逗号分隔</param>
        /// <param name="appCodeName">应用的英文标识</param>
        /// <param name="roleCodeNames">角色的英文标识,多个时用逗号分隔</param>
        /// <param name="delegationMask">权限委派类型</param>
        /// <param name="sidelineMask">人员职位类型</param>
        /// <param name="extAttr">要求获取的扩展属性</param>
        /// <returns>指定部门范围下,指定应用系统中,指定角色下的所有人员</returns>
        public static OguObjectCollection <IUser> GetUsersFromRoles(string orgRoot, string appCodeName, string roleCodeNames,
                                                                    DelegationMaskType delegationMask, SidelineMaskType sidelineMask, string extAttr)
        {
            DataSet ds = AppAdminServiceBroker.Instance.GetRolesUsers(orgRoot, appCodeName, roleCodeNames,
                                                                      delegationMask, SidelineMaskType.All, extAttr);

            var users = Common.BuildObjectsFromTable <IUser>(ds.Tables[0]);

            return(new OguObjectCollection <IUser>(users));
        }
コード例 #3
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 得到某个用户,属于谁的秘书
        /// </summary>
        /// <param name="user">某个用户</param>
        /// <returns>是谁的秘书</returns>
        public OguObjectCollection <IUser> GetSecretaryOf(IUser user)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(user != null, "user");

            string multiIDString = BuildIDString(user.ID);

            DataTable table = OguReaderServiceBroker.Instance.GetLeadersOfSecretaries
                                  (multiIDString,
                                  (int)SearchOUIDType.Guid,
                                  Common.DefaultAttrs,
                                  1).Tables[0];

            return(new OguObjectCollection <IUser>(Common.BuildObjectsFromTable <IUser>(table)));
        }
コード例 #4
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 得到某用户的所有相关用户信息,包括主职和兼职的
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <returns>所有相关用户信息,包括主职和兼职的</returns>
        public OguObjectCollection <IUser> GetAllRelativeUserInfo(IUser user)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(user != null, "user");

            DataTable table = OguReaderServiceBroker.Instance.GetObjectsDetail(SchemaType.Users.ToString().ToUpper(),
                                                                               user.ID,
                                                                               (int)SearchOUIDType.Guid,
                                                                               string.Empty,
                                                                               (int)SearchOUIDType.Guid,
                                                                               Common.DefaultAttrs).Tables[0];

            RemoveDeletedObject(table);

            return(new OguObjectCollection <IUser>(Common.BuildObjectsFromTable <IUser>(table)));
        }
コード例 #5
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 得到某用户属于的所有组
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <returns>用户属于的组</returns>
        public OguObjectCollection <IGroup> GetGroupsOfUser(IUser user)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(user != null, "user");

            string multiIDString = BuildIDString(user.ID);

            DataTable table = OguReaderServiceBroker.Instance.GetGroupsOfUsers(
                multiIDString,
                (int)SearchOUIDType.Guid,
                string.Empty,
                1,
                string.Empty,
                1).Tables[0];

            return(new OguObjectCollection <IGroup>(Common.BuildObjectsFromTable <IGroup>(table)));
        }
コード例 #6
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 得到组当中的用户
        /// </summary>
        /// <param name="group">组对象</param>
        /// <returns>组当中的用户</returns>
        public OguObjectCollection <IUser> GetGroupMembers(IGroup group)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(group != null, "group");

            string multiIDString = BuildIDString(group.ID);

            DataTable table = OguReaderServiceBroker.Instance.GetUsersInGroups(
                multiIDString,
                (int)SearchOUIDType.Guid,
                Common.DefaultAttrs,
                string.Empty,
                1,
                string.Empty,
                1).Tables[0];

            return(new OguObjectCollection <IUser>(Common.BuildObjectsFromTable <IUser>(table)));
        }
コード例 #7
0
        public OguObjectCollection <IOguObject> GetRolesObjects(RoleCollection roles, OguObjectCollection <IOrganization> depts, bool recursively)
        {
            OguObjectCollection <IOguObject> result = null;

            if (roles.Count > 0)
            {
                string roleIDs            = BuildRoleObjectIDs(roles);
                string deptFullPath       = BuildOguObjectFullPath(depts);
                bool   includeMatrixUsers = ServiceBrokerContext.Current.Context.GetValue("includeMatrixUsers", true);

                DataTable table = null;

                if (recursively)
                {
                    table = AppAdminServiceBroker.Instance.GetRolesUsers2(
                        deptFullPath,
                        roles[0].Application.CodeName,
                        roleIDs,
                        DelegationMaskType.All,
                        SidelineMaskType.All,
                        Common.DefaultAttrs,
                        includeMatrixUsers).Tables[0];
                }
                else
                {
                    table = AppAdminServiceBroker.Instance.GetChildrenInRoles2(
                        deptFullPath,
                        roles[0].Application.CodeName,
                        roleIDs,
                        false,
                        true,
                        true,
                        includeMatrixUsers).Tables[0];
                }

                result = new OguObjectCollection <IOguObject>(Common.BuildObjectsFromTable <IOguObject>(table));
            }
            else
            {
                result = new OguObjectCollection <IOguObject>(new List <IOguObject>());
            }

            return(result);
        }
コード例 #8
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        public IOrganization GetRoot()
        {
            string rootPath = OguPermissionSettings.GetConfig().RootOUPath;

            OguObjectCollection <IOrganization> depts;

            if (string.IsNullOrEmpty(rootPath) == false)
            {
                depts = GetObjects <IOrganization>(SearchOUIDType.FullPath, rootPath);
            }
            else
            {
                DataTable table = OguReaderServiceBroker.Instance.GetRootDSE().Tables[0];

                depts = new OguObjectCollection <IOrganization>(Common.BuildObjectsFromTable <IOrganization>(table));
            }

            ExceptionHelper.FalseThrow(depts.Count > 0, Resource.CanNotFindRootOU, rootPath);
            return(depts[0]);
        }
コード例 #9
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        /// <summary>
        /// 在子对象进行查询(所有级别深度)
        /// </summary>
        /// <typeparam name="T">期望的类型</typeparam>
        /// <param name="parent">父机构对象</param>
        /// <param name="matchString">模糊查询的字符串</param>
        /// <param name="includeSideLine">是否包含兼职的人员</param>
        /// <param name="level">查询的深度</param>
        /// <param name="returnCount">返回的记录数</param>
        /// <returns>得到查询的子对象</returns>
        public OguObjectCollection <T> QueryChildren <T>(IOrganization parent, string matchString, bool includeSideLine, SearchLevel level, int returnCount) where T : IOguObject
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(parent != null, "parent");
            //ExceptionHelper.CheckStringIsNullOrEmpty(matchString, "matchString");

            SchemaType objType = OguObjectHelper.GetSchemaTypeFromInterface <T>();

            if (includeSideLine)
            {
                objType |= SchemaType.Sideline;
            }

            int nDep = 0;

            if (level == SearchLevel.OneLevel)
            {
                nDep = 1;
            }

            DataTable table = OguReaderServiceBroker.Instance.QueryOGUByCondition3(
                parent.ID,
                (int)SearchOUIDType.Guid,
                matchString,
                true,
                Common.DefaultAttrs,
                (int)objType,
                (int)ServiceBrokerContext.Current.ListObjectCondition,
                nDep,
                string.Empty,
                returnCount).Tables[0];

            if ((objType & SchemaType.Organizations) == SchemaType.Organizations)
            {
                RemoveParentDeptRow(table.Rows, parent);
            }

            return(new OguObjectCollection <T>(Common.BuildObjectsFromTable <T>(table, parent)));
        }
コード例 #10
0
ファイル: OguAdminMechanism.cs プロジェクト: wooln/AK47Source
        public OguObjectCollection <T> GetObjects <T>(SearchOUIDType idType, params string[] ids) where T : IOguObject
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(ids != null, "ids");

            SchemaType objType = OguObjectHelper.GetSchemaTypeFromInterface <T>();

            ExceptionHelper.TrueThrow(idType == SearchOUIDType.LogOnName &&
                                      (objType & ~(SchemaType.Users | SchemaType.Sideline)) != SchemaType.Unspecified, Resource.OnlyUserCanUserLogOnNameQuery);

            OguObjectCollection <T> result = null;

            if (ids.Length > 0)
            {
                string[]  notInCacheIds = null;
                IList <T> objsInCache   = null;

                if (ServiceBrokerContext.Current.UseLocalCache)
                {
                    objsInCache = OguObjectCacheBase.GetInstance(idType).GetObjectsInCache <T>(ids, out notInCacheIds);
                }
                else
                {
                    notInCacheIds = ids;
                    objsInCache   = new List <T>();
                }

                if (notInCacheIds.Length > 0)
                {
                    string multiIDString = BuildIDString(notInCacheIds);

                    DataSet ds = OguReaderServiceBroker.Instance.GetObjectsDetail(
                        SchemaTypeToString(objType),
                        multiIDString,
                        (int)idType,
                        string.Empty,
                        0,
                        Common.DefaultAttrs);

                    //RemoveDeletedObject(ds.Tables[0]); //原来有这句话,现在去掉,可以查询已经逻辑删除的对象

                    OguObjectCollection <T> queryResult = new OguObjectCollection <T>(Common.BuildObjectsFromTable <T>(ds.Tables[0]));

                    queryResult = queryResult.GetRemovedDuplicateDeletedObjectCollection();

                    if (ServiceBrokerContext.Current.UseLocalCache)
                    {
                        OguObjectCacheBase.GetInstance(idType).AddObjectsToCache <T>(queryResult);
                    }

                    foreach (T obj in queryResult)
                    {
                        objsInCache.Add(obj);
                    }
                }

                result = new OguObjectCollection <T>(objsInCache);
                result.Sort(OrderByPropertyType.GlobalSortID, SortDirectionType.Ascending);
            }
            else
            {
                result = new OguObjectCollection <T>();
            }

            return(result);
        }