コード例 #1
0
    public string GetRegionAccessDetails()
    {
        Person queryPerson = PersonManager.GetAllPersons().FirstOrDefault <Person>(x => x.Id.Equals(Id));
        IList <PersonRegionAccessDetail> regions    = new List <PersonRegionAccessDetail>();
        JavaScriptSerializer             serializer = new JavaScriptSerializer();

        if (queryPerson != null)
        {
            User           user1          = MembershipManager.GetUserByPerson(queryPerson);
            MembershipUser membershipUser = Membership.GetUser(user1.Name);

            if (!string.IsNullOrEmpty(membershipUser.UserName))
            {
                IList <Region> userRegions = SiteManager.GetAllRegions();
                foreach (Region region in userRegions)
                {
                    PersonRegion PR = PersonManager.GetPersonRegionByPersonAndRegion(queryPerson, region);
                    if (PR != null)
                    {
                        regions.Add(new PersonRegionAccessDetail()
                        {
                            PersonId = PR.Person.Id, LocationId = region.Id, IsView = PR.IsView, IsAdmin = PR.IsAdministrator, IsManager = PR.IsManager, Name = region.Name
                        });
                    }
                }
            }
        }
        return(serializer.Serialize(regions));
    }
コード例 #2
0
        public override void DeletePerson(string personId)
        {
            // If person regions exist.
            if (IsPersonInPersonRegion(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists in a Region");
            }

            // If person persontypes exist.
            if (IsPersonInPersonType(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists in a PersonType");
            }

            // If person personsite exist.
            if (IsPersonInPersonSite(personId))
            {
                throw new SchemaIntegrityException("Unable to delete. Person exists at a Site");
            }

            using (var transaction = new TransactionScope(_configuration))
            {
                var    ptDS   = new PersonDataStore(transaction);
                Person person = ptDS.FindByKey(personId);
                User   user   = MembershipManager.GetUserByPerson(person);
                System.Web.Security.Membership.DeleteUser(user.Name);
                person.Deleted = true;
                ptDS.Update(person);
                transaction.Commit();
            }
        }
コード例 #3
0
    public string GetSiteAccessDetails()
    {
        Person queryPerson                  = PersonManager.GetAllPersons().FirstOrDefault <Person>(x => x.Id.Equals(Id));
        IList <SiteAccessDetail> sites      = new List <SiteAccessDetail>();
        JavaScriptSerializer     serializer = new JavaScriptSerializer();

        if (queryPerson != null)
        {
            User           user1          = MembershipManager.GetUserByPerson(queryPerson);
            MembershipUser membershipUser = Membership.GetUser(user1.Name);

            if (!string.IsNullOrEmpty(membershipUser.UserName))
            {
                IList <Site> userSites = SiteManager.GetSitesByUser(membershipUser.UserName, false);

                foreach (Site site in userSites)
                {
                    PersonSite PS = PersonManager.GetPersonSiteByPersonAndSite(queryPerson, site, false);
                    sites.Add(new SiteAccessDetail()
                    {
                        PersonId = PS.Person.Id, LocationId = site.Id, IsAdmin = PS.IsAdministrator, IsManager = PS.IsManager, IsPrimary = PS.IsDefault, IsView = PS.IsAssigned, Name = site.Name
                    });
                }
            }
        }
        return(serializer.Serialize(sites));
    }
コード例 #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        PersonType editPersonType = new PersonType();

        editPersonType = PersonManager.GetPersonTypeById(GroupId);

        PersonType tempPersonType = ctrlManageGroupEdit.GetGroupDetails();

        editPersonType.Name        = tempPersonType.Name;
        editPersonType.Description = tempPersonType.Description;

        PersonManager.UpdatePersonType(editPersonType);

        UserNamesList.Clear();
        List <string> lstUsers = ctrlManageGroupEdit.GetList();

        foreach (string item in lstUsers)
        {
            UserNamesList.Add(item);
        }

        object personListObj = ViewState[PersonList];

        if (personListObj != null)
        {
            string[] personList = personListObj.ToString().Split(',');
            foreach (string personId in personList)
            {
                Person editPerson = PersonManager.GetPersonById(personId);
                User   user       = MembershipManager.GetUserByPerson(PersonManager.GetPersonById(personId));

                if (UserNamesList.Contains(user.Name))
                {
                    bool isPersonType = PersonManager.IsPersonInPersonType(editPerson, editPersonType);
                    if (!isPersonType)
                    {
                        PersonManager.AddPersonToPersonType(editPerson.Id, editPersonType.Id);
                    }
                }
                else
                {
                    bool isPersonType = PersonManager.IsPersonInPersonType(editPerson, editPersonType);
                    if (isPersonType)
                    {
                        PersonManager.DeletePersonFromPersonType(editPerson.Id, editPersonType.Id);
                    }
                }
            }
        }
        string   groupnameLink = "<a href=../Admin/EditGroup.aspx?id=" + editPersonType.Id + ">" + editPersonType.Name + "</a>";
        Feedback feedBack      = new Feedback(BusiBlocksConstants.Blocks.Administration.BlockName, "Group", Feedback.Actions.Saved, groupnameLink);

        Session["feedback"] = feedBack;

        Navigation.Admin_ManageRolesGroups().Redirect(this);
    }
コード例 #5
0
    public void DisplayPersonDetails(Person person)
    {
        User           user1          = MembershipManager.GetUserByPerson(person);
        MembershipUser membershipUser = Membership.GetUser(user1.Name);

        txtFirstName.Text  = person.FirstName;
        txtLastName.Text   = person.LastName;
        txtPosition.Text   = person.Position;
        txtWorkEmail.Text  = person.Email;
        txtWorkFax.Text    = person.WorkFax;
        txtWorkMobile.Text = person.WorkMobile;
        txtWorkPhone.Text  = person.WorkPhone;
        txtUserId.Text     = membershipUser.UserName;
    }
コード例 #6
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "add")
        {
            string personId = (string)e.CommandArgument;

            Person person = PersonManager.GetPersonById(personId);
            User   user   = MembershipManager.GetUserByPerson(person);

            if (lstUsers.Items.FindByText(user.Name) == null)
            {
                lstUsers.Items.Add(user.Name);
            }
        }
    }
