Пример #1
0
 private bool AddEditUserGroupsDialog_OKClicked(UserGroupRowData userGroup)
 {
     if (AddEditUserGroupsDialog.EditMode)
     {
         // Commit the change into database
         if (_controller.UpdateUserGroup(userGroup))
         {
             UserGroupsPanel.UpdateUI();
             return true;
         }
         return false;
     }
     else
     {
         try
         {
             if (_controller.AddUserGroup(userGroup))
             {
                 UserGroupsPanel.UpdateUI();
                 return true;
             }
             return false;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Пример #2
0
 public void OnEditUserGroup(UserGroupRowData userGroupRowData)
 {
     //TODO: Rewrite this. This method is being called by the child control.
     
     AddEditUserGroupsDialog.EditMode = true;
     AddEditUserGroupsDialog.UserGroup = userGroupRowData;
     AddEditUserGroupsDialog.Show(true);
 }
Пример #3
0
        public void OnDeleteUserGroup(UserGroupRowData userGroupRowData)
        {
            //TODO: Rewrite this. This method is being called by the child control.

            DeleteConfirmation.Message = string.Format(SR.AdminUserGroups_DeleteDialog_AreYouSure, userGroupRowData.Name);
            DeleteConfirmation.MessageType = MessageBox.MessageTypeEnum.YESNO;
            DeleteConfirmation.Data = userGroupRowData;
            DeleteConfirmation.Show();
        }
Пример #4
0
        private IList<UserGroupRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array authorityRowData;
            Array authorityRowDataRange = Array.CreateInstance(typeof(UserGroupRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0) return new List<UserGroupRowData>();

            using(AuthorityManagement service = new AuthorityManagement())
            {
                IList<AuthorityGroupSummary> list = service.ListAllAuthorityGroups();
                IList<AuthorityGroupSummary> filteredList = new List<AuthorityGroupSummary>();

                if(!string.IsNullOrEmpty(GroupName))
                {
                	string matchString = GroupName;

					while (matchString.StartsWith("*") || matchString.StartsWith("?"))
						matchString = matchString.Substring(1);
					while (matchString.EndsWith("*")||matchString.EndsWith("?"))
						matchString = matchString.Substring(0, matchString.Length - 1);

					matchString = matchString.Replace("*", "[A-Za-z0-9]*");
					matchString = matchString.Replace("?", ".");

                    foreach(AuthorityGroupSummary group in list)
                    {
						if (Regex.IsMatch(group.Name,matchString,RegexOptions.IgnoreCase))
							filteredList.Add(group);
                    }
                } 
				else
                {
                    filteredList = list;
                }

                List<UserGroupRowData> rows = CollectionUtils.Map<AuthorityGroupSummary, UserGroupRowData>(
                    filteredList, delegate(AuthorityGroupSummary group)
                              {
                                  UserGroupRowData row =
                                      new UserGroupRowData(service.LoadAuthorityGroupDetail(group.AuthorityGroupRef));
                                  return row;
                              });

                authorityRowData = CollectionUtils.ToArray(rows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, authorityRowData.Length);

                Array.Copy(authorityRowData, startRowIndex, authorityRowDataRange, 0, copyLength);

                if (copyLength < authorityRowDataRange.Length)
                {
                    authorityRowDataRange = resizeArray(authorityRowDataRange, copyLength);
                }
            };

            resultCount = authorityRowData.Length;

            return CollectionUtils.Cast<UserGroupRowData>(authorityRowDataRange);
        }
Пример #5
0
        private IList <UserGroupRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array authorityRowData;
            Array authorityRowDataRange = Array.CreateInstance(typeof(UserGroupRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <UserGroupRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityGroupSummary> list         = service.ListAllAuthorityGroups();
                IList <AuthorityGroupSummary> filteredList = new List <AuthorityGroupSummary>();

                if (!string.IsNullOrEmpty(GroupName))
                {
                    string matchString = GroupName;

                    while (matchString.StartsWith("*") || matchString.StartsWith("?"))
                    {
                        matchString = matchString.Substring(1);
                    }
                    while (matchString.EndsWith("*") || matchString.EndsWith("?"))
                    {
                        matchString = matchString.Substring(0, matchString.Length - 1);
                    }

                    matchString = matchString.Replace("*", "[A-Za-z0-9]*");
                    matchString = matchString.Replace("?", ".");

                    foreach (AuthorityGroupSummary group in list)
                    {
                        if (Regex.IsMatch(group.Name, matchString, RegexOptions.IgnoreCase))
                        {
                            filteredList.Add(group);
                        }
                    }
                }
                else
                {
                    filteredList = list;
                }

                List <UserGroupRowData> rows = CollectionUtils.Map <AuthorityGroupSummary, UserGroupRowData>(
                    filteredList, delegate(AuthorityGroupSummary group)
                {
                    UserGroupRowData row =
                        new UserGroupRowData(service.LoadAuthorityGroupDetail(group.AuthorityGroupRef));
                    return(row);
                });

                authorityRowData = CollectionUtils.ToArray(rows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, authorityRowData.Length);

                Array.Copy(authorityRowData, startRowIndex, authorityRowDataRange, 0, copyLength);

                if (copyLength < authorityRowDataRange.Length)
                {
                    authorityRowDataRange = resizeArray(authorityRowDataRange, copyLength);
                }
            };

            resultCount = authorityRowData.Length;

            return(CollectionUtils.Cast <UserGroupRowData>(authorityRowDataRange));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PasswordConfirmDialog.OKClicked += PasswordConfirmDialog_OKClicked;

            if (Page.IsPostBack == false)
            {

                using (AuthorityManagement service = new AuthorityManagement())
                {
                    IList<AuthorityTokenSummary> tokens = service.ListAuthorityTokens();
                    IList<ListItem> items = CollectionUtils.Map<AuthorityTokenSummary, ListItem>(
                                            tokens,
                                            delegate(AuthorityTokenSummary token)
                                            {
                                                return new ListItem(token.Description, token.Name);
                                            });

                    TokenCheckBoxList.Items.AddRange(CollectionUtils.ToArray(items));
                };
            }
            else
            {
                if (ViewState["SaveDataGroup"] != null)
                    _saveDataGroup = (bool)ViewState["SaveDataGroup"];

                if (ViewState["EditMode"] != null)
                    _editMode = (bool) ViewState[ "EditMode"];

                if (ViewState[ "EditedUserGroup"] != null)
                    _userGroup = ViewState[ "EditedUserGroup"] as UserGroupRowData;
            }
        }
        private void SaveData()
        {
            if (UserGroup == null)
            {
                UserGroup = new UserGroupRowData();
            }

            UserGroup.Name = GroupName.Text;
            UserGroup.Description = GroupDescription.Text;
            UserGroup.DataGroup = DataGroupCheckBox.Checked;
            UserGroup.Tokens.Clear();
            foreach (ListItem item in TokenCheckBoxList.Items)
            {
                if (item.Selected)
                {
                    UserGroup.Tokens.Add(new TokenSummary(item.Value, item.Text));
                }
            }
        }
 public void DeleteUserGroup(UserGroupRowData userGroup, bool checkIfGroupIsEmpty)
 {
     using (AuthorityManagement service = new AuthorityManagement())
     {
         try
         {
             EntityRef entityRef = new EntityRef(userGroup.Ref);
             service.DeleteAuthorityGroup(entityRef, checkIfGroupIsEmpty);
         }
         catch (Exception ex)
         {
             Platform.Log(LogLevel.Error, ex, "Unexpected exception deleting user group: {0}.", userGroup.Name);
             throw;
         }
     }
 }
        public bool UpdateUserGroup(UserGroupRowData userGroup)
        {
            bool success;

            using(AuthorityManagement service = new AuthorityManagement())
        
            {
                AuthorityGroupDetail detail = new AuthorityGroupDetail
                                                  {
                                                      AuthorityGroupRef = new EntityRef(userGroup.Ref),
                                                      Name = userGroup.Name,
                                                      Description = userGroup.Description,
                                                      DataGroup = userGroup.DataGroup
                                                  };

                foreach(TokenSummary token in userGroup.Tokens)
                {
                    detail.AuthorityTokens.Add(new AuthorityTokenSummary(token.Name, token.Description));
                }

                service.UpdateAuthorityGroup(detail, userGroup.Password);
                success = true;
            }

            //TODO: Catch exception?
            return success;
        }
Пример #10
0
        public bool AddUserGroup(UserGroupRowData userGroup)
        {
            bool success;

            using(AuthorityManagement service = new AuthorityManagement())
            {
                List<AuthorityTokenSummary> tokens = new List<AuthorityTokenSummary>();

                foreach (TokenSummary token in userGroup.Tokens)
                {
                    tokens.Add(new AuthorityTokenSummary(token.Name, token.Description));
                }

                service.AddAuthorityGroup(userGroup.Name, userGroup.Description, userGroup.DataGroup, tokens);
                success = true;
            }

            //TODO: Catch exception?
            return success;
        }