/// <summary>
		/// 获取所有管理员用户信息
		/// </summary>
		/// <returns></returns>
		public static IEnumerable<IUser> GetAllUsers()
		{
			/*
			RolesDefineConfig rolesConfig = RolesDefineConfig.GetConfig().;

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

			foreach (RolesDefine roleDefine in rolesConfig.RolesDefineCollection)
			{
				roleNames.Add(roleDefine.Name);
			}
			               
			IRole[] roles = rolesConfig.GetRolesInstances(roleNames.ToArray()); */

			IRole[] roles = RolesDefineConfig.GetConfig().RolesDefineCollection["ProcessAdmin"].GetRolesInstances();

			Dictionary<string, IUser> allUsers = new Dictionary<string, IUser>();

			foreach (IRole role in roles)
			{
				WfRoleResourceDescriptor roleDescriptor = new WfRoleResourceDescriptor(role);
				WfResourceDescriptorCollection roleDescriptors = new WfResourceDescriptorCollection(roleDescriptor);
				roleDescriptors.Add(roleDescriptor);

				OguDataCollection<IUser> roleUsers = roleDescriptors.ToUsers();

				foreach (IUser user in roleUsers)
				{
					if (allUsers.ContainsKey(user.ID) == false)
						allUsers.Add(user.ID, user);
				}
			}

			return allUsers.Values;
		}
Beispiel #2
0
        public void WfEmptyUserDynamicResourceDescriptorTest()
        {
            WfRuntime.ProcessContext.EvaluateDynamicResourceCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateDynamicResourceCondition);

            WfResourceDescriptorCollection resources = new WfResourceDescriptorCollection();

            WfDynamicResourceDescriptor resource = new WfDynamicResourceDescriptor();

            resource.Condition.Expression = "EmptyUser";

            resources.Add(resource);

            OguDataCollection <IUser> users = resources.ToUsers();

            Assert.AreEqual(0, users.Count);
        }
Beispiel #3
0
        public void WfDynamicResourceDescriptorTest()
        {
            WfRuntime.ProcessContext.EvaluateDynamicResourceCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateDynamicResourceCondition);

            WfResourceDescriptorCollection resources = new WfResourceDescriptorCollection();

            WfDynamicResourceDescriptor resource = new WfDynamicResourceDescriptor();

            resource.Condition.Expression = "Requestor";

            resources.Add(resource);

            OguDataCollection <IUser> users = resources.ToUsers();

            users.ForEach(u => Console.WriteLine(u.DisplayName));
        }
Beispiel #4
0
        public void QueryRoleUserByContext()
        {
            SOARole role = PrepareSOARole();

            WfRoleResourceDescriptor       roleDescriptor = new WfRoleResourceDescriptor(role);
            WfResourceDescriptorCollection roles          = new WfResourceDescriptorCollection();

            roles.Add(roleDescriptor);

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["CostCenter"] = "1002";
            parameters["FormType"]   = "Form1";

            WfApplicationParametersContext.CreateContext(parameters);

            OguDataCollection <IUser> users = roles.ToUsers();

            Assert.AreEqual(4, users.Count);
        }
        public void ClientToServer(WfClientResourceDescriptorCollection client, WfResourceDescriptorCollection server)
        {
            client.NullCheck("client");
            server.NullCheck("server");

            server.Clear();

            foreach (WfClientResourceDescriptor clientRes in client)
            {
                WfClientResourceDescriptorConverterBase converter = WfClientResourceDescriptorConverterFactory.Instance.GetConverterByClientType(clientRes.GetType());

                if (converter != null)
                {
                    WfResourceDescriptor serverRes = null;

                    converter.ClientToServer(clientRes, ref serverRes);

                    if (serverRes != null)
                        server.Add(serverRes);
                }
            }
        }
        /// <summary>
        /// 获取所有管理员用户信息
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <IUser> GetAllUsers()
        {
            /*
             * RolesDefineConfig rolesConfig = RolesDefineConfig.GetConfig().;
             *
             * List<string> roleNames = new List<string>();
             *
             * foreach (RolesDefine roleDefine in rolesConfig.RolesDefineCollection)
             * {
             *      roleNames.Add(roleDefine.Name);
             * }
             *
             * IRole[] roles = rolesConfig.GetRolesInstances(roleNames.ToArray()); */

            IRole[] roles = RolesDefineConfig.GetConfig().RolesDefineCollection["ProcessAdmin"].GetRolesInstances();

            Dictionary <string, IUser> allUsers = new Dictionary <string, IUser>();

            foreach (IRole role in roles)
            {
                WfRoleResourceDescriptor       roleDescriptor  = new WfRoleResourceDescriptor(role);
                WfResourceDescriptorCollection roleDescriptors = new WfResourceDescriptorCollection(roleDescriptor);
                roleDescriptors.Add(roleDescriptor);

                OguDataCollection <IUser> roleUsers = roleDescriptors.ToUsers();

                foreach (IUser user in roleUsers)
                {
                    if (allUsers.ContainsKey(user.ID) == false)
                    {
                        allUsers.Add(user.ID, user);
                    }
                }
            }

            return(allUsers.Values);
        }
Beispiel #7
0
        public void ClientToServer(WfClientResourceDescriptorCollection client, WfResourceDescriptorCollection server)
        {
            client.NullCheck("client");
            server.NullCheck("server");

            server.Clear();

            foreach (WfClientResourceDescriptor clientRes in client)
            {
                WfClientResourceDescriptorConverterBase converter = WfClientResourceDescriptorConverterFactory.Instance.GetConverterByClientType(clientRes.GetType());

                if (converter != null)
                {
                    WfResourceDescriptor serverRes = null;

                    converter.ClientToServer(clientRes, ref serverRes);

                    if (serverRes != null)
                    {
                        server.Add(serverRes);
                    }
                }
            }
        }
Beispiel #8
0
		public void QueryRoleUserByContext()
		{
			SOARole role = PrepareSOARole();

			WfRoleResourceDescriptor roleDescriptor = new WfRoleResourceDescriptor(role);
			WfResourceDescriptorCollection roles = new WfResourceDescriptorCollection();

			roles.Add(roleDescriptor);

			Dictionary<string, object> parameters = new Dictionary<string, object>();

			parameters["CostCenter"] = "1002";
			parameters["FormType"] = "Form1";

			WfApplicationParametersContext.CreateContext(parameters);

			OguDataCollection<IUser> users = roles.ToUsers();

			Assert.AreEqual(4, users.Count);
		}
        public void WfEmptyUserDynamicResourceDescriptorTest()
        {
            WfRuntime.ProcessContext.EvaluateDynamicResourceCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateDynamicResourceCondition);

            WfResourceDescriptorCollection resources = new WfResourceDescriptorCollection();

            WfDynamicResourceDescriptor resource = new WfDynamicResourceDescriptor();

            resource.Condition.Expression = "EmptyUser";

            resources.Add(resource);

            OguDataCollection<IUser> users = resources.ToUsers();

            Assert.AreEqual(0, users.Count);
        }
        public void WfDynamicResourceDescriptorTest()
        {
            WfRuntime.ProcessContext.EvaluateDynamicResourceCondition += new Expression.CalculateUserFunction(ProcessContext_EvaluateDynamicResourceCondition);

            WfResourceDescriptorCollection resources = new WfResourceDescriptorCollection();

            WfDynamicResourceDescriptor resource = new WfDynamicResourceDescriptor();

            resource.Condition.Expression = "Requestor";

            resources.Add(resource);

            OguDataCollection<IUser> users = resources.ToUsers();

            users.ForEach(u => Console.WriteLine(u.DisplayName));
        }