/// <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; }
internal static void AppendResourcesToNotifiers(IWfActivity currentActivity, UserTaskCollection notifyTasks, WfResourceDescriptorCollection resources) { foreach (IUser user in resources.ToUsers()) { UserTask task = BuildOneUserNotifyFromActivity(currentActivity); task.SendToUserID = user.ID; task.SendToUserName = user.DisplayName; notifyTasks.Add(task); } }
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); }
/// <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); }
internal static void AppendResourcesToNotifiers(IWfActivity currentActivity, UserTaskCollection notifyTasks, WfResourceDescriptorCollection resources) { foreach (IUser user in resources.ToUsers()) { UserTask task = BuildOneUserNotifyFromActivity(currentActivity); task.SendToUserID = user.ID; task.SendToUserName = user.DisplayName; notifyTasks.Add(task); } }
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)); }