本文整理汇总了C#中Rock.Model.PersonAliasService.GetPrimaryAlias方法的典型用法代码示例。如果您正苦于以下问题:C# PersonAliasService.GetPrimaryAlias方法的具体用法?C# PersonAliasService.GetPrimaryAlias怎么用?C# PersonAliasService.GetPrimaryAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonAliasService
的用法示例。
在下文中一共展示了PersonAliasService.GetPrimaryAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
AttendanceCode attendanceCode = null;
DateTime startDateTime = RockDateTime.Now;
bool reuseCodeForFamily = checkInState.CheckInType != null && checkInState.CheckInType.ReuseSameCode;
int securityCodeLength = checkInState.CheckInType != null ? checkInState.CheckInType.SecurityCodeLength : 3;
var attendanceCodeService = new AttendanceCodeService( rockContext );
var attendanceService = new AttendanceService( rockContext );
var groupMemberService = new GroupMemberService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
var family = checkInState.CheckIn.CurrentFamily;
if ( family != null )
{
foreach ( var person in family.GetPeople( true ) )
{
if ( reuseCodeForFamily && attendanceCode != null )
{
person.SecurityCode = attendanceCode.Code;
}
else
{
attendanceCode = AttendanceCodeService.GetNew( securityCodeLength );
person.SecurityCode = attendanceCode.Code;
}
foreach ( var groupType in person.GetGroupTypes( true ) )
{
foreach ( var group in groupType.GetGroups( true ) )
{
if ( groupType.GroupType.AttendanceRule == AttendanceRule.AddOnCheckIn &&
groupType.GroupType.DefaultGroupRoleId.HasValue &&
!groupMemberService.GetByGroupIdAndPersonId( group.Group.Id, person.Person.Id, true ).Any() )
{
var groupMember = new GroupMember();
groupMember.GroupId = group.Group.Id;
groupMember.PersonId = person.Person.Id;
groupMember.GroupRoleId = groupType.GroupType.DefaultGroupRoleId.Value;
groupMemberService.Add( groupMember );
}
foreach ( var location in group.GetLocations( true ) )
{
foreach ( var schedule in location.GetSchedules( true ) )
{
// Only create one attendance record per day for each person/schedule/group/location
var attendance = attendanceService.Get( startDateTime, location.Location.Id, schedule.Schedule.Id, group.Group.Id, person.Person.Id );
if ( attendance == null )
{
var primaryAlias = personAliasService.GetPrimaryAlias( person.Person.Id );
if ( primaryAlias != null )
{
attendance = rockContext.Attendances.Create();
attendance.LocationId = location.Location.Id;
attendance.CampusId = location.CampusId;
attendance.ScheduleId = schedule.Schedule.Id;
attendance.GroupId = group.Group.Id;
attendance.PersonAlias = primaryAlias;
attendance.PersonAliasId = primaryAlias.Id;
attendance.DeviceId = checkInState.Kiosk.Device.Id;
attendance.SearchTypeValueId = checkInState.CheckIn.SearchType.Id;
attendance.LoadAttributes();
attendance.SetAttributeValue( "SearchValue", checkInState.CheckIn.SearchValue );
attendance.SetAttributeValue( "SearchResultGroupId", family.Group.Id );
attendanceService.Add( attendance );
}
}
attendance.AttendanceCodeId = attendanceCode.Id;
attendance.StartDateTime = startDateTime;
attendance.EndDateTime = null;
attendance.DidAttend = true;
rockContext.SaveChanges();
attendance.SaveAttributeValues( rockContext );
KioskLocationAttendance.AddAttendance( attendance );
}
}
}
}
}
}
rockContext.SaveChanges();
//.........这里部分代码省略.........
示例2: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
btnDone.Visible = true;
lblPeople.Visible = true;
//Create List to Save Registered People
var peopleList = new List<string>();
if (Session["peopleList"] != null)
{
peopleList = (List<string>)Session["peopleList"];
}
AttendanceCodeService attendanceCodeService = new AttendanceCodeService(rockContext);
AttendanceService attendanceService = new AttendanceService(rockContext);
GroupMemberService groupMemberService = new GroupMemberService(rockContext);
PersonAliasService personAliasService = new PersonAliasService(rockContext);
Session["person"] = ppPerson.SelectedValue.ToString();
// Only create one attendance record per day for each person/schedule/group/location
DateTime theTime = Convert.ToDateTime(Session["startDateTime"]);
var attendance = attendanceService.Get(theTime, int.Parse(Session["location"].ToString()), int.Parse(Session["schedule"].ToString()), int.Parse(Session["group"].ToString()), int.Parse(ppPerson.SelectedValue.ToString()));
var primaryAlias = personAliasService.GetPrimaryAlias(int.Parse(ppPerson.SelectedValue.ToString()));
if (attendance == null)
{
if (primaryAlias != null)
{
attendance = rockContext.Attendances.Create();
attendance.LocationId = int.Parse(Session["location"].ToString());
attendance.CampusId = int.Parse(Session["campus"].ToString());
attendance.ScheduleId = int.Parse(Session["schedule"].ToString());
attendance.GroupId = int.Parse(Session["group"].ToString());
attendance.PersonAlias = primaryAlias;
attendance.PersonAliasId = primaryAlias.Id;
attendance.DeviceId = null;
attendance.SearchTypeValueId = 1;
attendanceService.Add(attendance);
}
}
attendance.AttendanceCodeId = null;
attendance.StartDateTime = Convert.ToDateTime(Session["startDateTime"]);
attendance.EndDateTime = null;
attendance.DidAttend = true;
//KioskLocationAttendance.AddAttendance(attendance);
rockContext.SaveChanges();
//Add Person to Dictionary
peopleList.Add( ppPerson.PersonName );
repLinks.DataSource = peopleList;
repLinks.DataBind();
Session["peopleList"] = peopleList;
//Clear Person field
ppPerson.PersonId = null;
ppPerson.PersonName = null;
//Update Current Participants List
}
示例3: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
AttendanceCode attendanceCode = null;
bool reuseCodeForFamily = false;
if ( bool.TryParse( GetAttributeValue( action, "ReuseCodeForFamily" ), out reuseCodeForFamily ) && reuseCodeForFamily )
{
reuseCodeForFamily = true;
}
DateTime startDateTime = RockDateTime.Now;
int securityCodeLength = 3;
if ( !int.TryParse( GetAttributeValue( action, "SecurityCodeLength" ), out securityCodeLength ) )
{
securityCodeLength = 3;
}
var attendanceCodeService = new AttendanceCodeService( rockContext );
var attendanceService = new AttendanceService( rockContext );
var groupMemberService = new GroupMemberService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
foreach ( var family in checkInState.CheckIn.Families.Where( f => f.Selected ) )
{
foreach ( var person in family.People.Where( p => p.Selected ) )
{
if ( reuseCodeForFamily && attendanceCode != null )
{
person.SecurityCode = attendanceCode.Code;
}
else
{
attendanceCode = AttendanceCodeService.GetNew( securityCodeLength );
person.SecurityCode = attendanceCode.Code;
}
foreach ( var groupType in person.GroupTypes.Where( g => g.Selected ) )
{
foreach ( var group in groupType.Groups.Where( g => g.Selected ) )
{
foreach ( var location in group.Locations.Where( l => l.Selected ) )
{
if ( groupType.GroupType.AttendanceRule == AttendanceRule.AddOnCheckIn &&
groupType.GroupType.DefaultGroupRoleId.HasValue &&
!groupMemberService.GetByGroupIdAndPersonId( group.Group.Id, person.Person.Id, true ).Any() )
{
var groupMember = new GroupMember();
groupMember.GroupId = group.Group.Id;
groupMember.PersonId = person.Person.Id;
groupMember.GroupRoleId = groupType.GroupType.DefaultGroupRoleId.Value;
groupMemberService.Add( groupMember );
}
foreach ( var schedule in location.Schedules.Where( s => s.Selected ) )
{
// Only create one attendance record per day for each person/schedule/group/location
var attendance = attendanceService.Get( startDateTime, location.Location.Id, schedule.Schedule.Id, group.Group.Id, person.Person.Id );
if ( attendance == null )
{
var primaryAlias = personAliasService.GetPrimaryAlias( person.Person.Id );
if ( primaryAlias != null )
{
attendance = rockContext.Attendances.Create();
attendance.LocationId = location.Location.Id;
attendance.CampusId = location.CampuId;
attendance.ScheduleId = schedule.Schedule.Id;
attendance.GroupId = group.Group.Id;
attendance.PersonAlias = primaryAlias;
attendance.PersonAliasId = primaryAlias.Id;
attendance.DeviceId = checkInState.Kiosk.Device.Id;
attendance.SearchTypeValueId = checkInState.CheckIn.SearchType.Id;
attendanceService.Add( attendance );
}
}
attendance.AttendanceCodeId = attendanceCode.Id;
attendance.StartDateTime = startDateTime;
attendance.EndDateTime = null;
attendance.DidAttend = true;
KioskLocationAttendance.AddAttendance( attendance );
}
}
}
}
}
}
//.........这里部分代码省略.........