本文整理汇总了C#中Schedule.GetOccurrences方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.GetOccurrences方法的具体用法?C# Schedule.GetOccurrences怎么用?C# Schedule.GetOccurrences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schedule
的用法示例。
在下文中一共展示了Schedule.GetOccurrences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowReadonlyDetails
/// <summary>
/// Shows the readonly details.
/// </summary>
/// <param name="schedule">The schedule.</param>
private void ShowReadonlyDetails( Schedule schedule )
{
SetEditMode( false );
hfScheduleId.SetValue( schedule.Id );
lReadOnlyTitle.Text = schedule.Name.FormatAsHtmlTitle();
string occurrenceText = string.Empty;
var occurrences = schedule.GetOccurrences( RockDateTime.Now, RockDateTime.Now.AddYears( 1 ) );
if ( occurrences.Any() )
{
occurrenceText = GetOccurrenceText( occurrences[0] );
}
if ( schedule.CategoryId.HasValue )
{
var today = RockDateTime.Today;
var nextYear = today.AddYears( 1 );
var exclusions = new List<string>();
foreach ( var exclusion in new ScheduleCategoryExclusionService( new RockContext() )
.Queryable().AsNoTracking()
.Where( e =>
e.CategoryId == schedule.CategoryId.Value &&
e.EndDate >= today &&
e.StartDate < nextYear )
.OrderBy( e => e.StartDate ) )
{
exclusions.Add( string.Format( "<strong>{0}</strong>: {1} - {2}",
exclusion.Title, exclusion.StartDate.ToShortDateString(), exclusion.EndDate.ToShortDateString() ) );
}
if ( exclusions.Any() )
{
nbExclusions.Text = string.Format( "<p>This schedule will not be active during the following dates due to being excluded by the schedule's category:</p><p>{0}</p>",
exclusions.AsDelimited( "<br/>" ) );
nbExclusions.Visible = true;
}
}
var friendlyText = schedule.ToFriendlyScheduleText();
if ( schedule.HasScheduleWarning() )
{
friendlyText = string.Format( "<label class='label label-warning'>{0}</label> <i class='fa fa-exclamation-triangle text-warning'></i>", friendlyText );
}
DescriptionList descriptionList = new DescriptionList()
.Add( "Description", schedule.Description ?? string.Empty )
.Add( "Schedule", friendlyText )
.Add( "Next Occurrence", occurrenceText )
.Add( "Category", schedule.Category != null ? schedule.Category.Name : string.Empty );
if ( schedule.CheckInStartOffsetMinutes.HasValue )
{
descriptionList.Add( "Check-in Starts", schedule.CheckInStartOffsetMinutes.Value.ToString() + " minutes before start of schedule" );
}
if ( schedule.CheckInEndOffsetMinutes.HasValue )
{
descriptionList.Add( "Check-in Ends", schedule.CheckInEndOffsetMinutes.Value.ToString() + " minutes after start of schedule" );
}
lblMainDetails.Text = descriptionList.Html;
}