示例#1
0
    protected void PopulateGrids(bool rebuildOthersGrid)
    {
        Volunteers allVolunteers = Volunteers.GetOpen();
        int        currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);

        Person    viewingPerson = Person.FromIdentity(currentUserId);
        Authority authority     = viewingPerson.GetAuthority();

        Volunteers geoVolunteers            = new Volunteers();
        Volunteers directReportVolunteers   = new Volunteers();
        Volunteers vicesAndAdminsVolunteers = new Volunteers();
        Volunteers ownerVolunteers          = new Volunteers();

        Geographies authGeos       = this.GetAuthorityArea();
        People      directReports  = GetDirectReports();
        People      vicesAndAdmins = this.GetVicesAndAdmins();

        // Build lookup tables

        Dictionary <int, bool> geoLookup                 = new Dictionary <int, bool>();
        Dictionary <int, bool> directReportLookup        = new Dictionary <int, bool>();
        Dictionary <int, bool> vicesAndAdminsLookup      = new Dictionary <int, bool>();
        Dictionary <int, bool> leadsVicesAndAdminsLookup = new Dictionary <int, bool>();

        foreach (Geography geo in authGeos)
        {
            geoLookup[geo.Identity] = true;
        }

        foreach (Person person in directReports)
        {
            directReportLookup[person.Identity] = true;
        }

        foreach (Person person in vicesAndAdmins)
        {
            vicesAndAdminsLookup[person.Identity] = true;
        }

        // Build volunteer lists
        Dictionary <int, Organization> viewerOrgDict = new Dictionary <int, Organization>();

        Organizations viewerOrgsList = authority.GetOrganizations(RoleTypes.AllLocalRoleTypes);

        foreach (Organization o in viewerOrgsList)
        {
            viewerOrgDict[o.Identity] = o;
        }

        //Volunteers filteredVolunteers = new Volunteers();

        //foreach (Volunteer volunteer in allVolunteers)
        //{
        //    try
        //    {
        //        Person p = volunteer.Person;
        //        filteredVolunteers.Add(volunteer);
        //    }
        //    catch
        //    {
        //    }
        //}

        //allVolunteers = filteredVolunteers;


        foreach (Volunteer volunteer in allVolunteers)
        {
            try
            {
                bool hasAuthority = false;
                // Only show geoVolunteers that volounteered for an org where viewer have a role.
                // (This is currently always PP)
                // Unless it is directly assigned.

                foreach (VolunteerRole rle in volunteer.Roles)
                {
                    if (viewerOrgDict.ContainsKey(rle.OrganizationId))
                    {
                        hasAuthority = true;
                        break;
                    }
                }

                if (hasAuthority && geoLookup.ContainsKey(volunteer.Geography.Identity))
                {
                    geoVolunteers.Add(volunteer);

                    /* Fix for the viewing users volunteers showing up in more than one list */
                    // BROKEN FIX -- this caused only one volunteer to be displayed, EVER, and delayed
                    // volunteer processing by several days -RF
                    //break;
                }

                // If directly assigned to me show regardless of org.
                if (volunteer.OwnerPersonId == currentUserId)
                {
                    ownerVolunteers.Add(volunteer);
                }

                if (hasAuthority && directReportLookup.ContainsKey(volunteer.OwnerPersonId))
                {
                    directReportVolunteers.Add(volunteer);
                }

                if (hasAuthority && vicesAndAdminsLookup.ContainsKey(volunteer.OwnerPersonId))
                {
                    vicesAndAdminsVolunteers.Add(volunteer);
                }
            }
            finally
            {
                // DEBUG USE ONLY - INTENTIONALLY NO EFFECT
            }
        }

        if (rebuildOthersGrid)
        {
            geoVolunteers.Remove(ownerVolunteers);
            geoVolunteers.Remove(directReportVolunteers);
            geoVolunteers.Remove(vicesAndAdminsVolunteers);
            this.GridOther.DataSource = geoVolunteers;
        }
        this.GridLeadGeography.DataSource = vicesAndAdminsVolunteers;
        this.GridReports.DataSource       = directReportVolunteers;
        this.GridOwner.DataSource         = ownerVolunteers;
    }
