Ejemplo n.º 1
0
        public void LoadGroups()
        {
            groupListView.Items.Clear();
            List <CGroupEntity> groups = _currentUser.ListGroups();

            foreach (CGroupEntity group in groups)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.Text       = group.Grp_Name;
                lvi.SmallImage = new IconResourceHandle("people.gif");
                lvi.Tag        = group.Grp_Id;
                groupListView.Items.Add(lvi);
            }
        }
Ejemplo n.º 2
0
        private void FillUserLists()
        {
            // get all shared users and init list
            List <CACLEntity>   acls         = _currentUser.ListMyAcls(_resourceId);
            List <CUserEntity>  sharedUsers  = new List <CUserEntity>();
            List <CGroupEntity> sharedGroups = new List <CGroupEntity>();

            foreach (CACLEntity acl in acls)
            {
                if (acl.Acl_RType == (int)ACLROLETYPE.USERROLE && acl.Acl_Role == _currentUser.Usr_Id)
                {
                    continue;
                }

                bool added = false;
                if (acl.Acl_RType == (int)ACLROLETYPE.USERROLE)
                {
                    foreach (CUserEntity u in sharedUsers)
                    {
                        if (acl.Acl_Role == u.Usr_Id)
                        {
                            added = true;
                            break;
                        }
                    }
                    if (added)
                    {
                        continue;
                    }

                    CUserEntity user = new CUserEntity(_currentUser.ConnString).Load(acl.Acl_Role);
                    sharedUsers.Add(user);
                }
                else if (acl.Acl_RType == (int)ACLROLETYPE.GROUPROLE)
                {
                    foreach (CGroupEntity g in sharedGroups)
                    {
                        if (acl.Acl_Role == g.Grp_Id)
                        {
                            added = true;
                            break;
                        }
                    }
                    if (added)
                    {
                        continue;
                    }

                    CGroupEntity group = new CGroupEntity(_currentUser.ConnString).Load(acl.Acl_Role);
                    sharedGroups.Add(group);
                }
            }

            shareList.Items.Clear();
            foreach (CGroupEntity ug in sharedGroups)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.Text       = ug.Grp_Name;
                lvi.SmallImage = new IconResourceHandle("people.gif");
                lvi.Tag        = ug;

                shareList.Items.Add(lvi);
            }
            foreach (CUserEntity ur in sharedUsers)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.Text       = ur.Usr_Member + "[" + ur.Usr_Name + "]";
                lvi.SmallImage = new IconResourceHandle("personal.gif");
                lvi.Tag        = ur;

                shareList.Items.Add(lvi);
            }

            // get other users and fill unshared user list
            List <CUserEntity>  allUsers  = _currentUser.ListAllUsers();
            List <CGroupEntity> allGroups = _currentUser.ListGroups();

            unshareList.Items.Clear();
            foreach (CGroupEntity ug in allGroups)
            {
                bool shared = false;
                foreach (CGroupEntity group in sharedGroups)
                {
                    if (ug.Grp_Id == group.Grp_Id)
                    {
                        shared = true;
                        break;
                    }
                }
                if (shared)
                {
                    continue;
                }

                ListViewItem lvi = new ListViewItem();

                lvi.Text       = ug.Grp_Name;
                lvi.SmallImage = new IconResourceHandle("people.gif");
                lvi.Tag        = ug;

                unshareList.Items.Add(lvi);
            }
            foreach (CUserEntity ur in allUsers)
            {
                if (ur.Usr_Id == _currentUser.Usr_Id)
                {
                    continue;
                }

                bool shared = false;
                foreach (CUserEntity usr in sharedUsers)
                {
                    if (ur.Usr_Id == usr.Usr_Id)
                    {
                        shared = true;
                        break;
                    }
                }
                if (shared)
                {
                    continue;
                }

                ListViewItem lvi = new ListViewItem();

                lvi.Text       = ur.Usr_Member;
                lvi.SmallImage = new IconResourceHandle("personal.gif");
                lvi.Tag        = ur;

                unshareList.Items.Add(lvi);
            }
        }