当前位置: 首页>>代码示例>>C#>>正文


C# Group.LoadAttributes方法代码示例

本文整理汇总了C#中Group.LoadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Group.LoadAttributes方法的具体用法?C# Group.LoadAttributes怎么用?C# Group.LoadAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group.LoadAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnInit

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );

            _rockContext = new RockContext();

            int groupId = PageParameter( "GroupId" ).AsInteger();
            _group = new GroupService( _rockContext )
                .Queryable( "GroupLocations" ).AsNoTracking()
                .FirstOrDefault( g => g.Id == groupId );

            if ( _group != null && _group.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
            {
                _group.LoadAttributes( _rockContext );
                _canView = true;

                rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;
                gOccurrences.DataKeyNames = new string[] { "Date", "ScheduleId", "LocationId" };
                gOccurrences.Actions.AddClick += gOccurrences_Add;
                gOccurrences.GridRebind += gOccurrences_GridRebind;
                gOccurrences.RowDataBound += gOccurrences_RowDataBound;

                // make sure they have Auth to edit the block OR edit to the Group
                bool canEditBlock = IsUserAuthorized( Authorization.EDIT ) || _group.IsAuthorized( Authorization.EDIT, this.CurrentPerson );
                gOccurrences.Actions.ShowAdd = canEditBlock && GetAttributeValue( "AllowAdd" ).AsBoolean();
                gOccurrences.IsDeleteEnabled = canEditBlock;
            }

            _allowCampusFilter = GetAttributeValue( "AllowCampusFilter" ).AsBoolean();
            bddlCampus.Visible = _allowCampusFilter;
            if ( _allowCampusFilter )
            {
                bddlCampus.DataSource = CampusCache.All();
                bddlCampus.DataBind();
                bddlCampus.Items.Insert( 0, new ListItem( "All Campuses", "0" ) );
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:41,代码来源:GroupAttendanceList.ascx.cs

示例2: GetGroup

        /// <summary>
        /// Gets or sets the group.
        /// </summary>
        /// <value>
        /// The group.
        /// </value>
        public Group GetGroup()
        {
            EnsureChildControls();
            Group result = new Group();

            result.Id = _hfGroupTypeId.ValueAsInt();
            result.Guid = new Guid( _hfGroupGuid.Value );
            result.GroupTypeId = _hfGroupTypeId.ValueAsInt();

            // get the current InheritedGroupTypeId from the Parent Editor just in case it hasn't been saved to the database
            CheckinGroupTypeEditor checkinGroupTypeEditor = this.Parent as CheckinGroupTypeEditor;
            if ( checkinGroupTypeEditor != null )
            {
                result.GroupType = new GroupType();
                result.GroupType.Id = result.GroupTypeId;
                result.GroupType.Guid = checkinGroupTypeEditor.GroupTypeGuid;
                result.GroupType.InheritedGroupTypeId = checkinGroupTypeEditor.InheritedGroupTypeId;
            }

            result.Name = _tbGroupName.Text;
            result.LoadAttributes();

            // populate groupLocations with whatever is currently in the grid, with just enough info to repopulate it and save it later
            result.GroupLocations = new List<GroupLocation>();
            foreach ( var item in this.Locations )
            {
                var groupLocation = new GroupLocation();
                groupLocation.LocationId = item.LocationId;
                groupLocation.Location = new Location { Id = item.LocationId, Name = item.Name };
                result.GroupLocations.Add( groupLocation );
            }

            Rock.Attribute.Helper.GetEditValues( _phGroupAttributes, result );
            return result;
        }
开发者ID:jondhinkle,项目名称:Rock,代码行数:41,代码来源:CheckinGroupEditor.cs

示例3: AddGroups

        /// <summary>
        /// Handles adding groups from the given XML element snippet.
        /// </summary>
        /// <param name="elemGroups">The elem groups.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <exception cref="System.NotSupportedException"></exception>
        private void AddGroups( XElement elemGroups, RockContext rockContext )
        {
            // Add groups
            if ( elemGroups == null )
            {
                return;
            }

            GroupService groupService = new GroupService( rockContext );
            DefinedTypeCache smallGroupTopicType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.SMALL_GROUP_TOPIC.AsGuid() );

            // Next create the group along with its members.
            foreach ( var elemGroup in elemGroups.Elements( "group" ) )
            {
                Guid guid = elemGroup.Attribute( "guid" ).Value.Trim().AsGuid();
                string type = elemGroup.Attribute( "type" ).Value;
                Group group = new Group()
                {
                    Guid = guid,
                    Name = elemGroup.Attribute( "name" ).Value.Trim(),
                    IsActive = true,
                    IsPublic = true
                };

                // skip any where there is no group type given -- they are invalid entries.
                if ( string.IsNullOrEmpty( elemGroup.Attribute( "type" ).Value.Trim() ) )
                {
                    return;
                }

                int? roleId;
                GroupTypeCache groupType;
                switch ( elemGroup.Attribute( "type" ).Value.Trim() )
                {
                    case "serving":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SERVING_TEAM.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    case "smallgroup":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SMALL_GROUP.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    default:
                        throw new NotSupportedException( string.Format( "unknown group type {0}", elemGroup.Attribute( "type" ).Value.Trim() ) );
                }

                if ( elemGroup.Attribute( "description" ) != null )
                {
                    group.Description = elemGroup.Attribute( "description" ).Value;
                }

                if ( elemGroup.Attribute( "parentGroupGuid" ) != null )
                {
                    var parentGroup = groupService.Get( elemGroup.Attribute( "parentGroupGuid" ).Value.AsGuid() );
                    if ( parentGroup != null )
                    {
                        group.ParentGroupId = parentGroup.Id;
                    }
                }

                // Set the group's meeting location
                if ( elemGroup.Attribute( "meetsAtHomeOfFamily" ) != null )
                {
                    int meetingLocationValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_MEETING_LOCATION.AsGuid() ).Id;
                    var groupLocation = new GroupLocation()
                    {
                        IsMappedLocation = false,
                        IsMailingLocation = false,
                        GroupLocationTypeValueId = meetingLocationValueId,
                        LocationId = _familyLocationDictionary[elemGroup.Attribute( "meetsAtHomeOfFamily" ).Value.AsGuid()],
                    };

                    // Set the group location's GroupMemberPersonId if given (required?)
                    if ( elemGroup.Attribute( "meetsAtHomeOfPerson" ) != null )
                    {
                        groupLocation.GroupMemberPersonAliasId = _peopleAliasDictionary[elemGroup.Attribute( "meetsAtHomeOfPerson" ).Value.AsGuid()];
                    }

                    group.GroupLocations.Add( groupLocation );
                }

                group.LoadAttributes( rockContext );

                // Set the study topic
                if ( elemGroup.Attribute( "studyTopic" ) != null )
                {
                    var topic = elemGroup.Attribute( "studyTopic" ).Value;
                    DefinedValue smallGroupTopicDefinedValue = _smallGroupTopicDefinedType.DefinedValues.FirstOrDefault( a => a.Value == topic );

                    // add it as new if we didn't find it.
                    if ( smallGroupTopicDefinedValue == null )
                    {
//.........这里部分代码省略.........
开发者ID:NewPointe,项目名称:Rockit,代码行数:101,代码来源:SampleData.ascx.cs

示例4: DeleteGroupAndMemberData

        /// <summary>
        /// Generic method to delete the members of a group and then the group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <exception cref="System.InvalidOperationException">Unable to delete group:  + group.Name</exception>
        private void DeleteGroupAndMemberData( Group group, RockContext rockContext )
        {
            GroupService groupService = new GroupService( rockContext );

            // delete addresses
            GroupLocationService groupLocationService = new GroupLocationService( rockContext );
            if ( group.GroupLocations.Count > 0 )
            {
                foreach ( var groupLocations in group.GroupLocations.ToList() )
                {
                    group.GroupLocations.Remove( groupLocations );
                    groupLocationService.Delete( groupLocations );
                }
            }

            // delete members
            var groupMemberService = new GroupMemberService( rockContext );
            var members = group.Members;
            foreach ( var member in members.ToList() )
            {
                group.Members.Remove( member );
                groupMemberService.Delete( member );
            }

            // delete attribute values
            group.LoadAttributes( rockContext );
            if ( group.AttributeValues != null )
            {
                var attributeValueService = new AttributeValueService( rockContext );
                foreach ( var entry in group.AttributeValues )
                {
                    var attributeValue = attributeValueService.GetByAttributeIdAndEntityId( entry.Value.AttributeId, group.Id );
                    if ( attributeValue != null )
                    {
                        attributeValueService.Delete( attributeValue );
                    }
                }
            }

            // now delete the group
            if ( groupService.Delete( group ) )
            {
                // ok
            }
            else
            {
                throw new InvalidOperationException( "Unable to delete group: " + group.Name );
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:55,代码来源:SampleData.ascx.cs

示例5: ShowGroupTypeEditDetails

        /// <summary>
        /// Shows the group type edit details.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        private void ShowGroupTypeEditDetails( GroupTypeCache groupType, Group group, bool setValues )
        {
            if ( group != null )
            {
                // Save value to viewstate for use later when binding location grid
                AllowMultipleLocations = groupType != null && groupType.AllowMultipleLocations;

                if ( groupType != null && groupType.LocationSelectionMode != GroupLocationPickerMode.None )
                {
                    wpLocations.Visible = true;
                    wpLocations.Title = AllowMultipleLocations ? "Locations" : "Location";
                    BindLocationsGrid();
                }
                else
                {
                    wpLocations.Visible = false;
                }

                phGroupAttributes.Controls.Clear();
                group.LoadAttributes();

                if ( group.Attributes != null && group.Attributes.Any() )
                {
                    wpGroupAttributes.Visible = true;
                    Rock.Attribute.Helper.AddEditControls( group, phGroupAttributes, setValues, "GroupDetail" );
                }
                else
                {
                    wpGroupAttributes.Visible = false;
                }
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:38,代码来源:GroupDetail.ascx.cs

示例6: ShowReadonlyDetails

        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowReadonlyDetails( Group group )
        {
            SetEditMode( false );
            var rockContext = new RockContext();

            string groupIconHtml = !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) ?
                groupIconHtml = string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass ) : string.Empty;

            hfGroupId.SetValue( group.Id );
            lGroupIconHtml.Text = groupIconHtml;
            lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();

            hlInactive.Visible = !group.IsActive;
            hlType.Text = group.GroupType.Name;

            lGroupDescription.Text = group.Description;

            DescriptionList descriptionList = new DescriptionList();

            if ( group.ParentGroup != null )
            {
                descriptionList.Add( "Parent Group", group.ParentGroup.Name );
            }

            if ( group.Campus != null )
            {
                hlCampus.Visible = true;
                hlCampus.Text = group.Campus.Name;
            }
            else
            {
                hlCampus.Visible = false;
            }

            lblMainDetails.Text = descriptionList.Html;

            var attributes = new List<Rock.Web.Cache.AttributeCache>();

            // Get the attributes inherited from group type
            GroupType groupType = new GroupTypeService( rockContext ).Get( group.GroupTypeId );
            groupType.LoadAttributes();
            attributes = groupType.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();

            // Combine with the group attributes
            group.LoadAttributes();
            attributes.AddRange( group.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ) );

            // display attribute values
            var attributeCategories = Helper.GetAttributeCategories( attributes );
            Rock.Attribute.Helper.AddDisplayControls( group, attributeCategories, phAttributes );

            // Get Map Style
            phMaps.Controls.Clear();
            var mapStyleValue = DefinedValueCache.Read( GetAttributeValue( "MapStyle" ) );
            if ( mapStyleValue == null )
            {
                mapStyleValue = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.MAP_STYLE_ROCK );
            }

            if ( mapStyleValue != null )
            {
                string mapStyle = mapStyleValue.GetAttributeValue( "StaticMapStyle" );

                if ( !string.IsNullOrWhiteSpace( mapStyle ) )
                {
                    // Get all the group locations and group all those that have a geo-location into either points or polygons
                    var points = new List<GroupLocation>();
                    var polygons = new List<GroupLocation>();
                    foreach ( GroupLocation groupLocation in group.GroupLocations )
                    {
                        if ( groupLocation.Location != null )
                        {
                            if ( groupLocation.Location.GeoPoint != null )
                            {
                                points.Add( groupLocation );
                            }
                            else if ( groupLocation.Location.GeoFence != null )
                            {
                                polygons.Add( groupLocation );
                            }
                        }
                    }

                    if ( points.Any() )
                    {
                        foreach ( var groupLocation in points )
                        {
                            string markerPoints = string.Format( "{0},{1}", groupLocation.Location.GeoPoint.Latitude, groupLocation.Location.GeoPoint.Longitude );
                            string mapLink = System.Text.RegularExpressions.Regex.Replace( mapStyle, @"\{\s*MarkerPoints\s*\}", markerPoints );
                            mapLink = System.Text.RegularExpressions.Regex.Replace( mapLink, @"\{\s*PolygonPoints\s*\}", string.Empty );
                            mapLink += "&sensor=false&size=350x200&zoom=13&format=png";
                            var literalcontrol = new Literal()
                            {
                                Text = string.Format(
                                "<div class='group-location-map'>{0}<img src='{1}'/></div>",
                                groupLocation.GroupLocationTypeValue != null ? ( "<h4>" + groupLocation.GroupLocationTypeValue.Name + "</h4>" ) : string.Empty,
//.........这里部分代码省略.........
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:101,代码来源:GroupDetail.ascx.cs

示例7: ShowReadonlyDetails

        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowReadonlyDetails( Group group )
        {
            SetEditMode( false );

            string groupIconHtml = !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) ?
                groupIconHtml = string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass ) : "";

            hfGroupId.SetValue( group.Id );
            lGroupIconHtml.Text = groupIconHtml;
            lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();

            hlInactive.Visible = !group.IsActive;
            hlType.Text = group.GroupType.Name;

            lGroupDescription.Text = group.Description;

            DescriptionList descriptionList = new DescriptionList();

            if ( group.ParentGroup != null )
            {
                descriptionList.Add( "Parent Group", group.ParentGroup.Name );
            }

            if ( group.Campus != null )
            {
                hlCampus.Visible = true;
                hlCampus.Text = group.Campus.Name;
            }
            else
            {
                hlCampus.Visible = false;
            }


            lblMainDetails.Text = descriptionList.Html;

            var attributes = new List<Rock.Web.Cache.AttributeCache>();

            // Get the attributes inherited from group type
            GroupType groupType = new GroupTypeService().Get( group.GroupTypeId );
            groupType.LoadAttributes();
            attributes = groupType.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();

            // Combine with the group attributes
            group.LoadAttributes();
            attributes.AddRange( group.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ) );

            // display attribute values
            var attributeCategories = Helper.GetAttributeCategories( attributes );
            Rock.Attribute.Helper.AddDisplayControls( group, attributeCategories, phAttributes );

            // Get all the group locations and group all those that have a geo-location into either points or polygons
            var points = new List<GroupLocation>();
            var polygons = new List<GroupLocation>();
            foreach ( GroupLocation groupLocation in group.GroupLocations )
            {
                if ( groupLocation.Location != null )
                {
                    if ( groupLocation.Location.GeoPoint != null )
                    {
                        points.Add( groupLocation );
                    }
                    else if ( groupLocation.Location.GeoFence != null )
                    {
                        polygons.Add( groupLocation );
                    }
                }
            }

            var dict = new Dictionary<string, object>();
            if ( points.Any() )
            {
                var pointsList = new List<Dictionary<string, object>>();
                foreach ( var groupLocation in points)
                {
                    var pointsDict = new Dictionary<string, object>();
                    if ( groupLocation.GroupLocationTypeValue != null )
                    {
                        pointsDict.Add( "type", groupLocation.GroupLocationTypeValue.Name );
                    }
                    pointsDict.Add( "latitude", groupLocation.Location.GeoPoint.Latitude );
                    pointsDict.Add( "longitude", groupLocation.Location.GeoPoint.Longitude );
                    pointsList.Add( pointsDict );
                }
                dict.Add( "points", pointsList );
            }

            if ( polygons.Any() )
            {
                var polygonsList = new List<Dictionary<string, object>>();
                foreach ( var groupLocation in polygons )
                {
                    var polygonDict = new Dictionary<string, object>();
                    if ( groupLocation.GroupLocationTypeValue != null )
                    {
                        polygonDict.Add( "type", groupLocation.GroupLocationTypeValue.Name );
//.........这里部分代码省略.........
开发者ID:pkdevbox,项目名称:Rock,代码行数:101,代码来源:GroupDetail.ascx.cs

示例8: ShowGroupTypeEditDetails

        /// <summary>
        /// Shows the group type edit details.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        private void ShowGroupTypeEditDetails( GroupTypeCache groupType, Group group, bool setValues )
        {
            if ( group != null )
            {
                // Save value to viewstate for use later when binding location grid
                AllowMultipleLocations = groupType != null && groupType.AllowMultipleLocations;

                // show/hide group sync panel based on permissions from the group type
                if ( group.GroupTypeId != 0 )
                {
                    using ( var rockContext = new RockContext() )
                    {
                        GroupType selectedGroupType = new GroupTypeService( rockContext ).Get( group.GroupTypeId );
                        if ( selectedGroupType != null )
                        {
                            wpGroupSync.Visible = selectedGroupType.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
                        }
                    }
                }

                if ( groupType != null && groupType.LocationSelectionMode != GroupLocationPickerMode.None )
                {
                    wpMeetingDetails.Visible = true;
                    gLocations.Visible = true;
                    BindLocationsGrid();
                }
                else
                {
                    wpMeetingDetails.Visible = pnlSchedule.Visible;
                    gLocations.Visible = false;
                }

                gLocations.Columns[2].Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );
                spSchedules.Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );

                phGroupAttributes.Controls.Clear();
                group.LoadAttributes();

                if ( group.Attributes != null && group.Attributes.Any() )
                {
                    wpGroupAttributes.Visible = true;
                    Rock.Attribute.Helper.AddEditControls( group, phGroupAttributes, setValues, BlockValidationGroup );
                }
                else
                {
                    wpGroupAttributes.Visible = false;
                }
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:55,代码来源:GroupDetail.ascx.cs

示例9: AddGroups

        /// <summary>
        /// Handles adding groups from the given XML element snippet.
        /// </summary>
        /// <param name="elemGroups">The elem groups.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <exception cref="System.NotSupportedException"></exception>
        private void AddGroups( XElement elemGroups, RockContext rockContext )
        {
            // Add groups
            if ( elemGroups == null )
            {
                return;
            }

            GroupService groupService = new GroupService( rockContext );

            // Next create the group along with its members.
            foreach ( var elemGroup in elemGroups.Elements( "group" ) )
            {
                Guid guid = elemGroup.Attribute( "guid" ).Value.Trim().AsGuid();
                string type = elemGroup.Attribute( "type" ).Value;
                Group group = new Group()
                {
                    Guid = guid,
                    Name = elemGroup.Attribute( "name" ).Value.Trim()
                };

                // skip any where there is no group type given -- they are invalid entries.
                if ( string.IsNullOrEmpty( elemGroup.Attribute( "type" ).Value.Trim() ) )
                {
                    return;
                }

                int? roleId;
                GroupTypeCache groupType;
                switch ( elemGroup.Attribute( "type" ).Value.Trim() )
                {
                    case "serving":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SERVING_TEAM.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    case "smallgroup":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SMALL_GROUP.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    default:
                        throw new NotSupportedException( string.Format( "unknown group type {0}", elemGroup.Attribute( "type" ).Value.Trim() ) );
                }

                if ( elemGroup.Attribute( "description" ) != null )
                {
                    group.Description = elemGroup.Attribute( "description" ).Value;
                }

                if ( elemGroup.Attribute( "parentGroupGuid" ) != null )
                {
                    var parentGroup = groupService.Get( elemGroup.Attribute( "parentGroupGuid" ).Value.AsGuid() );
                    group.ParentGroupId = parentGroup.Id;
                }

                // Set the group's meeting location
                if ( elemGroup.Attribute( "meetsAtHomeOfFamily" ) != null )
                {
                    int meetingLocationValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_MEETING_LOCATION.AsGuid() ).Id;
                    var groupLocation = new GroupLocation()
                    {
                        IsMappedLocation = false,
                        IsMailingLocation = false,
                        GroupLocationTypeValueId = meetingLocationValueId,
                        LocationId = _familyLocationDictionary[elemGroup.Attribute( "meetsAtHomeOfFamily" ).Value.AsGuid()],
                    };

                    // Set the group location's GroupMemberPersonId if given (required?)
                    if ( elemGroup.Attribute( "meetsAtHomeOfPerson" ) != null )
                    {
                        groupLocation.GroupMemberPersonId = _peopleDictionary[elemGroup.Attribute( "meetsAtHomeOfPerson" ).Value.AsGuid()];
                    }

                    group.GroupLocations.Add( groupLocation );
                }

                group.LoadAttributes();

                // Set the study topic
                if ( elemGroup.Attribute( "studyTopic" ) != null )
                {
                    group.SetAttributeValue( "StudyTopic", elemGroup.Attribute( "studyTopic" ).Value );
                }

                // Set the meeting time
                if ( elemGroup.Attribute( "meetingTime" ) != null )
                {
                    group.SetAttributeValue( "MeetingTime", elemGroup.Attribute( "meetingTime" ).Value );
                }

                // Add each person as a member
                foreach ( var elemPerson in elemGroup.Elements( "person" ) )
                {
//.........这里部分代码省略.........
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:101,代码来源:SampleData.ascx.cs

示例10: ShowGroupTypeEditDetails

        /// <summary>
        /// Shows the group type edit details.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        private void ShowGroupTypeEditDetails( GroupTypeCache groupType, Group group, bool setValues )
        {
            if ( group != null )
            {
                // Save value to viewstate for use later when binding location grid
                AllowMultipleLocations = groupType != null && groupType.AllowMultipleLocations;

                if ( groupType != null && groupType.LocationSelectionMode != GroupLocationPickerMode.None )
                {
                    wpMeetingDetails.Visible = true;
                    gLocations.Visible = true;
                    BindLocationsGrid();
                }
                else
                {
                    wpMeetingDetails.Visible = pnlSchedule.Visible;
                    gLocations.Visible = false;
                }

                gLocations.Columns[2].Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );
                spSchedules.Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );

                phGroupAttributes.Controls.Clear();
                group.LoadAttributes();

                if ( group.Attributes != null && group.Attributes.Any() )
                {
                    wpGroupAttributes.Visible = true;
                    Rock.Attribute.Helper.AddEditControls( group, phGroupAttributes, setValues, BlockValidationGroup );
                }
                else
                {
                    wpGroupAttributes.Visible = false;
                }
            }
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:42,代码来源:GroupDetail.ascx.cs

示例11: AddGroups

        /// <summary>
        /// Handles adding groups from the given XML element snippet.
        /// </summary>
        /// <param name="elemGroups">The elem groups.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <exception cref="System.NotSupportedException"></exception>
        private void AddGroups( XElement elemGroups, RockContext rockContext )
        {
            // Add groups
            if ( elemGroups == null )
            {
                return;
            }

            GroupService groupService = new GroupService( rockContext );

            // Next create the group along with its members.
            foreach ( var elemGroup in elemGroups.Elements( "group" ) )
            {
                Guid guid = elemGroup.Attribute( "guid" ).Value.Trim().AsGuid();
                string type = elemGroup.Attribute( "type" ).Value;
                Group group = new Group()
                {
                    Guid = guid,
                    Name = elemGroup.Attribute( "name" ).Value.Trim()
                };

                // skip any where there is no group type given -- they are invalid entries.
                if ( string.IsNullOrEmpty( elemGroup.Attribute( "type" ).Value.Trim() ) )
                {
                    return;
                }

                int? roleId;
                GroupTypeCache groupType;
                switch ( elemGroup.Attribute( "type" ).Value.Trim() )
                {
                    case "serving":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SERVING_TEAM.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    case "smallgroup":
                        groupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_SMALL_GROUP.AsGuid() );
                        group.GroupTypeId = groupType.Id;
                        roleId = groupType.DefaultGroupRoleId;
                        break;
                    default:
                        throw new NotSupportedException( string.Format( "unknown group type {0}", elemGroup.Attribute( "type" ).Value.Trim() ) );
                }

                if ( elemGroup.Attribute( "description" ) != null )
                {
                    group.Description = elemGroup.Attribute( "description" ).Value;
                }

                if ( elemGroup.Attribute( "parentGroupGuid" ) != null )
                {
                    var parentGroup = groupService.Get( elemGroup.Attribute( "parentGroupGuid" ).Value.AsGuid() );
                    group.ParentGroupId = parentGroup.Id;
                }

                // Set the group's meeting location
                if ( elemGroup.Attribute( "meetsAtHomeOfFamily" ) != null )
                {
                    int meetingLocationValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_MEETING_LOCATION.AsGuid() ).Id;
                    var groupLocation = new GroupLocation()
                    {
                        IsMappedLocation = false,
                        IsMailingLocation = false,
                        GroupLocationTypeValueId = meetingLocationValueId,
                        LocationId = _familyLocationDictionary[elemGroup.Attribute( "meetsAtHomeOfFamily" ).Value.AsGuid()],
                    };

                    // Set the group location's GroupMemberPersonId if given (required?)
                    if ( elemGroup.Attribute( "meetsAtHomeOfPerson" ) != null )
                    {
                        groupLocation.GroupMemberPersonId = _peopleDictionary[elemGroup.Attribute( "meetsAtHomeOfPerson" ).Value.AsGuid()];
                    }

                    group.GroupLocations.Add( groupLocation );
                }

                group.LoadAttributes( rockContext );

                // Set the study topic
                if ( elemGroup.Attribute( "studyTopic" ) != null )
                {
                    group.SetAttributeValue( "StudyTopic", elemGroup.Attribute( "studyTopic" ).Value );
                }

                // Set the meeting time
                if ( elemGroup.Attribute( "meetingTime" ) != null )
                {
                    group.SetAttributeValue( "MeetingTime", elemGroup.Attribute( "meetingTime" ).Value );
                }

                // Add each person as a member
                foreach ( var elemPerson in elemGroup.Elements( "person" ) )
                {
//.........这里部分代码省略.........
开发者ID:Ganon11,项目名称:Rock,代码行数:101,代码来源:SampleData.ascx.cs

示例12: ShowReadonlyDetails

        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowReadonlyDetails( Group group )
        {
            SetHighlightLabelVisibility( group, true );
            SetEditMode( false );
            var rockContext = new RockContext();

            string groupIconHtml = string.Empty;
            if ( group.GroupType != null )
            {
                groupIconHtml = !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) ?
                    string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass ) : string.Empty;
                hlType.Text = group.GroupType.Name;
            }

            hfGroupId.SetValue( group.Id );
            lGroupIconHtml.Text = groupIconHtml;
            lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();

            pdAuditDetails.SetEntity( group, ResolveRockUrl( "~" ) );

            if ( !string.IsNullOrWhiteSpace( group.Description ) )
            {
                lGroupDescription.Text = string.Format( "<p class='description'>{0}</p>", group.Description );
            }

            DescriptionList descriptionList = new DescriptionList();

            if ( group.ParentGroup != null )
            {
                descriptionList.Add( "Parent Group", group.ParentGroup.Name );
            }

            if ( group.RequiredSignatureDocumentTemplate != null )
            {
                descriptionList.Add( "Required Signed Document", group.RequiredSignatureDocumentTemplate.Name );
            }

            if ( group.Schedule != null )
            {
                descriptionList.Add( "Schedule", group.Schedule.ToString() );
            }

            if ( group.Campus != null )
            {
                hlCampus.Visible = true;
                hlCampus.Text = group.Campus.Name;
            }
            else
            {
                hlCampus.Visible = false;
            }

            // configure group capacity
            nbGroupCapacityMessage.Visible = false;
            if ( group.GroupType != null && group.GroupType.GroupCapacityRule != GroupCapacityRule.None )
            {
                // check if we're over capacity and if so show warning
                if ( group.GroupCapacity.HasValue )
                {
                    int activeGroupMemberCount = group.Members.Where( m => m.GroupMemberStatus == GroupMemberStatus.Active ).Count();
                    if ( activeGroupMemberCount > group.GroupCapacity )
                    {
                        nbGroupCapacityMessage.Text = string.Format( "This group is over capacity by {0}.", "individual".ToQuantity((activeGroupMemberCount - group.GroupCapacity.Value)) );
                        nbGroupCapacityMessage.Visible = true;

                        if ( group.GroupType != null && group.GroupType.GroupCapacityRule == GroupCapacityRule.Hard )
                        {
                            nbGroupCapacityMessage.NotificationBoxType = NotificationBoxType.Danger;
                        }
                    }

                    descriptionList.Add( "Capacity", group.GroupCapacity.ToString() );
                }
            }

            lblMainDetails.Text = descriptionList.Html;

            group.LoadAttributes();
            var attributes = group.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();

            var attributeCategories = Helper.GetAttributeCategories( attributes );

            Rock.Attribute.Helper.AddDisplayControls( group, attributeCategories, phAttributes, null, false );

            var pageParams = new Dictionary<string, string>();
            pageParams.Add( "GroupId", group.Id.ToString() );

            hlAttendance.Visible = group.GroupType != null && group.GroupType.TakesAttendance;
            hlAttendance.NavigateUrl = LinkedPageUrl( "AttendancePage", pageParams );

            string groupMapUrl = LinkedPageUrl( "GroupMapPage", pageParams );

            var registrations = new Dictionary<int, string>();
            var eventItemOccurrences = new Dictionary<int, string>();
            var contentItems = new Dictionary<int, string>();

//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:GroupDetail.ascx.cs

示例13: CreateGroupAttributeControls

        /// <summary>
        /// Creates the group attribute controls.
        /// </summary>
        public void CreateGroupAttributeControls( Group group )
        {
            // get the current InheritedGroupTypeId from the Parent Editor just in case it hasn't been saved to the database
            CheckinGroupTypeEditor checkinGroupTypeEditor = this.Parent as CheckinGroupTypeEditor;
            if ( checkinGroupTypeEditor != null )
            {
                group.GroupType = new GroupType();
                group.GroupType.Id = group.GroupTypeId;
                group.GroupType.InheritedGroupTypeId = checkinGroupTypeEditor.InheritedGroupTypeId;
            }

            if ( group.Attributes == null )
            {
                group.LoadAttributes();
            }

            _phGroupAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls( group, _phGroupAttributes, true );
        }
开发者ID:jondhinkle,项目名称:Rock,代码行数:22,代码来源:CheckinGroupEditor.cs

示例14: OnInit

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );

            _rockContext = new RockContext();

            _group = new GroupService( _rockContext ).Get( PageParameter( "GroupId" ).AsInteger() );
            if ( _group != null && _group.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
            {
                _group.LoadAttributes( _rockContext );
                _canView = true;

                gOccurrences.DataKeyNames = new string[] { "StartDateTime" };
                gOccurrences.Actions.AddClick += gOccurrences_Add;
                gOccurrences.GridRebind += gOccurrences_GridRebind;

                // make sure they have Auth to edit the block OR edit to the Group
                bool canEditBlock = IsUserAuthorized( Authorization.EDIT ) || _group.IsAuthorized( Authorization.EDIT, this.CurrentPerson );
                gOccurrences.Actions.ShowAdd = canEditBlock && GetAttributeValue("AllowAdd").AsBoolean();
                gOccurrences.IsDeleteEnabled = canEditBlock;

            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:27,代码来源:GroupAttendanceList.ascx.cs

示例15: SetGroupTypeOptions

        /// <summary>
        /// Binds the group attribute list.
        /// </summary>
        private void SetGroupTypeOptions()
        {
            cblSchedule.Visible = false;

            // Rebuild the checkbox list settings for both the filter and display in grid attribute lists
            cblAttributes.Items.Clear();
            cblGridAttributes.Items.Clear();

            if ( gtpGroupType.SelectedGroupTypeId.HasValue )
            {
                var groupType = GroupTypeCache.Read( gtpGroupType.SelectedGroupTypeId.Value );
                if ( groupType != null )
                {
                    cblSchedule.Visible = ( groupType.AllowedScheduleTypes & ScheduleType.Weekly ) == ScheduleType.Weekly;

                    var group = new Group();
                    group.GroupTypeId = groupType.Id;
                    group.LoadAttributes();
                    foreach ( var attribute in group.Attributes )
                    {
                        if ( attribute.Value.FieldType.Field.HasFilterControl() )
                        {
                            cblAttributes.Items.Add( new ListItem( attribute.Value.Name, attribute.Value.Guid.ToString() ) );
                        }
                        cblGridAttributes.Items.Add( new ListItem( attribute.Value.Name, attribute.Value.Guid.ToString() ) );
                    }
                }
            }

            cblAttributes.Visible = cblAttributes.Items.Count > 0;
            cblGridAttributes.Visible = cblAttributes.Items.Count > 0;
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:35,代码来源:GroupFinder.ascx.cs


注:本文中的Group.LoadAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。