本文整理汇总了C#中Rock.AddLogEntry方法的典型用法代码示例。如果您正苦于以下问题:C# Rock.AddLogEntry方法的具体用法?C# Rock.AddLogEntry怎么用?C# Rock.AddLogEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock
的用法示例。
在下文中一共展示了Rock.AddLogEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, Rock.Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState == null )
{
return false;
}
var roomBalanceGroupTypes = GetAttributeValue( action, "RoomBalanceGrouptypes" ).SplitDelimitedValues().AsGuidList();
bool useGroupMembership = GetAttributeValue( action, "PrioritizeGroupMembership" ).AsBoolean();
int roomBalanceOverride = GetAttributeValue( action, "BalancingOverride" ).AsIntegerOrNull() ?? 5;
var excludedLocations = GetAttributeValue( action, "ExcludedLocations" ).SplitDelimitedValues( false )
.Select( s => s.Trim() );
// get admin-selected attribute keys instead of using a hardcoded key
var personSpecialNeedsKey = string.Empty;
var personSpecialNeedsGuid = GetAttributeValue( action, "PersonSpecialNeedsAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
personSpecialNeedsKey = AttributeCache.Read( personSpecialNeedsGuid, rockContext ).Key;
}
var groupSpecialNeedsKey = string.Empty;
var groupSpecialNeedsGuid = GetAttributeValue( action, "GroupSpecialNeedsAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupSpecialNeedsKey = AttributeCache.Read( groupSpecialNeedsGuid, rockContext ).Key;
}
var groupAgeRangeKey = string.Empty;
var groupAgeRangeGuid = GetAttributeValue( action, "GroupAgeRangeAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupAgeRangeKey = AttributeCache.Read( groupAgeRangeGuid, rockContext ).Key;
}
var groupGradeRangeKey = string.Empty;
var groupGradeRangeGuid = GetAttributeValue( action, "GroupGradeRangeAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupGradeRangeKey = AttributeCache.Read( groupGradeRangeGuid, rockContext ).Key;
}
// log a warning if any of the attributes are missing or invalid
if ( string.IsNullOrWhiteSpace( personSpecialNeedsKey ) )
{
action.AddLogEntry( string.Format( "The Person Special Needs attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupSpecialNeedsKey ) )
{
action.AddLogEntry( string.Format( "The Group Special Needs attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupAgeRangeKey ) )
{
action.AddLogEntry( string.Format( "The Group Age Range attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupGradeRangeKey ) )
{
action.AddLogEntry( string.Format( "The Group Grade Range attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
var family = checkInState.CheckIn.Families.FirstOrDefault( f => f.Selected );
if ( family != null )
{
// don't process people who already have assignments
foreach ( var person in family.People.Where( f => f.Selected && !f.GroupTypes.Any( gt => gt.Selected ) ) )
{
decimal baseVariance = 100;
char[] delimiter = { ',' };
// check if this person has special needs
var hasSpecialNeeds = person.Person.GetAttributeValue( personSpecialNeedsKey ).AsBoolean();
// get a list of room balanced grouptype ID's since CheckInGroup model is a shallow clone
var roomBalanceGroupTypeIds = person.GroupTypes.Where( gt => roomBalanceGroupTypes.Contains( gt.GroupType.Guid ) )
.Select( gt => gt.GroupType.Id ).ToList();
if ( person.GroupTypes.Count > 0 )
{
CheckInGroupType bestGroupType = null;
IEnumerable<CheckInGroup> validGroups;
if ( person.GroupTypes.Count == 1 )
{
bestGroupType = person.GroupTypes.FirstOrDefault();
validGroups = bestGroupType.Groups;
}
else
{
//.........这里部分代码省略.........
示例2: 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, Rock.Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState == null )
{
return false;
}
int selectFromDaysBack = checkInState.CheckInType.AutoSelectDaysBack;
var roomBalanceGroupTypes = GetAttributeValue( action, "RoomBalanceGrouptypes" ).SplitDelimitedValues().AsGuidList();
int roomBalanceOverride = GetAttributeValue( action, "BalancingOverride" ).AsIntegerOrNull() ?? 5;
int maxAssignments = GetAttributeValue( action, "MaxAssignments" ).AsIntegerOrNull() ?? 5;
var excludedLocations = GetAttributeValue( action, "ExcludedLocations" ).SplitDelimitedValues( whitespace: false )
.Select( s => s.Trim() );
var personSpecialNeedsKey = string.Empty;
var personSpecialNeedsGuid = GetAttributeValue( action, "PersonSpecialNeedsAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
personSpecialNeedsKey = AttributeCache.Read( personSpecialNeedsGuid, rockContext ).Key;
}
// log a warning if the attribute is missing or invalid
if ( string.IsNullOrWhiteSpace( personSpecialNeedsKey ) )
{
action.AddLogEntry( string.Format( "The Person Special Needs attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
var family = checkInState.CheckIn.Families.FirstOrDefault( f => f.Selected );
if ( family != null )
{
var cutoffDate = RockDateTime.Today.AddDays( selectFromDaysBack * -1 );
var attendanceService = new AttendanceService( rockContext );
// only process people who have been here before
foreach ( var previousAttender in family.People.Where( p => p.Selected && !p.FirstTime ) )
{
// get a list of this person's available grouptypes
var availableGroupTypeIds = previousAttender.GroupTypes.Select( gt => gt.GroupType.Id ).ToList();
// order by most recent attendance
var lastDateAttendances = attendanceService.Queryable().Where( a =>
a.PersonAlias.PersonId == previousAttender.Person.Id &&
availableGroupTypeIds.Contains( a.Group.GroupTypeId ) &&
a.StartDateTime >= cutoffDate && a.DidAttend == true )
.OrderByDescending( a => a.StartDateTime ).Take( maxAssignments )
.ToList();
if ( lastDateAttendances.Any() )
{
var assignmentsGiven = 0;
// get the most recent day, then start with the earliest attendances
var lastAttended = lastDateAttendances.Max( a => a.StartDateTime ).Date;
var numAttendances = lastDateAttendances.Count( a => a.StartDateTime >= lastAttended );
foreach ( var groupAttendance in lastDateAttendances.Where( a => a.StartDateTime >= lastAttended ).OrderBy( a => a.Schedule.StartTimeOfDay ) )
{
bool currentlyCheckedIn = false;
var serviceCutoff = groupAttendance.StartDateTime;
if ( serviceCutoff > RockDateTime.Now.Date )
{
// calculate the service window to determine if people are still checked in
var serviceTime = groupAttendance.StartDateTime.Date + groupAttendance.Schedule.NextStartDateTime.Value.TimeOfDay;
var serviceStart = serviceTime.AddMinutes( ( groupAttendance.Schedule.CheckInStartOffsetMinutes ?? 0 ) * -1.0 );
serviceCutoff = serviceTime.AddMinutes( ( groupAttendance.Schedule.CheckInEndOffsetMinutes ?? 0 ) );
currentlyCheckedIn = RockDateTime.Now > serviceStart && RockDateTime.Now < serviceCutoff;
}
// override exists in case they are currently checked in or have special needs
bool useCheckinOverride = currentlyCheckedIn || previousAttender.Person.GetAttributeValue( personSpecialNeedsKey ).AsBoolean();
// get a list of room balanced grouptype ID's since CheckInGroup model is a shallow clone
var roomBalanceGroupTypeIds = previousAttender.GroupTypes.Where( gt => roomBalanceGroupTypes.Contains( gt.GroupType.Guid ) )
.Select( gt => gt.GroupType.Id ).ToList();
// Start with filtered groups unless they have abnormal age and grade parameters (1%)
var groupType = previousAttender.GroupTypes.FirstOrDefault( gt => gt.GroupType.Id == groupAttendance.Group.GroupTypeId && ( !gt.ExcludedByFilter || useCheckinOverride ) );
if ( groupType != null )
{
// get available schedules and order earliest first
var availableSchedules = groupType.Groups.SelectMany( g => g.Locations.Where( l => l.IsActiveAndNotFull ).SelectMany( l => l.Schedules ) )
.DistinctBy( s => s.Schedule.Id ).OrderBy( s => s.Schedule.StartTimeOfDay ).ToList();
// select the schedule first so group/location attendance can be filtered by schedule
CheckInSchedule schedule = null;
if ( availableSchedules.Count == 1 )
{
schedule = availableSchedules.FirstOrDefault( s => !s.ExcludedByFilter || useCheckinOverride );
}
else
{
// only use for current check-ins, otherwise SN might get the wrong schedule
//.........这里部分代码省略.........