// TODO: Needs the improvement - to get existing items from cache and the rest from the database using one call. internal static ArrayList GetActionIdList(ArrayList groupIdList, ArrayList roleIdList, Guid instanceId, Guid organizationId, bool isOrgAdmin) { ArrayList list = new ArrayList(); list.AddRange(ActionProvider.GetActionIdList(roleIdList, false, false)); if (groupIdList.Count > 0) { groupIdList.Sort(); foreach (Guid roleId in roleIdList) { list.AddRange(ActionProvider.GetActionIdListByRoleId(roleId)); } if (roleIdList.Count > 0) { list = Support.RemoveDuplicates(list); } SortedList list2 = GetGroupsInstanceActionIdList(organizationId, groupIdList, instanceId); if (list2 != null) { foreach (Guid actionId in list2.Keys) { if ((bool)list2[actionId]) { if (!list.Contains(actionId)) { list.Add(actionId); } } else if (list.Contains(actionId)) { list.Remove(actionId); } } } } if (isOrgAdmin) { list.AddRange(ActionProvider.GetActionIdListByRoleId(RoleProvider.OrganizationAdministratorRoleId)); } list = Support.RemoveDuplicates(list); return(list); }
/// <summary> /// Gets the identifiers of actions associated with specified group role in specified instance. /// </summary> /// <param name="groupId">The group's identifier.</param> /// <param name="instanceId">The instance's identifier.</param> /// <param name="roleId">The group's role identifier in specified instance.</param> /// <returns>The System.Collections.ArrayList that contains identifiers of actions associated with specified group role in specified instance.</returns> internal static ArrayList GetActionIdList(Guid groupId, Guid instanceId, Guid roleId) { ArrayList list = ActionProvider.GetActionIdListByRoleId(roleId); foreach (ClientDataSet.GroupsInstancesActionsRow actionRow in GetGroupsInstancesActionsByGroupIdInstanceId(UserContext.Current.OrganizationId, groupId, instanceId)) { Guid actionId = actionRow.ActionId; if (!actionRow.Enabled) { list.Remove(actionId); } else { list.Add(actionId); } } return(list); }
/// <summary> /// Modifies the actions list associated with specified group role in specified instance. /// </summary> /// <param name="groupId">The group's identifier.</param> /// <param name="instanceId">The instance's identifier.</param> /// <param name="actionIdList">The ArrayList that contains identifiers of actions.</param> internal static void GroupsInstancesActionsAcceptChanges(Guid groupId, Guid instanceId, ArrayList actionIdList) { UserContext user = UserContext.Current; Guid roleId = GetGroupInstanceRole(user.OrganizationId, groupId, instanceId); if (roleId == Guid.Empty) { return; } ArrayList list = ActionProvider.GetActionIdListByRoleId(roleId); ClientDataSet.GroupsInstancesActionsDataTable giaTable = null; using (GroupsInstancesActionsTableAdapter adapter = new GroupsInstancesActionsTableAdapter(OrganizationProvider.GetConnectionString(user.OrganizationId))) { giaTable = adapter.GetGroupsInstancesActionsByGroupIdInstanceId(user.OrganizationId, groupId, instanceId); foreach (ClientDataSet.GroupsInstancesActionsRow actionRow in giaTable) { Guid actionId = actionRow.ActionId; if (actionIdList.Contains(actionId)) { if (!actionRow.Enabled) { actionRow.Delete(); } else { actionIdList.Remove(actionId); } } else if (actionRow.Enabled) { actionRow.Delete(); } } ClientDataSet.GroupsInstancesActionsRow newActionRow = null; foreach (Guid actionId in list) { if (!actionIdList.Contains(actionId)) { newActionRow = giaTable.FindByGroupIdInstanceIdActionId(groupId, instanceId, actionId); if (newActionRow == null) { newActionRow = giaTable.NewGroupsInstancesActionsRow(); newActionRow.GroupId = groupId; newActionRow.InstanceId = instanceId; newActionRow.ActionId = actionId; newActionRow.Enabled = false; giaTable.AddGroupsInstancesActionsRow(newActionRow); } else if (newActionRow.Enabled) { newActionRow.Enabled = false; } } else { actionIdList.Remove(actionId); } } foreach (Guid actionId in actionIdList) { if (!list.Contains(actionId)) { newActionRow = giaTable.FindByGroupIdInstanceIdActionId(groupId, instanceId, actionId); if (newActionRow == null) { newActionRow = giaTable.NewGroupsInstancesActionsRow(); newActionRow.GroupId = groupId; newActionRow.InstanceId = instanceId; newActionRow.ActionId = actionId; newActionRow.Enabled = true; giaTable.AddGroupsInstancesActionsRow(newActionRow); } else if (!newActionRow.Enabled) { newActionRow.Enabled = true; } } } adapter.Update(giaTable); } RemoveGroupInstanceActionIdListFromCache(groupId, instanceId); }