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


C# GroupService.LoadAttributes方法代码示例

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


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

示例1: ShowDetail

        /// <summary>
        /// Shows the detail.
        /// </summary>
        private void ShowDetail()
        {
            var rockContext = new RockContext();
            var groupMemberService = new GroupMemberService( rockContext );
            var attributeValueService = new AttributeValueService( rockContext );

            if ( CurrentPerson != null )
            {
                var personId = CurrentPerson.Id;

                // Setup Image
                string imgTag = Rock.Model.Person.GetPersonPhotoImageTag( CurrentPerson, 200, 200 );
                if ( CurrentPerson.PhotoId.HasValue )
                {
                    lImage.Text = string.Format( "<a href='{0}'>{1}</a>", CurrentPerson.PhotoUrl, imgTag );
                }
                else
                {
                    lImage.Text = imgTag;
                }

                // Person Info
                lName.Text = CurrentPerson.FullName;
                if ( CurrentPerson.BirthDate.HasValue )
                {
                    lAge.Text = string.Format( "{0}<small>({1})</small><br/>", CurrentPerson.FormatAge(), CurrentPerson.BirthYear != DateTime.MinValue.Year ? CurrentPerson.BirthDate.Value.ToShortDateString() : CurrentPerson.BirthDate.Value.ToMonthDayString() );
                }

                lGender.Text = CurrentPerson.Gender != Gender.Unknown ? CurrentPerson.Gender.ToString() : string.Empty;
                lGrade.Text = CurrentPerson.GradeFormatted;
                lMaritalStatus.Text = CurrentPerson.MaritalStatusValueId.DefinedValue();
                if ( CurrentPerson.AnniversaryDate.HasValue )
                {
                    lMaritalStatus.Text += string.Format( " {0} yrs <small>({1})</small>", CurrentPerson.AnniversaryDate.Value.Age(), CurrentPerson.AnniversaryDate.Value.ToMonthDayString() );
                }

                if ( CurrentPerson.GetFamilies().Count() > 1 )
                {
                    ddlGroup.Visible = true;
                }

                // Contact Info
                if ( CurrentPerson.PhoneNumbers != null )
                {
                    var selectedPhoneTypeGuids = GetAttributeValue( "PhoneNumbers" ).Split( ',' ).AsGuidList();
                    rptPhones.DataSource = CurrentPerson.PhoneNumbers.Where( pn => selectedPhoneTypeGuids.Contains( pn.NumberTypeValue.Guid ) ).ToList();
                    rptPhones.DataBind();
                }

                lEmail.Text = CurrentPerson.Email;

                // Person Attributes
                List<Guid> attributeGuidList = GetPersonAttributeGuids( personId );
                CurrentPerson.LoadAttributes();
                rptPersonAttributes.DataSource = CurrentPerson.Attributes.Where( a =>
                     attributeGuidList.Contains( a.Value.Guid ) )
                    .Select( a => new
                    {
                        Name = a.Value.Name,
                        Value = a.Value.FieldType.Field.FormatValue( null, CurrentPerson.GetAttributeValue( a.Key ), a.Value.QualifierValues, a.Value.FieldType.Class == typeof( Rock.Field.Types.ImageFieldType ).FullName )
                    } )
                    .OrderBy( av => av.Name )
                    .ToList()
                    .Where( av => !String.IsNullOrWhiteSpace( av.Value ) );
                rptPersonAttributes.DataBind();

                // Families
                if ( GetAttributeValue( "ShowFamilyMembers" ).AsBoolean() )
                {
                    if ( ddlGroup.SelectedValueAsId().HasValue )
                    {
                        var group = new GroupService( rockContext ).Get( ddlGroup.SelectedValueAsId().Value );
                        if ( group != null )
                        {

                            // Family Name
                            lGroupName.Text = group.Name;

                            // Family Address
                            Guid? locationTypeGuid = GetAttributeValue( "AddressType" ).AsGuidOrNull();
                            if ( locationTypeGuid.HasValue )
                            {
                                var addressTypeDv = DefinedValueCache.Read( locationTypeGuid.Value );

                                var familyGroupTypeGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuidOrNull();

                                if ( familyGroupTypeGuid.HasValue )
                                {
                                    var familyGroupType = GroupTypeCache.Read( familyGroupTypeGuid.Value );

                                    var address = new GroupLocationService( rockContext ).Queryable()
                                                        .Where( l => l.Group.GroupTypeId == familyGroupType.Id
                                                             && l.GroupLocationTypeValueId == addressTypeDv.Id
                                                             && l.Group.Members.Any( m => m.PersonId == CurrentPerson.Id )
                                                             && l.Group.Id == group.Id )
                                                        .Select( l => l.Location )
                                                        .FirstOrDefault();
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:PublicProfileEdit.ascx.cs

示例2: LoadViewState

        /// <summary>
        /// Restores the view-state information from a previous user control request that was saved by the <see cref="M:System.Web.UI.UserControl.SaveViewState" /> method.
        /// </summary>
        /// <param name="savedState">An <see cref="T:System.Object" /> that represents the user control state to be restored.</param>
        protected override void LoadViewState( object savedState )
        {
            base.LoadViewState( savedState );

            if ( IsEditingGroup == true )
            {
                Group group = new GroupService( new RockContext() ).Get( _groupId );
                group.LoadAttributes();

                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls( group, phAttributes, false, BlockValidationGroup );
            }

            if ( IsEditingGroupMember == true )
            {
                RockContext rockContext = new RockContext();
                GroupMemberService groupMemberService = new GroupMemberService( rockContext );

                var groupMember = groupMemberService.Get( this.CurrentGroupMemberId );

                if ( groupMember == null )
                {
                    groupMember = new GroupMember { Id = 0 };
                    groupMember.GroupId = _groupId;
                    groupMember.Group = new GroupService( rockContext ).Get( groupMember.GroupId );
                    groupMember.GroupRoleId = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
                    groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                }

                // set attributes
                groupMember.LoadAttributes();
                phGroupMemberAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls( groupMember, phGroupMemberAttributes, true, string.Empty, true );
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:39,代码来源:GroupDetailLava.ascx.cs

示例3: btnSave_Click


//.........这里部分代码省略.........
                                            History.EvaluateChange(
                                                changes,
                                                string.Format( "{0} Phone", DefinedValueCache.GetName( phoneNumberTypeId ) ),
                                                oldPhoneNumber,
                                                phoneNumber.NumberFormattedWithCountryCode );
                                        }
                                    }
                                }
                            }

                            // Remove any blank numbers
                            var phoneNumberService = new PhoneNumberService( rockContext );
                            foreach ( var phoneNumber in person.PhoneNumbers
                                .Where( n => n.NumberTypeValueId.HasValue && !phoneNumberTypeIds.Contains( n.NumberTypeValueId.Value ) )
                                .ToList() )
                            {
                                History.EvaluateChange(
                                    changes,
                                    string.Format( "{0} Phone", DefinedValueCache.GetName( phoneNumber.NumberTypeValueId ) ),
                                    phoneNumber.ToString(),
                                    string.Empty );

                                person.PhoneNumbers.Remove( phoneNumber );
                                phoneNumberService.Delete( phoneNumber );
                            }

                            History.EvaluateChange( changes, "Email", person.Email, tbEmail.Text );
                            person.Email = tbEmail.Text.Trim();

                            var newEmailPreference = rblEmailPreference.SelectedValue.ConvertToEnum<EmailPreference>();
                            History.EvaluateChange( changes, "Email Preference", person.EmailPreference, newEmailPreference );
                            person.EmailPreference = newEmailPreference;

                            person.LoadAttributes();
                            Rock.Attribute.Helper.GetEditValues( phPersonAttributes, person );

                            if ( person.IsValid )
                            {
                                if ( rockContext.SaveChanges() > 0 )
                                {
                                    if ( changes.Any() )
                                    {
                                        HistoryService.SaveChanges(
                                            rockContext,
                                            typeof( Person ),
                                            Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(),
                                            person.Id,
                                            changes );
                                    }

                                    if ( orphanedPhotoId.HasValue )
                                    {
                                        BinaryFileService binaryFileService = new BinaryFileService( rockContext );
                                        var binaryFile = binaryFileService.Get( orphanedPhotoId.Value );
                                        if ( binaryFile != null )
                                        {
                                            // marked the old images as IsTemporary so they will get cleaned up later
                                            binaryFile.IsTemporary = true;
                                            rockContext.SaveChanges();
                                        }
                                    }

                                    // if they used the ImageEditor, and cropped it, the uncropped file is still in BinaryFile. So clean it up
                                    if ( imgPhoto.CropBinaryFileId.HasValue )
                                    {
                                        if ( imgPhoto.CropBinaryFileId != person.PhotoId )
开发者ID:NewSpring,项目名称:Rock,代码行数:67,代码来源:PublicProfileEdit.ascx.cs


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