Пример #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();

            if(! IsPostBack)
            {
                LoadAuthorityList();
                //Populate textboxes with User's data
                User sessionUser = new User();
                sessionUser = wrapper.GetUsersWrapper(new int[]{Convert.ToInt32(Session["UserID"])})[0];

                txtUsername.Text = sessionUser.userName;
                txtFirstName.Text = sessionUser.firstName;
                txtLastName.Text = sessionUser.lastName;
                txtEmail.Text = sessionUser.email;
                txtNewPassword.Text = "";
                txtConfirmPassword.Text = "";
                ddlAuthorities.SelectedValue = sessionUser.authID.ToString();
                ddlAuthorities.Enabled = false;

                // To list all the groups a user belongs to
                int userID = Convert.ToInt32(Session["UserID"]);
                int[] groupIDs = wrapper.ListGroupsForUserWrapper (userID);

                //since we already have the groups a user has access
                // if we use wrapper here, it will deny authentication
                Group[] gps = AdministrativeAPI.GetGroups(groupIDs);
                ArrayList nonRequestGroups = new ArrayList();
                ArrayList requestGroups = new ArrayList();

                foreach(Group g in gps)
                {
                    if (g.groupName.EndsWith("request"))
                        requestGroups.Add(g);
                    else
                        if(!g.groupName.Equals("NewUserGroup"))
                        nonRequestGroups.Add(g);
                }

                //List Groups that user belongs to in blue box
                if ((nonRequestGroups!=null)&& (nonRequestGroups.Count>0))
                {
                    for (int i=0;i<nonRequestGroups.Count;i++)
                    {
                        lblGroups.Text+= ((Group)nonRequestGroups[i]).groupName;
                        if (i != nonRequestGroups.Count-1)
                            lblGroups.Text +=", ";
                    }
                }
                else
                {
                    lblGroups.Text = "No group";
                }

                //List Groups that user has requested to in blue box
                if ((requestGroups!=null)&& (requestGroups.Count>0))
                {
                    for (int i=0;i<requestGroups.Count;i++)
                    {
                        int origGroupID = AdministrativeAPI.GetAssociatedGroupID(((Group)requestGroups[i]).groupID);
                        string origGroupName = AdministrativeAPI.GetGroups(new int[] {origGroupID})[0].groupName;
                        lblRequestGroups.Text+= origGroupName;
                        if (i != requestGroups.Count-1)
                            lblRequestGroups.Text +=", ";
                    }
                }
                else
                {
                    lblRequestGroups.Text = "No group";
                }
            }
        }