Beispiel #1
0
        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="dataView">The data view.</param>
        private void ShowReadonlyDetails( DataView dataView )
        {
            SetEditMode( false );
            hfDataViewId.SetValue( dataView.Id );
            lReadOnlyTitle.Text = dataView.Name.FormatAsHtmlTitle();
            hlblDataViewId.Text = "Id: " + dataView.Id.ToString();

            lDescription.Text = dataView.Description;

            DescriptionList descriptionListMain = new DescriptionList();

            if ( dataView.EntityType != null )
            {
                descriptionListMain.Add( "Applies To", dataView.EntityType.FriendlyName );
            }

            if ( dataView.Category != null )
            {
                descriptionListMain.Add( "Category", dataView.Category.Name );
            }

            if ( dataView.TransformEntityType != null )
            {
                descriptionListMain.Add( "Post-filter Transformation", dataView.TransformEntityType.FriendlyName );
            }

            lblMainDetails.Text = descriptionListMain.Html;

            DescriptionList descriptionListFilters = new DescriptionList();

            if ( dataView.DataViewFilter != null && dataView.EntityTypeId.HasValue )
            {
                var entityTypeCache = EntityTypeCache.Read( dataView.EntityTypeId.Value );
                if ( entityTypeCache != null )
                {
                    var entityTypeType = entityTypeCache.GetEntityType();
                    if ( entityTypeType != null )
                    {
                        descriptionListFilters.Add( "Filter", dataView.DataViewFilter.ToString( entityTypeType ) );
                    }
                }
            }

            lFilters.Text = descriptionListFilters.Html;

            DescriptionList descriptionListDataviews = new DescriptionList();
            var dataViewFilterEntityId = EntityTypeCache.Read( typeof( Rock.Reporting.DataFilter.OtherDataViewFilter ) ).Id;

            var rockContext = new RockContext();
            DataViewService dataViewService = new DataViewService( rockContext );

            var dataViews = dataViewService.Queryable()
                .Where( d => d.DataViewFilter.ChildFilters
                    .Any( f => f.Selection == dataView.Id.ToString()
                        && f.EntityTypeId == dataViewFilterEntityId ) );

            StringBuilder sbDataViews = new StringBuilder();
            var dataViewDetailPage = GetAttributeValue( "DataViewDetailPage" );

            foreach ( var dataview in dataViews )
            {
                if ( !string.IsNullOrWhiteSpace( dataViewDetailPage ) )
                {
                    sbDataViews.Append( "<a href=\"" + LinkedPageUrl( "DataViewDetailPage", new Dictionary<string, string>() { { "DataViewId", dataview.Id.ToString() } } ) + "\">" + dataview.Name + "</a><br/>" );
                }
                else
                {
                    sbDataViews.Append( dataview.Name + "<br/>" );
                }
            }

            descriptionListDataviews.Add( "Data Views", sbDataViews );
            lDataViews.Text = descriptionListDataviews.Html;

            DescriptionList descriptionListReports = new DescriptionList();
            StringBuilder sbReports = new StringBuilder();

            ReportService reportService = new ReportService( rockContext );
            var reports = reportService.Queryable().Where( r => r.DataViewId == dataView.Id );
            var reportDetailPage = GetAttributeValue( "ReportDetailPage" );

            foreach ( var report in reports )
            {
                if ( !string.IsNullOrWhiteSpace( reportDetailPage ) )
                {
                    sbReports.Append( "<a href=\"" + LinkedPageUrl( "ReportDetailPage", new Dictionary<string, string>() { { "ReportId", report.Id.ToString() } } ) + "\">" + report.Name + "</a><br/>" );
                }
                else
                {
                    sbReports.Append( report.Name + "<br/>" );
                }
            }

            descriptionListReports.Add( "Reports", sbReports );
            lReports.Text = descriptionListReports.Html;

            ShowReport( dataView );
        }
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        protected void LoadDropDowns()
        {
            var rockContext = new RockContext();
            var reportService = new ReportService( rockContext );
            var reportQry = reportService.Queryable().OrderBy( a => a.Name );

            ddlReport.Items.Clear();
            ddlReport.Items.Add( new ListItem() );
            foreach ( var report in reportQry.ToList() )
            {
                ddlReport.Items.Add( new ListItem( report.Name, report.Guid.ToString() ) );
            }
        }
Beispiel #3
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            RockContext rockContext = new RockContext();
            ReportService reportService = new ReportService( rockContext );

            Guid reportCategory = new Guid(GetAttributeValue( "ReportCategory" ));

            // sample query to display a few people
            var qry = reportService.Queryable()
                        .Where( r => r.Category.Guid == reportCategory );

            gList.DataSource = qry.ToList();
            gList.DataBind();
        }