コード例 #7
0
    protected string GetPrimarySite(string Id)
    {
        //get user and person
        Person queryPerson = PersonManager.GetPersonById(Id);
        User   user1       = MembershipManager.GetUserByPerson(queryPerson);

        //get primary site to avoid duplicate site names
        Site primarySite = PersonManager.GetDefaultSiteByPerson(queryPerson);

        if (primarySite != null && !string.IsNullOrEmpty(primarySite.Name))
        {
            return(primarySite.Name);
        }
        else
        {
            return(string.Empty);
        }
    }
コード例 #8
0
    protected void DisplayUsers(PersonType editPersonType)
    {
        ListBox listUsers = new ListBox();

        IList <Person> persons = RegionVisibilityHelper.GetPersonsForUser(Page.User.Identity.Name);

        foreach (Person person in persons)
        {
            if (PersonManager.IsPersonInPersonType(person, editPersonType) == true)
            {
                User user = MembershipManager.GetUserByPerson(person);
                listUsers.Items.Add(new ListItem(user.Name));
                UserNamesList.Add(user.Name);
            }
        }

        ctrlManageGroupEdit.SetList(listUsers);
    }
コード例 #9
0
    /// <summary>
    /// Deletes a user after confirming from Modal Popup. Accepts button's default parameters.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteUserClick(object sender, EventArgs e)
    {
        string personId = popDeleteUser.ReferrerId;

        try
        {
            Person person = PersonManager.GetPersonById(personId);
            User   user   = MembershipManager.GetUserByPerson(person);

            // Do not delete person if they are in a site or group.
            if (PersonManager.IsPersonInPersonRegion(personId) ||
                PersonManager.IsPersonInPersonSite(personId) ||
                PersonManager.IsPersonInPersonType(personId))
            {
                ((IFeedback)Page.Master).SetError(
                    GetType(),
                    Utilities.GetDisplayUserId(user.Id) + " could not be deleted because they are assigned to a Site, Region or Group"
                    );
                return;
            }

            PersonManager.DeletePerson(person.Id);

            //remove from ViewState
            List <string> personList = ViewState[PersonList].ToString().Split(',').ToList <string>();
            personList.Remove(personId);
            ViewState[PersonList] = string.Join(",", personList.ToArray());

            ((IFeedback)Master).ShowFeedback(BusiBlocksConstants.Blocks.Administration.BlockName, user.GetType().Name, Feedback.Actions.Deleted, user.Name);
            //if person deletes itself..logout him out.
            if (user.Name.Equals(Utilities.GetUserName(Page.User.Identity.Name)))
            {
                FormsAuthentication.SignOut();
                Navigation.Admin_SearchUsers().Redirect(this);
            }

            RadGrid1.MasterTableView.Rebind();
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Master).SetException(GetType(), ex);
        }
    }
