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


C# Model.GroupService类代码示例

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


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

示例1: FormatValue

        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            string formattedValue = string.Empty;

            string[] parts = ( value ?? string.Empty ).Split( '|' );
            Guid? groupTypeGuid = parts[0].AsGuidOrNull();
            Guid? groupGuid = parts[1].AsGuidOrNull();
            var rockContext = new RockContext();
            if ( groupGuid.HasValue )
            {
                var group = new GroupService( rockContext ).Get( groupGuid.Value );
                if ( group != null )
                {
                    formattedValue = "Group: " + group.Name;
                }
            }
            else if ( groupTypeGuid.HasValue )
            {
                var groupType = new GroupTypeService( rockContext ).Get( groupTypeGuid.Value );
                if ( groupType != null )
                {
                    formattedValue = "Group type: " + groupType.Name;
                }
            }

            return base.FormatValue( parentControl, formattedValue, null, condensed );
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:35,代码来源:GroupTypeGroupFieldType.cs

示例2: Page_Load

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load( object sender, EventArgs e )
        {
            Exception ex = GetSavedValue( "RockLastException" ) as Exception;
            if ( ex != null )
            {
                int? errorLevel = ( GetSavedValue( "RockExceptionOrder" ) ?? "" ).ToString().AsIntegerOrNull();

                ClearSavedValue( "RockExceptionOrder" );
                ClearSavedValue( "RockLastException" );

                bool showDetails = errorLevel.HasValue && errorLevel.Value == 66;
                if ( !showDetails )
                {
                    try
                    {
                        // check to see if the user is an admin, if so allow them to view the error details
                        var userLogin = Rock.Model.UserLoginService.GetCurrentUser();
                        GroupService service = new GroupService( new RockContext() );
                        Group adminGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_ADMINISTRATORS ) );
                        showDetails = userLogin != null && adminGroup.Members.Where( m => m.PersonId == userLogin.PersonId ).Count() > 0;
                    }
                    catch { }
                }

                if ( showDetails )
                {
                    lErrorInfo.Text = "<h3>Exception Log:</h3>";
                    ProcessException( ex, " " );
                }
            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:36,代码来源:Error.aspx.cs

示例3: Execute

        /// <summary>
        /// Executes the specified workflow action.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            errorMessages = new List<string>();

            var parts = ( GetAttributeValue( action, "Group" ) ?? string.Empty ).Split( '|' );
            Guid? groupTypeGuid = null;
            Guid? groupGuid = null;
            if ( parts.Length >= 1 )
            {
                groupTypeGuid = parts[0].AsGuidOrNull();
                if ( parts.Length >= 2 )
                {
                    groupGuid = parts[1].AsGuidOrNull();
                }
            }

            if ( groupGuid.HasValue )
            {
                var group = new GroupService( rockContext ).Get( groupGuid.Value );
                if ( group != null )
                {
                    action.Activity.AssignedPersonAlias = null;
                    action.Activity.AssignedPersonAliasId = null;
                    action.Activity.AssignedGroup = group;
                    action.Activity.AssignedGroupId = group.Id;
                    action.AddLogEntry( string.Format( "Assigned activity to '{0}' group ({1})", group.Name, group.Id ) );
                    return true;
                }
            }

            return false;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:40,代码来源:AssignActivityToGroup.cs

示例4: FormatSelection

        /// <summary>
        /// Formats the selection.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override string FormatSelection( Type entityType, string selection )
        {
            string result = "Group Member";
            string[] selectionValues = selection.Split( '|' );
            if ( selectionValues.Length >= 2 )
            {
                var rockContext = new RockContext();
                var group = new GroupService( rockContext ).Get( selectionValues[0].AsGuid() );

                var groupTypeRoleGuidList = selectionValues[1].Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).Select( a => a.AsGuid() ).ToList();

                var groupTypeRoles = new GroupTypeRoleService( rockContext ).Queryable().Where( a => groupTypeRoleGuidList.Contains( a.Guid ) ).ToList();

                if ( group != null )
                {
                    result = string.Format( "Not in group: {0}", group.Name );
                    if ( groupTypeRoles.Count() > 0 )
                    {
                        result += string.Format( ", with role(s): {0}", groupTypeRoles.Select( a => a.Name ).ToList().AsDelimited( "," ) );
                    }
                }
            }

            return result;
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:31,代码来源:NotInGroupFilter.cs

