/// <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; }
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)); }
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); }
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); } } } }
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)); }