本文整理汇总了C#中Rock.Model.PersonAliasService类的典型用法代码示例。如果您正苦于以下问题:C# PersonAliasService类的具体用法?C# PersonAliasService怎么用?C# PersonAliasService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersonAliasService类属于Rock.Model命名空间,在下文中一共展示了PersonAliasService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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? personAliasGuid = GetAttributeValue( action, "Person" ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Queryable( "Person" )
.Where( a => a.Guid.Equals( personAliasGuid.Value ) )
.FirstOrDefault();
if (personAlias != null)
{
action.Activity.AssignedPersonAlias = personAlias;
action.Activity.AssignedPersonAliasId = personAlias.Id;
action.Activity.AssignedGroup = null;
action.Activity.AssignedGroupId = null;
action.AddLogEntry( string.Format( "Assigned activity to '{0}' ({1})", personAlias.Person.FullName, personAlias.Person.Id ) );
return true;
}
}
return false;
}
示例2: AttributeFilterExpression
/// <summary>
/// Gets a filter expression for an attribute value.
/// </summary>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="filterValues">The filter values.</param>
/// <param name="parameterExpression">The parameter expression.</param>
/// <returns></returns>
public override System.Linq.Expressions.Expression AttributeFilterExpression( Dictionary<string, ConfigurationValue> configurationValues, List<string> filterValues, System.Linq.Expressions.ParameterExpression parameterExpression )
{
if ( filterValues.Count >= 2 )
{
string comparisonValue = filterValues[0];
if ( comparisonValue != "0" )
{
Guid guid = filterValues[1].AsGuid();
int personId = new PersonAliasService( new RockContext() ).Queryable()
.Where( a => a.Guid.Equals( guid ) )
.Select( a => a.PersonId )
.FirstOrDefault();
if ( personId > 0 )
{
ComparisonType comparisonType = comparisonValue.ConvertToEnum<ComparisonType>( ComparisonType.EqualTo );
MemberExpression propertyExpression = Expression.Property( parameterExpression, "ValueAsPersonId" );
ConstantExpression constantExpression = Expression.Constant( personId, typeof( int ) );
return ComparisonHelper.ComparisonExpression( comparisonType, propertyExpression, constantExpression );
}
}
}
return null;
}
示例3: Execute
/// <summary>
/// Executes the specified workflow.
/// </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>();
if ( action.Activity.Workflow.InitiatorPersonAliasId.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Get( action.Activity.Workflow.InitiatorPersonAliasId.Value );
if ( personAlias != null )
{
// Get the attribute to set
Guid guid = GetAttributeValue( action, "PersonAttribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
var personAttribute = AttributeCache.Read( guid, rockContext );
if ( personAttribute != null )
{
// If this is a person type attribute
if ( personAttribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
{
SetWorkflowAttributeValue( action, guid, personAlias.Guid.ToString() );
}
else if ( personAttribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.TEXT.AsGuid(), rockContext ).Id )
{
SetWorkflowAttributeValue( action, guid, personAlias.Person.FullName );
}
}
}
}
}
return true;
}
示例4: 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>();
// Get the attribute's guid
Guid guid = GetAttributeValue( action, "PersonAttribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
// Get the attribute
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
if ( attribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
{
// If attribute type is a person, value should be person alias id
Guid? personAliasGuid = action.GetWorklowAttributeValue( guid ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Queryable( "Person" )
.Where( a => a.Guid.Equals( personAliasGuid.Value ) )
.FirstOrDefault();
if ( personAlias != null )
{
action.Activity.Workflow.InitiatorPersonAlias = personAlias;
action.Activity.Workflow.InitiatorPersonAliasId = personAlias.Id;
action.AddLogEntry( string.Format( "Assigned initiator to '{0}' ({1})", personAlias.Person.FullName, personAlias.Person.Id ) );
return true;
}
}
}
}
}
return false;
}
示例5: GetPersonFromForm
protected Person GetPersonFromForm(string formId)
{
AttributeValueService attributeValueService = new AttributeValueService(rockContext);
PersonService personService = new PersonService(rockContext);
PersonAliasService personAliasService = new PersonAliasService(rockContext);
var formAttribute = attributeValueService.Queryable().FirstOrDefault(a => a.Value == formId);
var person = personService.Queryable().FirstOrDefault(p => p.Id == formAttribute.EntityId);
return person;
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
PersonAliasService personAliasService = new PersonAliasService(rockContext);
StarsService starsService = new StarsService(starsProjectContext);
var starsList = starsService.Queryable().GroupBy(a => a.PersonAlias.Person).Select(g => new { Person = g.Key, Sum = g.Sum(a => a.Value)}).ToList();
gStars.DataSource = starsList;
gStars.DataBind();
}
示例7: Execute
/// <summary>
/// Executes the specified workflow.
/// </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 guid = GetAttributeValue( action, "Attribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
if ( entity != null )
{
if ( entity is Person && attribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
{
var person = entity as Person;
var primaryAlias = new PersonAliasService(rockContext).Queryable().FirstOrDefault( a => a.AliasPersonId == person.Id );
if ( primaryAlias != null )
{
SetWorkflowAttributeValue( action, guid, primaryAlias.Guid.ToString() );
return true;
}
else
{
errorMessages.Add( "Could not determine person primary alias!" );
}
}
else if ( entity is Group && attribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.GROUP.AsGuid(), rockContext ).Id )
{
var group = entity as Group;
SetWorkflowAttributeValue( action, guid, group.Id.ToString() );
return true;
}
else
{
errorMessages.Add( "The attribute is not the correct type for the entity!" );
}
}
}
else
{
errorMessages.Add( "Invalid attribute!" );
}
}
else
{
errorMessages.Add( "Invalid attribute!" );
}
errorMessages.ForEach( m => action.AddLogEntry( m, true ) );
return false;
}
示例8: UrlLink
/// <summary>
/// Formats the value extended.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="configurationValues">The configuration values.</param>
/// <returns></returns>
public string UrlLink( string value, Dictionary<string, ConfigurationValue> configurationValues )
{
if ( !string.IsNullOrWhiteSpace( value ) )
{
Guid guid = value.AsGuid();
int personId = new PersonAliasService( new RockContext() ).Queryable()
.Where( a => a.Guid.Equals( guid ) )
.Select( a => a.PersonId )
.FirstOrDefault();
return string.Format( "person/{0}", personId );
}
return value;
}
示例9: 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( System.Web.UI.Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
Guid guid = value.AsGuid();
formattedValue = new PersonAliasService( new RockContext() ).Queryable()
.Where( a => a.Guid.Equals( guid ) )
.Select( a => a.Person.NickName + " " + a.Person.LastName )
.FirstOrDefault();
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例10: Execute
/// <summary>
/// Executes the specified workflow.
/// </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>();
string attributeValue = GetAttributeValue( action, "Attribute" );
Guid guid = attributeValue.AsGuid();
if (!guid.IsEmpty())
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = GetAttributeValue( action, "Person" );
guid = value.AsGuid();
if ( !guid.IsEmpty() )
{
var personAlias = new PersonAliasService( rockContext ).Get( guid );
if ( personAlias != null && personAlias.Person != null )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, personAlias.Person.FullName ) );
return true;
}
else
{
errorMessages.Add( string.Format( "Person could not be found for selected value ('{0}')!", guid.ToString() ) );
}
}
else
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, string.Empty );
action.AddLogEntry( string.Format( "Set '{0}' attribute to nobody.", attribute.Name ) );
return true;
}
}
else
{
errorMessages.Add( string.Format( "Attribute could not be found for selected attribute value ('{0}')!", guid.ToString() ) );
}
}
else
{
errorMessages.Add( string.Format( "Selected attribute value ('{0}') was not a valid Guid!", attributeValue ) );
}
errorMessages.ForEach( m => action.AddLogEntry( m, true ) );
return true;
}
示例11: SetFollowing
/// <summary>
/// Configures a control to display and toggle following for the specified entity
/// </summary>
/// <param name="followEntity">The follow entity. NOTE: Make sure to use PersonAlias instead of Person when following a Person</param>
/// <param name="followControl">The follow control.</param>
/// <param name="follower">The follower.</param>
public static void SetFollowing( IEntity followEntity, WebControl followControl, Person follower )
{
var followingEntityType = EntityTypeCache.Read( followEntity.GetType() );
if ( follower != null && follower.PrimaryAliasId.HasValue )
{
using ( var rockContext = new RockContext() )
{
var personAliasService = new PersonAliasService( rockContext );
var followingService = new FollowingService( rockContext );
var followingQry = followingService.Queryable()
.Where( f =>
f.EntityTypeId == followingEntityType.Id &&
f.PersonAlias.PersonId == follower.Id );
followingQry = followingQry.Where( f => f.EntityId == followEntity.Id );
if ( followingQry.Any() )
{
followControl.AddCssClass( "following" );
}
else
{
followControl.RemoveCssClass( "following" );
}
}
int entityId = followEntity.Id;
// only show the following control if the entity has been saved to the database
followControl.Visible = entityId > 0;
string script = string.Format(
@"Rock.controls.followingsToggler.initialize($('#{0}'), {1}, {2}, {3}, {4});",
followControl.ClientID,
followingEntityType.Id,
entityId,
follower.Id,
follower.PrimaryAliasId );
ScriptManager.RegisterStartupScript( followControl, followControl.GetType(), "following", script, true );
}
}
示例12: gFollowings_Delete
/// <summary>
/// Handles the Delete event of the gFollowings control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gFollowings_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
var personAliasService = new PersonAliasService( rockContext );
var followingService = new FollowingService( rockContext );
var paQry = personAliasService.Queryable()
.Where( p => p.PersonId == e.RowKeyId )
.Select( p => p.Id );
int personAliasEntityTypeId = EntityTypeCache.Read( "Rock.Model.PersonAlias" ).Id;
foreach ( var following in followingService.Queryable()
.Where( f =>
f.EntityTypeId == personAliasEntityTypeId &&
paQry.Contains( f.EntityId ) &&
f.PersonAliasId == CurrentPersonAlias.Id ) )
{
followingService.Delete( following );
}
rockContext.SaveChanges();
BindGrid();
}
示例13: btnAddConnectionRequestActivity_Click
/// <summary>
/// Handles the Click event of the btnAddConnectionRequestActivity 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 btnAddConnectionRequestActivity_Click( object sender, EventArgs e )
{
using ( var rockContext = new RockContext() )
{
var connectionRequestService = new ConnectionRequestService( rockContext );
var connectionRequestActivityService = new ConnectionRequestActivityService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
var connectionRequest = connectionRequestService.Get( hfConnectionRequestId.ValueAsInt() );
if ( connectionRequest != null )
{
int? activityTypeId = ddlActivity.SelectedValueAsId();
int? personAliasId = personAliasService.GetPrimaryAliasId( ddlActivityConnector.SelectedValueAsId() ?? 0 );
if ( activityTypeId.HasValue && personAliasId.HasValue )
{
ConnectionRequestActivity connectionRequestActivity = null;
Guid? guid = hfAddConnectionRequestActivityGuid.Value.AsGuidOrNull();
if ( guid.HasValue )
{
connectionRequestActivity = connectionRequestActivityService.Get( guid.Value );
}
if ( connectionRequestActivity == null )
{
connectionRequestActivity = new ConnectionRequestActivity();
connectionRequestActivity.ConnectionRequestId = connectionRequest.Id;
connectionRequestActivity.ConnectionOpportunityId = connectionRequest.ConnectionOpportunityId;
connectionRequestActivityService.Add( connectionRequestActivity );
}
connectionRequestActivity.ConnectionActivityTypeId = activityTypeId.Value;
connectionRequestActivity.ConnectorPersonAliasId = personAliasId.Value;
connectionRequestActivity.Note = tbNote.Text;
rockContext.SaveChanges();
BindConnectionRequestActivitiesGrid( connectionRequest, rockContext );
HideDialog();
}
}
}
}
示例14: ShowDetail
private void ShowDetail(Guid personGuid)
{
using ( var rockContext = new RockContext() )
{
var personService = new PersonService( new RockContext() );
var person = personService.Get( personGuid );
if ( person != null )
{
lName.Text = person.FullName;
string photoTag = Rock.Model.Person.GetPhotoImageTag( person, 120, 120 );
if ( person.PhotoId.HasValue )
{
lPhoto.Text = string.Format( "<a href='{0}'>{1}</a>", person.PhotoUrl, photoTag );
}
else
{
lPhoto.Text = photoTag;
}
lEmail.Visible = !string.IsNullOrWhiteSpace( person.Email );
lEmail.Text = person.GetEmailTag( ResolveRockUrl( "/" ), "btn btn-default", "<i class='fa fa-envelope'></i>" );
var childGuid = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid();
var isFamilyChild = new Dictionary<int, bool>();
var allFamilyMembers = person.GetFamilyMembers( true ).ToList();
allFamilyMembers.Where( m => m.PersonId == person.Id ).ToList().ForEach(
m => isFamilyChild.Add( m.GroupId, m.GroupRole.Guid.Equals( childGuid ) ) );
string urlRoot = Request.Url.ToString().ReplaceCaseInsensitive( personGuid.ToString(), "" );
var familyMembers = allFamilyMembers.Where( m => m.PersonId != person.Id )
.OrderBy( m => m.GroupId )
.ThenBy( m => m.Person.BirthDate )
.Select( m => new
{
Url = urlRoot + m.Person.Guid.ToString(),
FullName = m.Person.FullName,
Gender = m.Person.Gender,
FamilyRole = m.GroupRole,
Note = isFamilyChild[m.GroupId] ?
( m.GroupRole.Guid.Equals( childGuid ) ? " (Sibling)" : "(Parent)" ) :
( m.GroupRole.Guid.Equals( childGuid ) ? " (Child)" : "" )
} )
.ToList();
rcwFamily.Visible = familyMembers.Any();
rptrFamily.DataSource = familyMembers;
rptrFamily.DataBind();
rptrPhones.DataSource = person.PhoneNumbers.Where( p => !p.IsUnlisted ).ToList();
rptrPhones.DataBind();
var schedules = new ScheduleService( rockContext ).Queryable()
.Where( s => s.CheckInStartOffsetMinutes.HasValue )
.ToList();
var scheduleIds = schedules.Select( s => s.Id ).ToList();
var activeScheduleIds = new List<int>();
foreach ( var schedule in schedules )
{
if ( schedule.IsScheduleOrCheckInActive )
{
activeScheduleIds.Add( schedule.Id );
}
}
int? personAliasId = person.PrimaryAliasId;
if ( !personAliasId.HasValue )
{
personAliasId = new PersonAliasService( rockContext ).GetPrimaryAliasId( person.Id );
}
var attendances = new AttendanceService( rockContext )
.Queryable( "Schedule,Group,Location" )
.Where( a =>
a.PersonAliasId.HasValue &&
a.PersonAliasId == personAliasId &&
a.ScheduleId.HasValue &&
a.GroupId.HasValue &&
a.LocationId.HasValue &&
a.DidAttend.HasValue &&
a.DidAttend.Value &&
scheduleIds.Contains( a.ScheduleId.Value ) )
.OrderByDescending( a => a.StartDateTime )
.Take( 20 )
.Select( a => new AttendanceInfo
{
Date = a.StartDateTime,
GroupId = a.Group.Id,
Group = a.Group.Name,
LocationId = a.LocationId.Value,
Location = a.Location.Name,
Schedule = a.Schedule.Name,
IsActive =
a.StartDateTime > DateTime.Today &&
//.........这里部分代码省略.........
示例15: Execute
/// <summary>
/// Executes the specified workflow.
/// </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 = null;
Person person = null;
Group group = null;
string noteValue = string.Empty;
string captionValue = string.Empty;
bool isAlert = false;
// get the group attribute
Guid groupAttributeGuid = GetAttributeValue( action, "Group" ).AsGuid();
if ( !groupAttributeGuid.IsEmpty() )
{
groupGuid = action.GetWorklowAttributeValue( groupAttributeGuid ).AsGuidOrNull();
if ( groupGuid.HasValue )
{
group = new GroupService( rockContext ).Get( groupGuid.Value );
if ( group == null )
{
errorMessages.Add( "The group provided does not exist." );
}
}
else
{
errorMessages.Add( "Invalid group provided." );
}
}
// get person alias guid
Guid personAliasGuid = Guid.Empty;
string personAttribute = GetAttributeValue( action, "Person" );
Guid guid = personAttribute.AsGuid();
if ( !guid.IsEmpty() )
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = action.GetWorklowAttributeValue( guid );
personAliasGuid = value.AsGuid();
}
if ( personAliasGuid != Guid.Empty )
{
person = new PersonAliasService( rockContext ).Queryable()
.Where( p => p.Guid.Equals( personAliasGuid ) )
.Select( p => p.Person )
.FirstOrDefault();
}
else
{
errorMessages.Add( "The person could not be found!" );
}
}
// get caption
captionValue = GetAttributeValue( action, "Caption" );
guid = captionValue.AsGuid();
if ( guid.IsEmpty() )
{
captionValue = captionValue.ResolveMergeFields( GetMergeFields( action ) );
}
else
{
var workflowAttributeValue = action.GetWorklowAttributeValue( guid );
if ( workflowAttributeValue != null )
{
captionValue = workflowAttributeValue;
}
}
// get group member note
noteValue = GetAttributeValue( action, "Note" );
guid = noteValue.AsGuid();
if ( guid.IsEmpty() )
{
noteValue = noteValue.ResolveMergeFields( GetMergeFields( action ) );
}
else
{
var workflowAttributeValue = action.GetWorklowAttributeValue( guid );
if ( workflowAttributeValue != null )
{
noteValue = workflowAttributeValue;
}
//.........这里部分代码省略.........