本文整理汇总了C#中Rock.Model.GroupService.GetByGuid方法的典型用法代码示例。如果您正苦于以下问题:C# GroupService.GetByGuid方法的具体用法?C# GroupService.GetByGuid怎么用?C# GroupService.GetByGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupService
的用法示例。
在下文中一共展示了GroupService.GetByGuid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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, " " );
}
}
}
示例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 )
{
// get error level
int errorLevel = 0;
if ( Request["error"] != null )
errorLevel = Int32.Parse( Request["error"].ToString() );
if ( errorLevel == 1 )
{
// 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();
Group adminGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_ADMINISTRATORS ) );
if ( userLogin != null && adminGroup.Members.Where( m => m.PersonId == userLogin.PersonId ).Count() > 0 )
{
// is an admin
lErrorInfo.Text = "<h3>Exception Log:</h3>";
// get exception from Session
if ( Session["Exception"] != null )
{
ProcessException( (Exception)Session["Exception"], " " );
}
}
}
// clear session object
Session.Remove( "Exception" );
}
示例3: 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 );
}
示例4: 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 );
}
示例5: AddOrUpdatePersonInPhotoRequestGroup
/// <summary>
/// Add the person (if not already existing) to the Photo Request group and set status to Pending.
/// </summary>
/// <param name="person">The person.</param>
/// <param name="rockContext">The rock context.</param>
private void AddOrUpdatePersonInPhotoRequestGroup( Person person, RockContext rockContext )
{
if ( _photoRequestGroup == null )
{
GroupService service = new GroupService( rockContext );
_photoRequestGroup = service.GetByGuid( Rock.SystemGuid.Group.GROUP_PHOTO_REQUEST.AsGuid() );
}
var groupMember = _photoRequestGroup.Members.Where( m => m.PersonId == person.Id ).FirstOrDefault();
if ( groupMember == null )
{
groupMember = new GroupMember();
groupMember.GroupId = _photoRequestGroup.Id;
groupMember.PersonId = person.Id;
groupMember.GroupRoleId = _photoRequestGroup.GroupType.DefaultGroupRoleId ?? -1;
_photoRequestGroup.Members.Add( groupMember );
}
groupMember.GroupMemberStatus = GroupMemberStatus.Pending;
}
示例6: OnLoad
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( ! Page.IsPostBack )
{
if ( ! GetAttributeValue( "AllowStaff" ).AsBoolean() )
{
GroupService service = new GroupService( new RockContext() );
_staffGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_STAFF_MEMBERS ) );
}
BindRepeater();
}
}
示例7: OptOutThePerson
/// <summary>
/// Opts the given person out of the Photo Request group making them inactive.
/// </summary>
private void OptOutThePerson()
{
RockContext rockContext = new RockContext();
Person targetPerson = null;
string personKey = PageParameter( "Person" );
if ( personKey != null )
{
try
{
targetPerson = new PersonService( rockContext ).GetByUrlEncodedKey( personKey );
}
catch ( System.FormatException )
{
nbWarning.Visible = true;
}
catch ( Exception ex )
{
nbWarning.Visible = true;
LogException( ex );
}
}
if ( targetPerson != null )
{
try
{
GroupService service = new GroupService( rockContext );
Group photoRequestGroup = service.GetByGuid( Rock.SystemGuid.Group.GROUP_PHOTO_REQUEST.AsGuid() );
var groupMember = photoRequestGroup.Members.Where( m => m.PersonId == targetPerson.Id ).FirstOrDefault();
if ( groupMember == null )
{
groupMember = new GroupMember();
groupMember.GroupId = photoRequestGroup.Id;
groupMember.PersonId = targetPerson.Id;
groupMember.GroupRoleId = photoRequestGroup.GroupType.DefaultGroupRoleId ?? 0;
photoRequestGroup.Members.Add( groupMember );
}
groupMember.GroupMemberStatus = GroupMemberStatus.Inactive;
rockContext.SaveChanges();
nbMessage.Visible = true;
}
catch ( Exception ex )
{
LogException( ex );
nbMessage.Visible = true;
nbMessage.NotificationBoxType = NotificationBoxType.Danger;
nbMessage.Text = "Something went wrong and we could not save your request. If it happens again please contact our office at the number below.";
}
}
else
{
nbMessage.Visible = true;
nbMessage.NotificationBoxType = NotificationBoxType.Info;
nbMessage.Text = "That's odd. We could not find your record in our system. Please contact our office at the number below.";
}
}
示例8: ShowException
/// <summary>
/// Shows the exception.
/// </summary>
private void ShowException()
{
Exception ex = GetSavedValue( "RockLastException" ) as Exception;
if ( ex != null )
{
int? siteId = ( GetSavedValue( "Rock:SiteId" ) ?? string.Empty ).ToString().AsIntegerOrNull();
if ( siteId.HasValue )
{
var site = SiteCache.Read( siteId.Value );
if ( site != null && !string.IsNullOrWhiteSpace( site.ErrorPage ) )
{
Context.Response.Redirect( site.ErrorPage, false );
Context.ApplicationInstance.CompleteRequest();
return;
}
}
pnlSecurity.Visible = false;
pnlException.Visible = true;
int? errorLevel = ( GetSavedValue( "RockExceptionOrder" ) ?? string.Empty ).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
{
// ignore
}
}
if ( showDetails )
{
lErrorInfo.Text = "<h3>Exception Log:</h3>";
ProcessException( ex, " " );
}
if ( Request.Headers["X-Requested-With"] == "XMLHttpRequest" )
{
Response.StatusCode = 500;
if ( showDetails )
{
// go get the important exception
while ( ex.InnerException != null )
{
ex = ex.InnerException;
}
Response.Write( string.Format( "{0}<p><pre>{1}</pre>", ex.Message, ex.StackTrace ) );
}
else
{
Response.Write( "An error has occurred while processing your request. Your organization's administrators have been notified of this problem." );
}
Response.Flush();
Response.End();
return;
}
}
}
示例9: AddToSecurityGroups
/// <summary>
/// Handles adding people to the security groups from the given XML element snippet.
/// </summary>
/// <param name="elemSecurityGroups">The elem security groups.</param>
/// <param name="rockContext">The rock context.</param>
private void AddToSecurityGroups( XElement elemSecurityGroups, RockContext rockContext )
{
if ( elemSecurityGroups == null )
{
return;
}
GroupService groupService = new GroupService( rockContext );
// Next find each group and add its members
foreach ( var elemGroup in elemSecurityGroups.Elements( "group" ) )
{
int membersAdded = 0;
Guid guid = elemGroup.Attribute( "guid" ).Value.Trim().AsGuid();
Group securityGroup = groupService.GetByGuid( guid );
if ( securityGroup == null )
{
continue;
}
// Add each person as a member of the group
foreach ( var elemPerson in elemGroup.Elements( "members" ).Elements( "person" ) )
{
Guid personGuid = elemPerson.Attribute( "guid" ).Value.Trim().AsGuid();
int personId = _peopleDictionary[personGuid];
// Don't add if already in the group...
if ( securityGroup.Members.Where( p => p.PersonId == personId ).Count() > 0 )
{
continue;
}
membersAdded++;
GroupMember groupMember = new GroupMember();
groupMember.GroupMemberStatus = GroupMemberStatus.Active;
groupMember.GroupRoleId = securityGroup.GroupType.DefaultGroupRoleId.Value;
groupMember.PersonId = personId;
securityGroup.Members.Add( groupMember );
}
}
}
示例10: ShowException
private void ShowException()
{
pnlException.Visible = true;
// get error level
int errorLevel = 0;
if ( Request["error"] != null )
{
errorLevel = Int32.Parse( Request["error"].ToString() );
}
else
{
if (Request.RequestContext.HttpContext.Items["error"] != null)
{
errorLevel = Int32.Parse( Request.RequestContext.HttpContext.Items["error"].ToString() );
}
}
switch ( errorLevel )
{
case 1:
// check to see if the user is an admin, if so allow them to view the error details
var userLogin = Rock.Model.UserLoginService.GetCurrentUser();
try
{
GroupService service = new GroupService( new RockContext() );
Group adminGroup = service.GetByGuid( new Guid( Rock.SystemGuid.Group.GROUP_ADMINISTRATORS ) );
if ( userLogin != null && adminGroup.Members.Where( m => m.PersonId == userLogin.PersonId ).Count() > 0 )
{
// get exception from Session
if ( Session["Exception"] != null )
{
// is an admin
lErrorInfo.Text = "<h3>Exception Log:</h3>";
ProcessException( (Exception)Session["Exception"], " " );
}
}
}
catch { }
break;
case 66: // massive errors from global.asax.cs or routehandler
if ( Session["Exception"] != null )
{
lErrorInfo.Text = "<h3>Exception Log:</h3>";
ProcessException( (Exception)Session["Exception"], " " );
}
else
{
if (Request.RequestContext.HttpContext.Items["Exception"] != null)
{
lErrorInfo.Text = "<h3>Exception Log:</h3>";
ProcessException( (Exception)Request.RequestContext.HttpContext.Items["Exception"], " " );
}
}
break;
}
// clear session object
Session.Remove( "Exception" );
}