示例5: Handle

 /// <summary>
 /// When overridden in a derived class, handles the exception synchronously.
 /// </summary>
 /// <param name="context">The exception handler context.</param>
 public override void Handle( ExceptionHandlerContext context )
 {
      // check to see if the user is an admin, if so allow them to view the error details
     var userLogin = Rock.Model.UserLoginService.GetCurrentUser();
     GroupService service = new GroupService( new RockContext() );
     Group adminGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_ADMINISTRATORS ) );
     context.RequestContext.IncludeErrorDetail = userLogin != null && adminGroup.Members.Where( m => m.PersonId == userLogin.PersonId ).Count() > 0;
     
     base.Handle( context );
 }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:14,代码来源:RockApiExceptionHandler.cs

示例6: GetChildren

        public IQueryable<TreeViewItem> GetChildren( int id, int rootGroupId, bool limitToSecurityRoleGroups, string groupTypeIds )
        {
            var user = CurrentUser();
            if ( user != null )
            {
                var groupService = new GroupService();
                groupService.Repository.SetConfigurationValue( "ProxyCreationEnabled", "false" );
                var qry = groupService.GetNavigationChildren( id, rootGroupId, limitToSecurityRoleGroups, groupTypeIds );

                List<Group> groupList = new List<Group>();
                List<TreeViewItem> groupNameList = new List<TreeViewItem>();

                foreach ( var group in qry )
                {
                    if ( group.IsAuthorized( "View", user.Person ) )
                    {
                        groupList.Add( group );
                        var treeViewItem = new TreeViewItem();
                        treeViewItem.Id = group.Id.ToString();
                        treeViewItem.Name = System.Web.HttpUtility.HtmlEncode( group.Name );

                        // if there a IconCssClass is assigned, use that as the Icon.
                        var groupType = Rock.Web.Cache.GroupTypeCache.Read( group.GroupTypeId );
                        if ( groupType != null )
                        {
                            treeViewItem.IconCssClass = groupType.IconCssClass;
                        }

                        groupNameList.Add( treeViewItem );
                    }
                }

                // try to quickly figure out which items have Children
                List<int> resultIds = groupList.Select( a => a.Id ).ToList();

                var qryHasChildren = from x in Get().Select( a => a.ParentGroupId )
                                     where resultIds.Contains( x.Value )
                                     select x.Value;

                var qryHasChildrenList = qryHasChildren.ToList();

                foreach ( var g in groupNameList )
                {
                    int groupId = int.Parse( g.Id );
                    g.HasChildren = qryHasChildrenList.Any( a => a == groupId );
                }

                return groupNameList.AsQueryable();
            }
            else
            {
                throw new HttpResponseException( HttpStatusCode.Unauthorized );
            }
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:54,代码来源:GroupsController.Partial.cs

示例7: SetEditValue

 /// <summary>
 /// Sets the value.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="value">The value.</param>
 public override void SetEditValue( System.Web.UI.Control control, Dictionary<string, ConfigurationValue> configurationValues, string value )
 {
     if ( value != null )
     {
         GroupPicker groupPicker = control as GroupPicker;
         int groupId = 0;
         int.TryParse( value, out groupId );
         Group group = new GroupService().Get( groupId );
         groupPicker.SetValue( group );
     }
 }
开发者ID:pkdevbox,项目名称:Rock,代码行数:17,代码来源:GroupFieldType.cs

示例8: FormatValue

        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            string formattedValue = value;

            Guid? guid = value.AsGuidOrNull();
            if ( guid.HasValue )
            {
                var group = new GroupService( new RockContext() ).Get( guid.Value );
                if ( group != null )
                {
                    formattedValue = group.Name;
                }
            }

            return base.FormatValue( parentControl, formattedValue, configurationValues, condensed );
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:24,代码来源:SecurityRoleFieldType.cs

示例9: BindGrid

        private void BindGrid()
        {
            string type = PageParameter( "SearchType" );
            string term = PageParameter( "SearchTerm" );

            var groupService = new GroupService( new RockContext() );
            var groups = new List<Group>();

            if ( !string.IsNullOrWhiteSpace( type ) && !string.IsNullOrWhiteSpace( term ) )
            {
                switch ( type.ToLower() )
                {
                    case "name":
                        {
                            groups = groupService.Queryable()
                                .Where( g =>
                                    g.GroupType.ShowInNavigation &&
                                    g.Name.Contains( term ) )
                                .OrderBy( g => g.Order )
                                .ThenBy( g => g.Name )
                                .ToList();

                            break;
                        }
                }
            }

            if ( groups.Count == 1 )
            {
                Response.Redirect( string.Format( "~/Group/{0}", groups[0].Id ), false );
                Context.ApplicationInstance.CompleteRequest();
            }
            else
            {
                gGroups.EntityTypeId = EntityTypeCache.Read<Group>().Id;
                gGroups.DataSource = groups
                    .Select( g => new
                    {
                        g.Id,
                        GroupType = g.GroupType.Name,
                        Structure = ParentStructure( g ),
                        MemberCount = g.Members.Count()
                    } )
                    .ToList();
                gGroups.DataBind();
            }
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:47,代码来源:GroupSearch.ascx.cs

示例10: EditControl

        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            var editControl = new RockDropDownList { ID = id };

            var roles = new GroupService( new RockContext() ).Queryable().Where(g => g.IsSecurityRole).OrderBy( t => t.Name );
            if ( roles.Any() )
            {
                foreach ( var role in roles )
                {
                    editControl.Items.Add( new ListItem( role.Name, role.Guid.ToString() ) );
                }

                return editControl;
            }

            return null;
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:25,代码来源:SecurityRoleFieldType.cs

示例11: bbtnVerify_Click

        /// <summary>
        /// Marks the selected people/photos as verified by setting their group member status Active.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void bbtnVerify_Click( object sender, EventArgs e )
        {
            nbMessage.Visible = true;

            int count = 0;
            RockContext rockContext = new RockContext();
            GroupService groupService = new GroupService( rockContext );
            Group group = groupService.Get( Rock.SystemGuid.Group.GROUP_PHOTO_REQUEST.AsGuid() );

            GroupMember groupMember = null;

            var itemsSelected = new List<int>();

            gList.SelectedKeys.ToList().ForEach( i => itemsSelected.Add( i.ToString().AsInteger() ) );

            if ( itemsSelected.Any() )
            {
                foreach ( int currentRowsPersonId in itemsSelected )
                {
                    groupMember = group.Members.Where( m => m.PersonId == currentRowsPersonId ).FirstOrDefault();
                    if ( groupMember != null )
                    {
                        count++;
                        groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                    }
                }
            }

            if ( count > 0 )
            {
                nbMessage.NotificationBoxType = NotificationBoxType.Success;
                nbMessage.Text = string.Format( "Verified {0} photo{1}.", count, count > 1 ? "s" : "" );
            }
            else
            {
                nbMessage.NotificationBoxType = NotificationBoxType.Warning;
                nbMessage.Text = "No photos selected.";
            }
            rockContext.SaveChanges();
            _photoRequestGroup = group;

            BindGrid();
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:48,代码来源:PhotoVerify.ascx.cs

示例12: Handle

        /// <summary>
        /// When overridden in a derived class, handles the exception synchronously.
        /// </summary>
        /// <param name="context">The exception handler context.</param>
        public override void Handle( ExceptionHandlerContext context )
        {
            // check to see if the user is an admin, if so allow them to view the error details
            var userLogin = Rock.Model.UserLoginService.GetCurrentUser();
            GroupService service = new GroupService( new RockContext() );
            Group adminGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_ADMINISTRATORS ) );
            context.RequestContext.IncludeErrorDetail = userLogin != null && adminGroup.Members.Where( m => m.PersonId == userLogin.PersonId ).Count() > 0;

            ExceptionResult result = context.Result as ExceptionResult;

            // fix up context.Result.IncludeErrorMessage if it didn't get set when we set context.RequestContext.IncludeErrorDetail
            // see comments in https://aspnetwebstack.codeplex.com/workitem/1248
            if ( result != null && result.IncludeErrorDetail != context.RequestContext.IncludeErrorDetail )
            {

                context.Result = new ExceptionResult( result.Exception, context.RequestContext.IncludeErrorDetail, result.ContentNegotiator, context.Request, result.Formatters );
            }

            base.Handle( context );
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:24,代码来源:RockApiExceptionHandler.cs

示例13: bbtnVerify_Click

        /// <summary>
        /// Marks the selected people/photos as verified by setting their group member status Active.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void bbtnVerify_Click( object sender, EventArgs e )
        {
            nbMessage.Visible = true;

            int count = 0;
            RockContext rockContext = new RockContext();
            GroupService groupService = new GroupService( rockContext );
            Group group = groupService.Get( Rock.SystemGuid.Group.GROUP_PHOTO_REQUEST.AsGuid() );

            GroupMember groupMember = null;
            foreach ( GridViewRow row in gList.Rows )
            {
                var cb = row.FindControl( "cbSelected" ) as CheckBox;

                if ( cb != null && cb.Checked )
                {
                    int currentRowsPersonId = (int)gList.DataKeys[row.RowIndex].Value;
                    groupMember = group.Members.Where( m => m.PersonId == currentRowsPersonId ).FirstOrDefault();
                    if ( groupMember != null )
                    {
                        count++;
                        groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                    }
                }
            }

            if ( count > 0 )
            {
                nbMessage.NotificationBoxType = NotificationBoxType.Success;
                nbMessage.Text = string.Format( "Verified {0} photo{1}.", count, count > 1 ? "s" : "" );
            }
            else
            {
                nbMessage.NotificationBoxType = NotificationBoxType.Warning;
                nbMessage.Text = "No changes were made.";
            }
            rockContext.SaveChanges();
            _photoRequestGroup = group;

            BindGrid();
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:46,代码来源:VerifyPhoto.ascx.cs

示例14: Execute

        /// <summary>
        /// Executes the specified workflow action.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            errorMessages = new List<string>();

            Guid? groupGuid = GetAttributeValue( action, "SecurityRole" ).AsGuidOrNull();
            if ( groupGuid.HasValue )
            {
                var group = new GroupService( rockContext ).Get( groupGuid.Value );
                if ( group != null )
                {
                    action.Activity.AssignedPersonAlias = null;
                    action.Activity.AssignedPersonAliasId = null;
                    action.Activity.AssignedGroup = group;
                    action.Activity.AssignedGroupId = group.Id;
                    action.AddLogEntry( string.Format( "Assigned activity to '{0}' security role ({1})", group.Name, group.Id ) );
                    return true;
                }
            }

            return false;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:29,代码来源:AssignActivityToSecurityRole.cs

示例15: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Guid? rootGroupGuid = GetAttributeValue("RootGroup").AsGuidOrNull();
            GroupService gs = new GroupService(new RockContext());

            if (rootGroupGuid != null)
            {
                var staffGroup = gs.Get(rootGroupGuid.Value);
                var groupMembers = staffGroup.Members.OrderByDescending(g => g.GroupMemberStatus).Select(m => m.Person).OrderBy(m => m.LastName).ThenBy(m => m.FirstName).ToList();
                var groupName = staffGroup.Name.ToString();
                this.lblGroupName.Text = groupName;

                var people = new List<PersonData>();

                foreach (var person in groupMembers)
                {
                    person.LoadAttributes();
                    people.Add(new PersonData { Name = person.FullName, PhotoUrl = person.PhotoUrl, Position = person.GetAttributeValue("Position") });
                }

                this.rptStaff.DataSource = people;
                this.rptStaff.DataBind();
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:24,代码来源:Staff.ascx.cs


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