Пример #1
0
        /// <summary>
        /// 创建带分支流程的模版。为了测试XElement序列化,里面需要包含角色、资源、条件等内容
        /// </summary>
        /// <returns></returns>
        public static IWfProcessDescriptor CreateProcessDescriptorForXElementSerialization()
        {
            IWfProcessDescriptor processDesp = CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfActivityDescriptor normalActivity = processDesp.Activities["NormalActivity"];

            string roleDesp = RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles;

            OguRole role = new OguRole(roleDesp);

            WfRoleResourceDescriptor roleResource = new WfRoleResourceDescriptor(role);

            normalActivity.EnterEventReceivers.Add(roleResource);

            WfDynamicResourceDescriptor dynResource = new WfDynamicResourceDescriptor();

            dynResource.Condition.Expression = "Leader";
            normalActivity.LeaveEventReceivers.Add(dynResource);

            processDesp.CancelEventReceivers.Add(dynResource);

            WfRelativeLinkDescriptor relLink = new WfRelativeLinkDescriptor("TestUrl");

            relLink.Category = "Test";
            relLink.Url      = "http://localhost/www.baidu.com";

            processDesp.RelativeLinks.Add(relLink);

            return(processDesp);
        }
		/// <summary>
		/// 是否是超级管理员
		/// </summary>
		/// <param name="principal"></param>
		/// <returns></returns>
		public static bool IsSupervisor(IPrincipal principal)
		{
			bool result = false;

			if (principal != null)
			{
				result = (bool)ObjectContextCache.Instance.GetOrAddNewValue(principal, (cache, key) =>
					{
						bool innerResult = false;

						string roleName = Configuration.AUConfigurationSection.GetConfig().MasterRoleFullCodeName;

						if (roleName.IsNotEmpty())
						{
							IRole role = new OguRole(roleName);

							if (role.ObjectsInRole.Count == 0)
								innerResult = true;
							else
								innerResult = principal.IsInRole(roleName);
						}
						else
							innerResult = true;

						cache.Add(key, innerResult);

						return innerResult;
					});
			}

			return result;
		}
        private static bool IsSuperAdmin(IPrincipal principal)
        {
            return(DEPrincipalCache.Instance.GetOrAddNewValue(principal.Identity.Name, (cache, key) =>
            {
                bool innerResult = false;
                if (ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName.IsNotEmpty())
                {
                    IRole role = new OguRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);

                    if (role.ObjectsInRole.Count == 0)
                    {
                        innerResult = true;
                    }
                    else
                    {
                        innerResult = principal.IsInRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);
                    }
                }
                else
                {
                    innerResult = true;
                }

                cache.Add(key, innerResult);

                return innerResult;
            }));
        }
		public IRole GetAdminRole()
		{
			OguRole result = null;

			if (this.AdminRoleFullCodeName.IsNotEmpty())
				result = new OguRole(this.AdminRoleFullCodeName);

			return result;
		}
        public IRole GetAdminRole()
        {
            OguRole result = null;

            if (this.AdminRoleFullCodeName.IsNotEmpty())
            {
                result = new OguRole(this.AdminRoleFullCodeName);
            }

            return(result);
        }
        /// <summary>
        /// 是否是超级管理员
        /// </summary>
        /// <param name="principal"></param>
        /// <returns></returns>
        public static bool IsSupervisor(this IPrincipal principal)
        {
            bool result = false;

            //Modified by Haoyk
            //2015-02-02
            //动态实体项目单设管理员
            if (principal != null)
            {
                result = DEPrincipalCache.Instance.GetOrAddNewValue(principal.Identity.Name, (cache, key) =>
                {
                    bool innerResult = false;

                    if (ConfigurationManager.AppSettings["DEAdmin"] != null && ConfigurationManager.AppSettings["DEAdmin"].IsNotEmpty())
                    {
                        string roleStr = ConfigurationManager.AppSettings["DEAdmin"].Trim();

                        if (string.IsNullOrEmpty(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName))
                        {
                            innerResult = true;
                        }
                        else
                        {
                            IRole role = new OguRole(ObjectSchemaSettings.GetConfig().AdminRoleFullCodeName);
                            if (role.ObjectsInRole.Count == 0)
                            {
                                innerResult = true;
                            }
                            else
                            {
                                innerResult = principal.IsInRole(roleStr);
                            }

                            //如果不属于DEAdmin,则进一步判断是否是超级管理员
                            if (innerResult == false)
                            {
                                innerResult = IsSuperAdmin(principal);
                            }
                        }
                    }
                    else
                    {
                        //如果没有配置则都认为人人都是管理员
                        innerResult = true;
                    }

                    cache.Add(key, innerResult);
                    return(innerResult);
                });
            }

            return(result);
        }
