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


C# LocationService.GetPath方法代码示例

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


在下文中一共展示了LocationService.GetPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindFilter

        /// <summary>
        /// Binds the filter.
        /// </summary>
        protected void BindFilter()
        {
            string dateRangePreference = rFilter.GetUserPreference( MakeKeyUniqueToGroup( "Date Range" ) );
            if ( string.IsNullOrWhiteSpace( dateRangePreference ) )
            {
                // set the dateRangePreference to force rFilter_DisplayFilterValue to show our default three month limit
                dateRangePreference = ",";
                rFilter.SaveUserPreference( MakeKeyUniqueToGroup( "Date Range" ), "Date Range", dateRangePreference );
            }

            var dateRange = DateRangePicker.CalculateDateRangeFromDelimitedValues( dateRangePreference );

            // if there is no start date, default to three months ago to minimize the chance of loading too much data
            drpDates.LowerValue = dateRange.Start ?? RockDateTime.Today.AddMonths( -3 );
            drpDates.UpperValue = dateRange.End;

            if ( _group != null )
            {
                var grouplocations = _group.GroupLocations
                    .Where( l =>
                        l.Location.Name != null &&
                        l.Location.Name != string.Empty )
                    .ToList();

                var locations = new Dictionary<string, string> { { string.Empty, string.Empty } };

                var locationService = new LocationService( _rockContext );
                foreach ( var location in grouplocations.Select( l => l.Location ) )
                {
                    if ( !locations.ContainsKey( location.Id.ToString() ) )
                    {
                        locations.Add( location.Id.ToString(), locationService.GetPath( location.Id ) );
                    }

                    var parentLocation = location.ParentLocation;
                    while ( parentLocation != null )
                    {
                        string key = string.Format( "P{0}", parentLocation.Id );
                        if ( !locations.ContainsKey( key ) )
                        {
                            locations.Add( key, locationService.GetPath( parentLocation.Id ) );
                        }

                        parentLocation = parentLocation.ParentLocation;
                    }
                }

                if ( locations.Any() )
                {
                    ddlLocation.Visible = true;
                    gOccurrences.Columns[2].Visible = true;
                    ddlLocation.DataSource = locations.OrderBy( l => l.Value );
                    ddlLocation.DataBind();
                    ddlLocation.SetValue( rFilter.GetUserPreference( MakeKeyUniqueToGroup( "Location" ) ) );
                }
                else
                {
                    ddlLocation.Visible = false;
                    gOccurrences.Columns[2].Visible = false;
                }

                var schedules = new Dictionary<int, string> { { 0, string.Empty } };
                grouplocations.SelectMany( l => l.Schedules ).OrderBy( s => s.Name ).ToList()
                    .ForEach( s => schedules.AddOrIgnore( s.Id, s.Name ) );

                if ( schedules.Any() )
                {
                    ddlSchedule.Visible = true;
                    gOccurrences.Columns[1].Visible = true;
                    ddlSchedule.DataSource = schedules;
                    ddlSchedule.DataBind();
                    ddlSchedule.SetValue( rFilter.GetUserPreference( MakeKeyUniqueToGroup( "Schedule" ) ) );
                }
                else
                {
                    ddlSchedule.Visible = false;
                    gOccurrences.Columns[1].Visible = false;
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:83,代码来源:GroupAttendanceList.ascx.cs

示例2: BindLocations

        /// <summary>
        /// Loads the dropdowns.
        /// </summary>
        private void BindLocations()
        {
            var locations = new Dictionary<int, string> { { 0, "" } };

            if ( _group != null )
            {
                var locationPaths = new Dictionary<int, string>();
                var locationService = new LocationService( _rockContext );

                foreach ( var location in _group.GroupLocations
                    .Where( l =>
                        l.Location.Name != null &&
                        l.Location.Name != "" )
                    .Select( l => l.Location ) )
                {
                    // Get location path
                    string parentLocationPath = string.Empty;
                    if ( location.ParentLocationId.HasValue )
                    {
                        var locId = location.ParentLocationId.Value;
                        if ( !locationPaths.ContainsKey( locId ) )
                        {
                            locationPaths.Add( locId, locationService.GetPath( locId ) );
                        }
                        parentLocationPath = locationPaths[locId];
                    }

                    if ( !locations.ContainsKey( location.Id ) )
                    {
                        locations.Add( location.Id, new List<string> { parentLocationPath, location.Name }.AsDelimited( " > " ) );
                    }
                }
            }

            if ( locations.Any() )
            {
                ddlLocation.DataSource = locations;
                ddlLocation.DataBind();
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:43,代码来源:GroupAttendanceDetail.ascx.cs

示例3: GetGroupOccurrences

        /// <summary>
        /// Gets occurrence data for the selected group
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="fromDateTime">From date time.</param>
        /// <param name="toDateTime">To date time.</param>
        /// <param name="locationIds">The location ids.</param>
        /// <param name="scheduleIds">The schedule ids.</param>
        /// <param name="loadSummaryData">if set to <c>true</c> [load summary data].</param>
        /// <returns></returns>
        public List<ScheduleOccurrence> GetGroupOccurrences( Group group, DateTime? fromDateTime, DateTime? toDateTime, 
            List<int> locationIds, List<int> scheduleIds, bool loadSummaryData )
        {
            var occurrences = new List<ScheduleOccurrence>();

            if ( group != null )
            {
                var rockContext = (RockContext)this.Context;
                var attendanceService = new AttendanceService( rockContext );
                var scheduleService = new ScheduleService( rockContext );
                var locationService = new LocationService( rockContext );

                // Set up an 'occurrences' query for the group
                var qry = attendanceService
                    .Queryable().AsNoTracking()
                    .Where( a => a.GroupId == group.Id );

                // Filter by date range
                if ( fromDateTime.HasValue )
                {
                    var fromDate = fromDateTime.Value.Date;
                    qry = qry.Where( a => DbFunctions.TruncateTime( a.StartDateTime ) >= ( fromDate ) );
                }
                if ( toDateTime.HasValue )
                {
                    var toDate = toDateTime.Value.Date;
                    qry = qry.Where( a => DbFunctions.TruncateTime( a.StartDateTime ) < ( toDate ) );
                }

                // Location Filter
                if ( locationIds.Any()  )
                {
                    qry = qry.Where( a =>
                        a.LocationId.HasValue &&
                        locationIds.Contains( a.LocationId.Value ) );
                }

                // Schedule Filter
                if ( scheduleIds.Any() )
                {
                    qry = qry.Where( a =>
                        a.ScheduleId.HasValue &&
                        scheduleIds.Contains( a.ScheduleId.Value ) );
                }

                // Get the unique combination of location/schedule/date for the selected group
                var occurrenceDates = qry
                    .Select( a => new
                    {
                        a.LocationId,
                        a.ScheduleId,
                        Date = DbFunctions.TruncateTime( a.StartDateTime )
                    } )
                    .Distinct()
                    .ToList();

                // Get the locations for each unique location id
                var selectedlocationIds = occurrenceDates.Select( o => o.LocationId ).Distinct().ToList();
                var locations = locationService
                    .Queryable().AsNoTracking()
                    .Where( l => selectedlocationIds.Contains( l.Id ) )
                    .Select( l => new { l.Id, l.ParentLocationId, l.Name } )
                    .ToList();
                var locationNames = new Dictionary<int, string>();
                locations.ForEach( l => locationNames.Add( l.Id, l.Name ) );

                // Get the parent location path for each unique location
                var parentlocationPaths = new Dictionary<int, string>();
                locations
                    .Where( l => l.ParentLocationId.HasValue )
                    .Select( l => l.ParentLocationId.Value )
                    .Distinct()
                    .ToList()
                    .ForEach( l => parentlocationPaths.Add( l, locationService.GetPath( l ) ) );
                var locationPaths = new Dictionary<int, string>();
                locations
                    .Where( l => l.ParentLocationId.HasValue )
                    .ToList()
                    .ForEach( l => locationPaths.Add( l.Id, parentlocationPaths[l.ParentLocationId.Value] ) );

                // Get the schedules for each unique schedule id
                var selectedScheduleIds = occurrenceDates.Select( o => o.ScheduleId ).Distinct().ToList();
                var schedules = scheduleService
                    .Queryable().AsNoTracking()
                    .Where( s => selectedScheduleIds.Contains( s.Id ) )
                    .ToList();
                var scheduleNames = new Dictionary<int, string>();
                var scheduleStartTimes = new Dictionary<int, TimeSpan>();
                schedules
                    .ForEach( s => {
//.........这里部分代码省略.........
开发者ID:azturner,项目名称:Rock,代码行数:101,代码来源:ScheduleService.Partial.cs


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