本文整理汇总了C#中Rock.Model.GroupMemberService.GetByGroupIdAndPersonId方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.GetByGroupIdAndPersonId方法的具体用法?C# GroupMemberService.GetByGroupIdAndPersonId怎么用?C# GroupMemberService.GetByGroupIdAndPersonId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.GetByGroupIdAndPersonId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//Set Last Sunday Date
DateTime dt = DateTime.Now.StartOfWeek(DayOfWeek.Sunday);
SundayDate = dt.ToShortDateString();
if (!Page.IsPostBack)
{
//Get Attributes
FiscalYearStartDate = GetAttributeValue("FiscalYearStartDate").ToString();
//Generate Campus List
string[] eventList = {"All Org", "Canton Campus", "Coshocton Campus", "Dover Campus", "Millersburg Campus", "Wooster Campus"};
cpCampus.DataSource = eventList;
cpCampus.DataBind();
PersonService personService = new PersonService(rockContext);
GroupService groupService = new GroupService(rockContext);
GroupMemberService groupMemberService = new GroupMemberService(rockContext);
var personObject = personService.Get(CurrentPerson.Guid);
//Is Person in Akron Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74786, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 5;
cpCampus.SelectedValue = "Akron Campus";
SelectedCampus = "Akron Campus";
}
//Is Person in Canton Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74787, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 2;
cpCampus.SelectedValue = "Canton Campus";
SelectedCampus = "Canton Campus";
}
//Is Person in Coshocton Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74788, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 3;
cpCampus.SelectedValue = "Coshocton Campus";
SelectedCampus = "Coshocton Campus";
}
//Is Person in Dover Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74789, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 1;
cpCampus.SelectedValue = "Dover Campus";
SelectedCampus = "Dover Campus";
}
//Is Person in Millersburg Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74790, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 4;
cpCampus.SelectedValue = "Millersburg Campus";
SelectedCampus = "Millersburg Campus";
}
//Is Person in Wooster Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74791, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 6;
cpCampus.SelectedValue = "Wooster Campus";
SelectedCampus = "Wooster Campus";
}
//Is Person in Central?
if (groupMemberService.GetByGroupIdAndPersonId(74785, (int)CurrentPersonId).Any() == true)
{
cpCampus.SelectedValue = "All Org";
SelectedCampus = "All Org";
SelectedCampusId = 0;
}
sMonth = DateTime.Now.ToString("MM");
switch (sMonth)
{
case "09":
CurrentMonthInFiscalYear = 1;
GoalOffsetMultiplier = .083M;
SecondaryGoalOffsetMultiplier = .89M;
break;
case "10":
CurrentMonthInFiscalYear = 2;
GoalOffsetMultiplier = .167M;
SecondaryGoalOffsetMultiplier = .90M;
break;
case "11":
CurrentMonthInFiscalYear = 3;
GoalOffsetMultiplier = .25M;
SecondaryGoalOffsetMultiplier = .91M;
break;
case "12":
CurrentMonthInFiscalYear = 4;
GoalOffsetMultiplier = .333M;
SecondaryGoalOffsetMultiplier = .92M;
break;
case "01":
CurrentMonthInFiscalYear = 5;
GoalOffsetMultiplier = .417M;
SecondaryGoalOffsetMultiplier = .93M;
break;
//.........这里部分代码省略.........
示例2: btnMoveRegistration_Click
protected void btnMoveRegistration_Click( object sender, EventArgs e )
{
// set the new registration id
using ( var rockContext = new RockContext() )
{
var registrationService = new RegistrationService( rockContext );
var groupMemberService = new GroupMemberService( rockContext );
var registration = registrationService.Get( Registration.Id );
registration.RegistrationInstanceId = ddlNewRegistrationInstance.SelectedValue.AsInteger();
// Move registrants to new group
int? groupId = ddlMoveGroup.SelectedValueAsInt();
if ( groupId.HasValue )
{
registration.GroupId = groupId;
rockContext.SaveChanges();
var group = new GroupService( rockContext ).Get( groupId.Value );
if ( group != null )
{
int? groupRoleId = null;
var template = registration.RegistrationInstance.RegistrationTemplate;
if ( group.GroupTypeId == template.GroupTypeId && template.GroupMemberRoleId.HasValue )
{
groupRoleId = template.GroupMemberRoleId.Value;
}
if ( !groupRoleId.HasValue )
{
groupRoleId = group.GroupType.DefaultGroupRoleId;
}
if ( !groupRoleId.HasValue )
{
groupRoleId = group.GroupType.Roles.OrderBy( r => r.Order ).Select( r => r.Id ).FirstOrDefault();
}
if ( groupRoleId.HasValue )
{
foreach ( var registrant in registration.Registrants.Where( r => r.PersonAlias != null ) )
{
var newGroupMembers = groupMemberService.GetByGroupIdAndPersonId( groupId.Value, registrant.PersonAlias.PersonId );
if ( !newGroupMembers.Any() )
{
// Get any existing group member attribute values
var existingAttributeValues = new Dictionary<string, string>();
if ( registrant.GroupMemberId.HasValue )
{
var existingGroupMember = groupMemberService.Get( registrant.GroupMemberId.Value );
if ( existingGroupMember != null )
{
existingGroupMember.LoadAttributes( rockContext );
foreach ( var attributeValue in existingGroupMember.AttributeValues )
{
existingAttributeValues.Add( attributeValue.Key, attributeValue.Value.Value );
}
}
registrant.GroupMember = null;
groupMemberService.Delete( existingGroupMember );
}
var newGroupMember = new GroupMember();
groupMemberService.Add( newGroupMember );
newGroupMember.Group = group;
newGroupMember.PersonId = registrant.PersonAlias.PersonId;
newGroupMember.GroupRoleId = groupRoleId.Value;
rockContext.SaveChanges();
newGroupMember = groupMemberService.Get( newGroupMember.Id );
newGroupMember.LoadAttributes();
foreach( var attr in newGroupMember.Attributes )
{
if ( existingAttributeValues.ContainsKey( attr.Key ) )
{
newGroupMember.SetAttributeValue( attr.Key, existingAttributeValues[attr.Key] );
}
}
newGroupMember.SaveAttributeValues( rockContext );
registrant.GroupMember = newGroupMember;
rockContext.SaveChanges();
}
}
}
}
}
// Reload registration
Registration = GetRegistration( Registration.Id );
lWizardInstanceName.Text = Registration.RegistrationInstance.Name;
ShowReadonlyDetails( Registration );
}
mdMoveRegistration.Hide();
}
示例3: Page_Load
//.........这里部分代码省略.........
break;
case "05":
CurrentMonthInFiscalYear = 9;
GoalOffsetMultiplier = .75M;
SecondaryGoalOffsetMultiplier = .97M;
break;
case "06":
CurrentMonthInFiscalYear = 10;
GoalOffsetMultiplier = .883M;
SecondaryGoalOffsetMultiplier = .98M;
break;
case "07":
CurrentMonthInFiscalYear = 11;
GoalOffsetMultiplier = .917M;
SecondaryGoalOffsetMultiplier = .99M;
break;
case "08":
CurrentMonthInFiscalYear = 12;
GoalOffsetMultiplier = 1;
SecondaryGoalOffsetMultiplier = 1;
break;
}
if (!Page.IsPostBack)
{
//Get Attributes
FiscalYearStartDate = GetAttributeValue("FiscalYearStartDate").ToString();
//Generate Campus List
string[] campusList = {"All Org", "Canton Campus", "Coshocton Campus", "Dover Campus", "Millersburg Campus", "Wooster Campus"};
cpCampus.DataSource = campusList;
cpCampus.DataBind();
//Get the campus of the currently logged in person
//PersonService personService = new PersonService(rockContext);
//var personObject = personService.Get(CurrentPerson.Guid);
//var campus = personObject.GetFamilies().FirstOrDefault().Campus ?? new Campus();
//SelectedCampusId = campus.Id;
//cpCampus.SelectedValue = campus.Name;
//SelectedCampus = campus.Name;
PersonService personService = new PersonService(rockContext);
GroupService groupService = new GroupService(rockContext);
GroupMemberService groupMemberService = new GroupMemberService(rockContext);
var personObject = personService.Get(CurrentPerson.Guid);
//Is Person in Akron Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74786, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 5;
cpCampus.SelectedValue = "Akron Campus";
SelectedCampus = "Akron Campus";
}
//Is Person in Canton Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74787, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 2;
cpCampus.SelectedValue = "Canton Campus";
SelectedCampus = "Canton Campus";
}
//Is Person in Coshocton Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74788, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 3;
cpCampus.SelectedValue = "Coshocton Campus";
SelectedCampus = "Coshocton Campus";
}
//Is Person in Dover Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74789, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 1;
cpCampus.SelectedValue = "Dover Campus";
SelectedCampus = "Dover Campus";
}
//Is Person in Millersburg Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74790, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 4;
cpCampus.SelectedValue = "Millersburg Campus";
SelectedCampus = "Millersburg Campus";
}
//Is Person in Wooster Campus?
if (groupMemberService.GetByGroupIdAndPersonId(74791, (int)CurrentPersonId).Any() == true)
{
SelectedCampusId = 6;
cpCampus.SelectedValue = "Wooster Campus";
SelectedCampus = "Wooster Campus";
}
//Is Person in Central?
if (groupMemberService.GetByGroupIdAndPersonId(74785, (int)CurrentPersonId).Any() == true)
{
cpCampus.SelectedValue = "All Org";
SelectedCampus = "All Org";
SelectedCampusId = 0;
}
}
DoSQL();
}
示例4: 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();
//.........这里部分代码省略.........
示例5: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <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( Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
DateTime startDateTime = DateTime.Now;
int securityCodeLength = 3;
if ( !int.TryParse( GetAttributeValue( action, "SecurityCodeLength" ), out securityCodeLength ) )
{
securityCodeLength = 3;
}
using ( var uow = new Rock.Data.UnitOfWorkScope() )
{
var attendanceCodeService = new AttendanceCodeService();
var attendanceService = new AttendanceService();
var groupMemberService = new GroupMemberService();
foreach ( var family in checkInState.CheckIn.Families.Where( f => f.Selected ) )
{
foreach ( var person in family.People.Where( p => p.Selected ) )
{
var 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, null );
groupMemberService.Save( groupMember, null );
}
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 )
{
attendance = ((Rock.Data.RockContext)uow.DbContext).Attendances.Create();
attendance.LocationId = location.Location.Id;
attendance.ScheduleId = schedule.Schedule.Id;
attendance.GroupId = group.Group.Id;
attendance.PersonId = person.Person.Id;
attendance.DeviceId = checkInState.Kiosk.Device.Id;
attendance.SearchTypeValueId = checkInState.CheckIn.SearchType.Id;
attendanceService.Add( attendance, null );
}
attendance.AttendanceCodeId = attendanceCode.Id;
attendance.StartDateTime = startDateTime;
attendance.EndDateTime = null;
attendance.DidAttend = true;
attendanceService.Save( attendance, null );
KioskLocationAttendance.AddAttendance( attendance );
}
}
}
}
}
}
}
return true;
}
return false;
}
示例6: 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 );
}
}
}
}
}
}
//.........这里部分代码省略.........