コード例 #1
0
        /// <summary>
        /// µÃµ½»ú¹¹ÈËÔ±µÄʵÏÖÀà
        /// </summary>
        /// <returns>IOrganizationMechanismµÄʵÏÖÀà</returns>
        public static IOrganizationMechanism GetMechanism()
        {
            OguPermissionSettings oguPermissionSettings = OguPermissionSettings.GetConfig();

            return(oguPermissionSettings.OguFactory);
            //return OguPermissionSettings.GetConfig().OguFactory;
        }
コード例 #2
0
        public RoleCollection GetUserRoles(IApplication application, IUser user)
        {
            application.NullCheck("application");
            user.NullCheck("user");

            //原来是按照ID进行权限判断,现在改成根据配置文件决定(沈峥)
            string        userID    = user.ID;
            UserValueType valueType = UserValueType.Guid;

            if (OguPermissionSettings.GetConfig().RoleRelatedUserParentDept&& user.FullPath.IsNotEmpty())
            {
                userID    = user.FullPath;
                valueType = UserValueType.AllPath;
            }

            bool includeMatrixUsers = ServiceBrokerContext.Current.Context.GetValue("includeMatrixUsers", true);

            DataTable table = AppAdminServiceBroker.Instance.GetUserRoles2(
                userID,
                application.CodeName,
                valueType,
                RightMaskType.App,
                DelegationMaskType.All,
                includeMatrixUsers).Tables[0];

            RoleCollection roles = new RoleCollection(BuildObjectsFromTable <IRole>(table));

            if (application != null)
            {
                roles.ForEach(r => ((RoleImpl)r).Application = application);
            }

            return(roles);
        }
コード例 #3
0
        /// <summary>
        /// 根据codeName得到应用对象
        /// </summary>
        /// <param name="codeName">应用的codeName</param>
        /// <param name="throwNotExistsApp">不存在App时,是否抛出异常</param>
        /// <returns>应用对象</returns>
        protected IApplication GetApplication(string codeName, bool throwNotExistsApp)
        {
            IApplication app = null;

            lock (applicationDict)
            {
                if (applicationDict.TryGetValue(codeName, out app) == false)
                {
                    ApplicationCollection apps = OguPermissionSettings.GetConfig().PermissionFactory.GetApplications(codeName);

                    if (throwNotExistsApp)
                    {
                        ExceptionHelper.FalseThrow(apps.Count > 0, Resource.CanNotFindObject, codeName);
                    }

                    if (apps.Count == 0)
                    {
                        app = null;
                    }
                    else
                    {
                        app = apps[0];

                        applicationDict.Add(codeName, app);
                    }
                }
            }

            return(app);
        }
コード例 #4
0
        /// <summary>
        /// 得到该部门的子成员
        /// </summary>
        /// <typeparam name="T">子成员的类型</typeparam>
        /// <param name="includeSideLine">是否包含兼职</param>
        /// <param name="searchLevel">是否递归</param>
        /// <returns>该部门的子成员</returns>
        protected virtual OguObjectCollection <T> GetChildren <T>(bool includeSideLine, SearchLevel searchLevel) where T : IOguObject
        {
            OguObjectCollection <T> result = OguPermissionSettings.GetConfig().OguObjectImpls.GetChildren <T>(this, includeSideLine, searchLevel);

            NormalizeChildrenFullPath(this, result);

            return(result);
        }
コード例 #5
0
        private PermissionCollection GetUserAppPermissions(IApplication app)
        {
            PermissionCollection permissions = null;

            lock (userAppPermissions)
            {
                if (userAppPermissions.TryGetValue(app, out permissions) == false)
                {
                    permissions = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserPermissions(app, User);
                    userAppPermissions.Add(app, permissions);
                }
            }

            return(permissions);
        }
コード例 #6
0
        private RoleCollection GetUserAppRoles(IApplication app)
        {
            RoleCollection roles = null;

            lock (this.userAppRoles)
            {
                if (this.userAppRoles.TryGetValue(app, out roles) == false)
                {
                    roles = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserRoles(app, User);
                    this.userAppRoles.Add(app, roles);
                }
            }

            return(roles);
        }
コード例 #7
0
        /// <summary>
        /// 得到所有应用的权限集合
        /// </summary>
        /// <returns></returns>
        public Dictionary <IApplication, PermissionCollection> GetAllAppPermissions()
        {
            ApplicationCollection allApps = OguPermissionSettings.GetConfig().PermissionFactory.GetAllApplications();

            lock (this.userAppPermissions)
            {
                foreach (IApplication app in allApps)
                {
                    if (this.userAppPermissions.ContainsKey(app) == false)
                    {
                        PermissionCollection permissions = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserPermissions(app, User);
                        this.userAppPermissions.Add(app, permissions);
                    }
                }
            }

            return(this.userAppPermissions);
        }