コード例 #10
0
    private void RefreshData(string personId)
    {
        Person currentPerson = PersonManager.GetPersonById(personId);

        if (currentPerson != null)
        {
            User           user1          = MembershipManager.GetUserByPerson(currentPerson);
            MembershipUser membershipUser = Membership.GetUser(user1.Name);
            if (membershipUser != null)
            {
                txtUserId.Text = membershipUser.UserName;
            }
            txtFirstName.Text  = currentPerson.FirstName;
            txtLastName.Text   = currentPerson.LastName;
            txtPosition.Text   = currentPerson.Position;
            txtWorkPhone.Text  = currentPerson.WorkPhone;
            txtWorkFax.Text    = currentPerson.WorkFax;
            txtWorkEmail.Text  = currentPerson.Email;
            txtWorkMobile.Text = currentPerson.WorkMobile;
        }
    }
コード例 #11
0
    /// <summary>
    /// Gets secondary sites if any for a person
    /// </summary>
    /// <param name="id"></param>
    /// <param name="isPrimaryExisting"></param>
    /// <returns>string of secondary sites</returns>
    protected string GetSecondarySites(string id, bool isPrimaryExisting)
    {
        string secondarySites = string.Empty;
        string seperator      = string.Empty;

        seperator = (isPrimaryExisting == true) ? ", " : string.Empty;
        //get user and person
        Person queryPerson = PersonManager.GetPersonById(id);
        User   user1       = MembershipManager.GetUserByPerson(queryPerson);

        if (user1 != null && !string.IsNullOrEmpty(user1.Name))
        {
            //get primary site to avoid duplicate site names
            Site           primarySite    = PersonManager.GetDefaultSiteByPerson(queryPerson);
            MembershipUser membershipUser = Membership.GetUser(user1.Name);

            if (!string.IsNullOrEmpty(membershipUser.UserName))
            {
                IList <Site> sites = SiteManager.GetSitesByUser(membershipUser.UserName, true);

                for (int i = 0; i < sites.Count; i++)
                {
                    if (primarySite != null)
                    {
                        //check if not primary site
                        if ((primarySite.Id != sites[i].Id) && !string.IsNullOrEmpty(sites[i].Name))
                        {
                            secondarySites = CombineSites(seperator + sites[i].Name, secondarySites);
                        }
                    }
                    else
                    {
                        secondarySites = CombineSites(sites[i].Name + ((i == (sites.Count - 1)) ? string.Empty : ", "), secondarySites);
                    }
                }
            }
        }
        return(secondarySites);
    }
