当前位置: 首页>>代码示例>>C#>>正文


C# Schedule.ToFriendlyScheduleText方法代码示例

本文整理汇总了C#中Schedule.ToFriendlyScheduleText方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.ToFriendlyScheduleText方法的具体用法?C# Schedule.ToFriendlyScheduleText怎么用?C# Schedule.ToFriendlyScheduleText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schedule的用法示例。


在下文中一共展示了Schedule.ToFriendlyScheduleText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();

            var calendarEvent = schedule.GetCalenderEvent();
            string occurrenceText = string.Empty;
            if ( calendarEvent != null )
            {
                if ( calendarEvent.DTStart != null )
                {
                    var occurrences = calendarEvent.GetOccurrences( RockDateTime.Now, RockDateTime.Now.AddYears( 1 ) );
                    if ( occurrences.Any() )
                    {
                        occurrenceText = GetOccurrenceText( occurrences[0] );
                    }
                }
            }

            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;
        }
开发者ID:SparkDevNetwork,项目名称:Rock,代码行数:48,代码来源:ScheduleDetail.ascx.cs

示例2: 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;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:67,代码来源:ScheduleDetail.ascx.cs


注:本文中的Schedule.ToFriendlyScheduleText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。