コード例 #8
0
        /// <summary>
        /// 初始化Broker的属性
        /// </summary>
        protected override void InitProperties()
        {
            OguPermissionSettings settings = OguPermissionSettings.GetConfig();

            this.Timeout        = settings.Timeout;
            this.UseLocalCache  = settings.UseLocalCache;
            this.UseServerCache = settings.UseServerCache;

            foreach (OguConnectionMappingElement cm in settings.ConnectionMappings)
            {
                this.ConnectionMappings[cm.Name] = cm.Destination;
            }

            if (TenantContext.Current.TenantCode.IsNotEmpty())
            {
                this.Context["TenantCode"] = TenantContext.Current.TenantCode;
            }
        }
コード例 #9
0
ファイル: Common.cs プロジェクト: ounata/AK47-2016Source
        public static List <T> BuildObjectsFromTable <T>(DataTable table, IOrganization parent) where T : IOguObject
        {
            List <T> list = new List <T>();

            foreach (DataRow row in table.Rows)
            {
                SchemaType type;

                if (row.Table.Columns.Contains("OBJECTCLASS"))
                {
                    type = (SchemaType)Enum.Parse(typeof(SchemaType), row["OBJECTCLASS"].ToString(), true);

                    if (type == SchemaType.Organizations)
                    {
                        if (row.Table.Columns.Contains("ACCESS_LEVEL") || (parent != null && parent is IOrganizationInRole))
                        {
                            type = SchemaType.OrganizationsInRole;
                        }
                    }
                }
                else
                {
                    type = OguObjectHelper.GetSchemaTypeFromInterface <T>();
                }

                IOguObject baseObject = OguPermissionSettings.GetConfig().OguObjectFactory.CreateObject(type);

                if (baseObject is OguBaseImpl)
                {
                    OguBaseImpl oBase = (OguBaseImpl)baseObject;

                    oBase.InitProperties(row);

                    if (oBase is IOrganizationInRole && (parent != null && parent is IOrganizationInRole))
                    {
                        ((OguOrganizationInRoleImpl)oBase).AccessLevel = ((IOrganizationInRole)parent).AccessLevel;
                    }
                }

                list.Add((T)(baseObject as object));
            }

            return(list);
        }
コード例 #10
0
        private static List <T> BuildObjectsFromTable <T>(DataTable table) where T : IPermissionObject
        {
            List <T> list = new List <T>();

            foreach (DataRow row in table.Rows)
            {
                IPermissionObject baseObject = OguPermissionSettings.GetConfig().PermissionObjectFactory.CreateObject(typeof(T));

                if (baseObject is PermissionObjBaseImpl)
                {
                    PermissionObjBaseImpl oBase = (PermissionObjBaseImpl)baseObject;
                    oBase.InitProperties(row);

                    list.Add((T)(oBase as object));
                }
            }

            return(list);
        }
コード例 #11
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]);
        }
コード例 #12
0
        public List <IRole> GetAllUserRoles(IUser user)
        {
            user.NullCheck("user");

            //原来是按照ID进行权限判断,现在改成根据配置文件决定(沈峥)
            string        userID    = user.ID;
            UserValueType valueType = UserValueType.Guid;

            if (OguPermissionSettings.GetConfig().RoleRelatedUserParentDept)
            {
                userID    = user.FullPath;
                valueType = UserValueType.AllPath;
            }

            DataTable table = AppAdminServiceBroker.Instance.GetUserRoles(
                userID,
                string.Empty,
                valueType,
                RightMaskType.App,
                DelegationMaskType.All).Tables[0];

            return(BuildObjectsFromTable <IRole>(table));
        }
コード例 #13
0
 private AppAdminServiceBroker()
 {
     ServiceBrokerContext.Current.InitWebClientProtocol(this);
     this.Url = OguPermissionSettings.GetConfig().AppAdminServiceAddress.ToString();
 }
コード例 #14
0
 /// <summary>
 /// µÃµ½ÊÚȨʵÏÖÀà
 /// </summary>
 /// <returns>IPermissionMechanismµÄʵÏÖÀà</returns>
 public static IPermissionMechanism GetMechanism()
 {
     return(OguPermissionSettings.GetConfig().PermissionFactory);
 }
コード例 #15
0
 /// <summary>
 /// 查询子成员
 /// </summary>
 /// <typeparam name="T">子成员的类型</typeparam>
 /// <param name="matchString">查询串</param>
 /// <param name="includeSideLine">是否包含兼职</param>
 /// <param name="level">是否递归查找</param>
 /// <param name="returnCount">返回的记录数</param>
 /// <returns>查询结果</returns>
 public OguObjectCollection <T> QueryChildren <T>(string matchString, bool includeSideLine, SearchLevel level, int returnCount) where T : IOguObject
 {
     return(OguPermissionSettings.GetConfig().OguObjectImpls.QueryChildren <T>(this, matchString, includeSideLine, level, returnCount));
 }