protected void UserGroupsStore_ReadData(object sender, StoreReadDataEventArgs e) { string filter = string.Empty; GroupUsersListRequest req = new GroupUsersListRequest(); req.Size = "100"; req.StartAt = "0"; req.Filter = ""; req.UserId = CurrentUser.Text; //Fetching the corresponding list //in this test will take a list of News ListResponse <SecurityGroupUser> groups = _accessControlService.ChildGetAll <SecurityGroupUser>(req); if (!groups.Success) { X.Msg.Alert(Resources.Common.Error, groups.Summary).Show(); return; } this.UserGroupsStore.DataSource = groups.Items; e.Total = groups.count; this.UserGroupsStore.DataBind(); }
protected void ADDGroups(object sender, DirectEventArgs e) { GroupUsersListRequest request = new GroupUsersListRequest(); request.UserId = CurrentUser.Text; ListResponse <SecurityGroup> userGroups = _accessControlService.ChildGetAll <SecurityGroup>(request); if (!userGroups.Success) { X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", userGroups.ErrorCode) != null ? GetGlobalResourceObject("Errors", userGroups.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + userGroups.LogId : userGroups.Summary).Show(); return; } List <SecurityGroupUser> list = new List <SecurityGroupUser>(); userGroups.Items.ForEach(x => { list.Add(new SecurityGroupUser() { sgName = x.name, sgId = x.recordId, userId = CurrentUser.Text }); }); groupSelectorGroup.DataSource = list; groupSelectorGroup.DataBind(); GroupUsersListRequest req = new GroupUsersListRequest(); req.Size = "100"; req.StartAt = "0"; req.Filter = ""; req.UserId = CurrentUser.Text; ListResponse <SecurityGroupUser> groups = _accessControlService.ChildGetAll <SecurityGroupUser>(req); if (!groups.Success) { X.Msg.Alert(Resources.Common.Error, groups.Summary).Show(); return; } this.userSelector.SelectedItems.Clear(); groups.Items.ForEach(x => { this.userSelector.SelectedItems.Add(new Ext.Net.ListItem() { Value = x.userId }); }); this.userSelector.UpdateSelectedItems(); this.groupUsersWindow.Show(); }
protected void AllGroupsStore_ReadData(object sender, StoreReadDataEventArgs e) { ListRequest groupsReq = new ListRequest(); groupsReq.Size = "100"; groupsReq.StartAt = "0"; groupsReq.Filter = ""; //Fetching the corresponding list //in this test will take a list of News ListResponse <SecurityGroup> groups = _accessControlService.ChildGetAll <SecurityGroup>(groupsReq); if (!groups.Success) { X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", groups.ErrorCode) != null ? GetGlobalResourceObject("Errors", groups.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + groups.LogId : groups.Summary).Show(); return; } GroupUsersListRequest request = new GroupUsersListRequest(); request.UserId = CurrentUser.Text; ListResponse <SecurityGroupUser> userGroups = _accessControlService.ChildGetAll <SecurityGroupUser>(request); if (!groups.Success) { X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", groups.ErrorCode) != null ? GetGlobalResourceObject("Errors", groups.ErrorCode).ToString() : groups.Summary).Show(); return; } UserGroupsStore.DataSource = userGroups.Items; UserGroupsStore.DataBind(); List <SecurityGroup> availableGroups = new List <SecurityGroup>(); groups.Items.ForEach(x => { if (userGroups.Items.Where(y => y.sgId == x.recordId).Count() == 0) { availableGroups.Add(x); } }); AllGroupsStore.DataSource = availableGroups; AllGroupsStore.DataBind(); GroupsCombo.Select(0); }
protected void SaveGroupUsers(object sender, DirectEventArgs e) { try { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string selected = e.ExtraParams["selectedGroups"]; List <SecurityGroupUser> selectedUsers = JsonConvert.DeserializeObject <List <SecurityGroupUser> >(selected); selectedUsers.ForEach(x => x.userId = CurrentUser.Text); GroupUsersListRequest request = new GroupUsersListRequest(); request.UserId = CurrentUser.Text; ListResponse <SecurityGroupUser> userGroups = _accessControlService.ChildGetAll <SecurityGroupUser>(request); if (!userGroups.Success) { Common.errorMessage(userGroups); return; } PostRequest <SecurityGroupUser> req = new PostRequest <SecurityGroupUser>(); PostResponse <SecurityGroupUser> resp = new PostResponse <SecurityGroupUser>(); userGroups.Items.ForEach(x => { req.entity = x; resp = _accessControlService.ChildDelete <SecurityGroupUser>(req); if (!resp.Success) { Common.errorMessage(resp); throw new Exception(); } }); //req.entity = new SecurityGroupUser() { sgId = "0", userId = CurrentUser.Text }; //resp = _accessControlService.ChildDelete<SecurityGroupUser>(req); foreach (var item in selectedUsers) { req.entity = item; req.entity.userId = CurrentUser.Text; resp = _accessControlService.ChildAddOrUpdate <SecurityGroupUser>(req); if (!resp.Success) { Common.errorMessage(resp); throw new Exception(); } } Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); groupUsersWindow.Close(); UserGroupsStore.Reload(); } catch (Exception exp) { X.MessageBox.Alert(GetGlobalResourceObject("Common", "Error").ToString(), exp.Message); } }