示例#2
0
    protected void PopulateGrids (bool rebuildOthersGrid)
    {
        Volunteers allVolunteers = Volunteers.GetOpen();
        int currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);

        Person viewingPerson = Person.FromIdentity(currentUserId);
        Authority authority = viewingPerson.GetAuthority();

        Volunteers geoVolunteers = new Volunteers();
        Volunteers directReportVolunteers = new Volunteers();
        Volunteers vicesAndAdminsVolunteers = new Volunteers();
        Volunteers ownerVolunteers = new Volunteers();

        Geographies authGeos = this.GetAuthorityArea();
        People directReports = GetDirectReports();
        People vicesAndAdmins = this.GetVicesAndAdmins();

        // Build lookup tables

        Dictionary<int, bool> geoLookup = new Dictionary<int, bool>();
        Dictionary<int, bool> directReportLookup = new Dictionary<int, bool>();
        Dictionary<int, bool> vicesAndAdminsLookup = new Dictionary<int, bool>();
        Dictionary<int, bool> leadsVicesAndAdminsLookup = new Dictionary<int, bool>();

        foreach (Geography geo in authGeos)
        {
            geoLookup[geo.Identity] = true;
        }

        foreach (Person person in directReports)
        {
            directReportLookup[person.Identity] = true;
        }

        foreach (Person person in vicesAndAdmins)
        {
            vicesAndAdminsLookup[person.Identity] = true;
        }

        // Build volunteer lists
        Dictionary<int, Organization> viewerOrgDict = new Dictionary<int, Organization>();

        Organizations viewerOrgsList = authority.GetOrganizations(RoleTypes.AllLocalRoleTypes );
        foreach (Organization o in viewerOrgsList)
            viewerOrgDict[o.Identity]= o;

        //Volunteers filteredVolunteers = new Volunteers();

        //foreach (Volunteer volunteer in allVolunteers)
        //{
        //    try
        //    {
        //        Person p = volunteer.Person;
        //        filteredVolunteers.Add(volunteer);
        //    }
        //    catch
        //    {
        //    }
        //}

        //allVolunteers = filteredVolunteers;


        foreach (Volunteer volunteer in allVolunteers)
        {
            try
            {
                bool hasAuthority = false;
                // Only show geoVolunteers that volounteered for an org where viewer have a role.
                // (This is currently always PP)
                // Unless it is directly assigned.

                foreach (VolunteerRole rle in volunteer.Roles)
                {
                    if (viewerOrgDict.ContainsKey(rle.OrganizationId))
                    {
                        hasAuthority = true;
                        break;
                    }
                }

                if (hasAuthority && geoLookup.ContainsKey(volunteer.Geography.Identity))
                {

                    geoVolunteers.Add(volunteer);

                    /* Fix for the viewing users volunteers showing up in more than one list */
                    // BROKEN FIX -- this caused only one volunteer to be displayed, EVER, and delayed
                    // volunteer processing by several days -RF
                    //break;
                }

                // If directly assigned to me show regardless of org.
                if (volunteer.OwnerPersonId == currentUserId)
                {
                    ownerVolunteers.Add(volunteer);
                }

                if (hasAuthority && directReportLookup.ContainsKey(volunteer.OwnerPersonId))
                {
                    directReportVolunteers.Add(volunteer);
                }

                if (hasAuthority && vicesAndAdminsLookup.ContainsKey(volunteer.OwnerPersonId))
                {
                    vicesAndAdminsVolunteers.Add(volunteer);
                }
            }
            finally
            {
                // DEBUG USE ONLY - INTENTIONALLY NO EFFECT
            }
        }

        if (rebuildOthersGrid)
        {
            geoVolunteers.Remove(ownerVolunteers);
            geoVolunteers.Remove(directReportVolunteers);
            geoVolunteers.Remove(vicesAndAdminsVolunteers);
            this.GridOther.DataSource = geoVolunteers;
        }
        this.GridLeadGeography.DataSource = vicesAndAdminsVolunteers;
        this.GridReports.DataSource = directReportVolunteers;
        this.GridOwner.DataSource = ownerVolunteers;
    }