/// <summary> /// Job that will run quick SQL queries on a schedule. /// /// Called by the <see cref="IScheduler" /> when a /// <see cref="ITrigger" /> fires that is associated with /// the <see cref="IJob" />. /// </summary> public virtual void Execute( IJobExecutionContext context ) { JobDataMap dataMap = context.JobDetail.JobDataMap; Stopwatch stopwatch; RockContext rockContext = new RockContext(); var entityTypes = new EntityTypeService( rockContext ) .Queryable().AsNoTracking().ToList(); var indexableEntityTypes = entityTypes.Where( e => e.IsIndexingSupported == true && e.IsIndexingEnabled == true ) .ToList(); StringBuilder results = new StringBuilder(); foreach(var entityType in indexableEntityTypes ) { Type type = Type.GetType( entityType.AssemblyName ); if ( type != null ) { object classInstance = Activator.CreateInstance( type, null ); MethodInfo bulkItemsMethod = type.GetMethod( "BulkIndexDocuments" ); if ( classInstance != null && bulkItemsMethod != null ) { stopwatch = Stopwatch.StartNew(); bulkItemsMethod.Invoke( classInstance, null ); stopwatch.Stop(); results.Append( string.Format(" {0} in {1}s,", entityType.FriendlyName, stopwatch.ElapsedMilliseconds/1000 ) ); } } } context.Result = results.ToString().TrimEnd(','); }
/// <summary> /// Binds the filter. /// </summary> private void BindFilter() { // Exclude the categories for block and service job attributes, since they are controlled through code attribute decorations var exclusions = new List<Guid>(); exclusions.Add( Rock.SystemGuid.EntityType.BLOCK.AsGuid() ); exclusions.Add( Rock.SystemGuid.EntityType.SERVICE_JOB.AsGuid() ); var rockContext = new RockContext(); var entityTypes = new EntityTypeService( rockContext ).GetEntities() .Where( t => !exclusions.Contains( t.Guid ) ) .OrderBy( t => t.FriendlyName ) .ToList(); entityTypePicker.EntityTypes = entityTypes; // Load Entity Type Filter var attributeEntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id; var categoryEntities = new CategoryService( rockContext ).Queryable() .Where( c => c.EntityTypeId == attributeEntityTypeId && c.EntityTypeQualifierColumn == "EntityTypeId" && c.EntityTypeQualifierValue != null ) .Select( c => c.EntityTypeQualifierValue ) .ToList() .Select( c => c.AsInteger() ); entityTypeFilter.EntityTypes = entityTypes.Where( e => categoryEntities.Contains( e.Id ) ).ToList(); entityTypeFilter.SelectedValue = rFilter.GetUserPreference( "EntityType" ); }
/// <summary> /// Loads the entities. /// </summary> private void LoadEntities() { using ( RockContext rockContext = new RockContext() ) { var entities = new EntityTypeService( rockContext ).Queryable().AsNoTracking().ToList(); var indexableEntities = entities.Where( e => e.IsIndexingSupported == true ).ToList(); gEntityList.DataSource = indexableEntities; gEntityList.DataBind(); } }
/// <summary> /// Binds the filter. /// </summary> private void BindFilter() { var rockContext = new RockContext(); var entityTypes = new EntityTypeService( rockContext ).GetEntities() .OrderBy( t => t.FriendlyName ) .ToList(); entityTypePicker.EntityTypes = entityTypes; // Load Entity Type Filter var noteTypeEntities = new NoteTypeService( rockContext ).Queryable() .Select( c => c.EntityTypeId ) .Distinct() .ToList(); entityTypeFilter.EntityTypes = entityTypes.Where( e => noteTypeEntities.Contains( e.Id ) ).ToList(); entityTypeFilter.SetValue( rFilter.GetUserPreference( "EntityType" ) ); }