コード例 #12
0
    private IList <User> GetTotalUsers()
    {
        IList <User> totalUsers = new List <BusiBlocks.Membership.User>();//total number of users who have viewed the announcement
        List <User>  viewUsers  = new List <BusiBlocks.Membership.User>();

        IList <Access> accesses          = AccessManager.GetItemAccess(Item.Category.Id);
        const string   allGroupsLabel    = "All Groups";
        const string   allLocationsLabel = "All Sites";

        foreach (Access access in accesses)
        {
            PersonType personType = null;
            Site       site       = null;

            if (!string.IsNullOrEmpty(access.PersonTypeId))
            {
                personType = PersonManager.GetPersonTypeById(access.PersonTypeId);
            }
            if (!string.IsNullOrEmpty(access.SiteId))
            {
                site = SiteManager.GetSiteById(access.SiteId);
            }

            if (personType != null || site != null || access.AllSites || access.AllPersonTypes || access.AllUsers)
            {
                IList <Person> persons = PersonManager.GetAllPersons();
                foreach (Person person in persons)
                {
                    User user = MembershipManager.GetUserByPerson(person);
                    bool add  = false;
                    if (SecurityHelper.CanUserView(user.Name, Item.Category.Id))
                    {
                        if (access.AllUsers || access.AllPersonTypes || access.AllSites)
                        {
                            add = true;
                        }
                        else if (personType != null)
                        {
                            if (PersonManager.IsPersonInPersonType(person, personType))
                            {
                                add = true;
                            }
                        }
                        else if (site != null)
                        {
                            if (PersonManager.IsPersonInPersonSite(person, site))
                            {
                                add = true;
                            }
                        }
                        if (add && totalUsers.Contains(user) == false)
                        {
                            totalUsers.Add(user);
                        }
                    }
                }
            }
        }

        return(totalUsers);
    }
コード例 #13
0
    private void BindApprovers()
    {
        //get the groups under the category
        //get the users in that group
        //bind the users to the drop down

        //clear the dropdown list
        ddlApprovers.Items.Clear();
        ddlApprovers.Enabled = false;

        ddlOwner.Items.Clear();
        ddlOwner.Enabled = true;

        if (!string.IsNullOrEmpty(currentSelectedNode))
        {
            IList <Access> accessList = AccessManager.GetItemEdittables(currentSelectedNode);
            bool           canEdit    = false;

            if (SecurityHelper.CanUserEdit(Page.User.Identity.Name, currentSelectedNode))
            {
                canEdit = true;
            }
            else if (SecurityHelper.CanUserContribute(Page.User.Identity.Name, currentSelectedNode))
            {
                User currentUser = MembershipManager.GetUserByName(Page.User.Identity.Name);
                ddlOwner.Items.Add(new ListItem(currentUser.Name, currentUser.Id));
            }
            if (canEdit)
            {
                foreach (Access access in accessList)
                {
                    IList <Person> persons = PersonManager.GetAllPersons();

                    foreach (Person person in persons)
                    {
                        User user = MembershipManager.GetUserByPerson(person);
                        if (!string.IsNullOrEmpty(user.Name))
                        {
                            if (ddlOwner.Items.FindByText(user.Name) == null)
                            {
                                if (SecurityHelper.CanUserEdit(user.Name, currentSelectedNode))
                                {
                                    ddlOwner.Items.Add(new ListItem(user.Name, user.Id));
                                }
                            }

                            //APPROVERS NOT REQUIRED AT THIS RELEASE - 19/06/2012
                            //if (ddlApprovers.Items.FindByText(user.Name) == null)
                            //{
                            //    ddlApprovers.Items.Add(new ListItem(user.Name, user.Id));
                            //}
                        }
                    }
                }
            }
            //ddlApprovers.Items.Insert(0, new ListItem("--All Approvers--", ""));
            if (ddlOwner.Items.FindByText("admin") == null)
            {
                User admin = MembershipManager.GetUserByName("admin");
                ddlOwner.Items.Insert(0, new ListItem(admin.Name, admin.Id));
            }

            if ((Item != null) && (Item.Owner != null) && (ddlOwner.Items.FindByValue(Item.Owner) == null))
            {
                User currentUser = MembershipManager.GetUserByName(Item.Owner);
                ddlOwner.Items.Insert(0, new ListItem(currentUser.Name, currentUser.Id));
                ddlOwner.SelectedIndex = ddlOwner.Items.IndexOf(ddlOwner.Items.FindByText(Item.Owner));
            }
        }
    }