Пример #7
0
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			string fullCodeName = (string)dictionary["fullCodeName"];

			OguRole role = new OguRole(fullCodeName);

			role.ID = DictionaryHelper.GetValue(dictionary, "id", string.Empty);
			role.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty);
			role.CodeName = DictionaryHelper.GetValue(dictionary, "codeName", string.Empty);
			role.Description = DictionaryHelper.GetValue(dictionary, "description", string.Empty);

			return role;
		}
        private static WfApplicationAuth PrepareData(string appName, string progName)
        {
            WfApplicationAuth auth = new WfApplicationAuth();

            auth.ApplicationName = appName;
            auth.ProgramName = progName;
            auth.AuthType = WfApplicationAuthType.FormAdmin;

            OguRole role = new OguRole(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles);

            auth.RoleID = role.ID;
            auth.RoleDescription = role.FullCodeName;

            return auth;
        }
Пример #9
0
        private static WfApplicationAuth PrepareData(string appName, string progName)
        {
            WfApplicationAuth auth = new WfApplicationAuth();

            auth.ApplicationName = appName;
            auth.ProgramName     = progName;
            auth.AuthType        = WfApplicationAuthType.FormAdmin;

            OguRole role = new OguRole(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles);

            auth.RoleID          = role.ID;
            auth.RoleDescription = role.FullCodeName;

            return(auth);
        }
Пример #10
0
        /// <summary>
        /// 是否是超级管理员
        /// </summary>
        /// <param name="principal"></param>
        /// <returns></returns>
        public static bool IsSupervisor(IPrincipal principal)
        {
            bool result = false;

            if (principal != null)
            {
                result = (bool)ObjectContextCache.Instance.GetOrAddNewValue(principal, (cache, key) =>
                {
                    bool innerResult = false;

                    string roleName = Configuration.AUConfigurationSection.GetConfig().MasterRoleFullCodeName;

                    if (roleName.IsNotEmpty())
                    {
                        IRole role = new OguRole(roleName);

                        if (role.ObjectsInRole.Count == 0)
                        {
                            innerResult = true;
                        }
                        else
                        {
                            innerResult = principal.IsInRole(roleName);
                        }
                    }
                    else
                    {
                        innerResult = true;
                    }

                    cache.Add(key, innerResult);

                    return(innerResult);
                });
            }

            return(result);
        }
Пример #11
0
        /// <summary>
        /// 创建带分支流程的模版。为了测试XElement序列化,里面需要包含角色、资源、条件等内容
        /// </summary>
        /// <returns></returns>
        public static IWfProcessDescriptor CreateProcessDescriptorForXElementSerialization()
        {
            IWfProcessDescriptor processDesp = CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfActivityDescriptor normalActivity = processDesp.Activities["NormalActivity"];

            string roleDesp = RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles;

            OguRole role = new OguRole(roleDesp);

            WfRoleResourceDescriptor roleResource = new WfRoleResourceDescriptor(role);
            normalActivity.EnterEventReceivers.Add(roleResource);

            WfDynamicResourceDescriptor dynResource = new WfDynamicResourceDescriptor();
            dynResource.Condition.Expression = "Leader";
            normalActivity.LeaveEventReceivers.Add(dynResource);

            processDesp.CancelEventReceivers.Add(dynResource);

            WfRelativeLinkDescriptor relLink = new WfRelativeLinkDescriptor("TestUrl");

            relLink.Category = "Test";
            relLink.Url = "http://localhost/www.baidu.com";

            processDesp.RelativeLinks.Add(relLink);

            return processDesp;
        }