/// <summary> /// Loads Rock data that's used globally by the transform /// </summary> private void LoadRockData( RockContext lookupContext = null ) { lookupContext = lookupContext ?? new RockContext(); // initialize storage providers and file types LoadStorageProviders(); FileTypes = new BinaryFileTypeService( lookupContext ).Queryable().AsNoTracking().ToList(); // core-specified blacklist files FileTypeBlackList = ( GlobalAttributesCache.Read().GetValue( "ContentFiletypeBlacklist" ) ?? string.Empty ).Split( new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries ); // clean up blacklist FileTypeBlackList = FileTypeBlackList.Select( a => a.ToLower().TrimStart( new char[] { '.', ' ' } ) ); // get all the file types we'll be importing var binaryTypeSettings = ConfigurationManager.GetSection( "binaryFileTypes" ) as NameValueCollection; // create any custom types that don't exist yet foreach ( var typeKey in binaryTypeSettings.AllKeys ) { var fileType = FileTypes.FirstOrDefault( f => f.Name == typeKey ); // create new binary file type if it doesn't exist if ( fileType == null ) { fileType = new BinaryFileType(); fileType.Name = typeKey; fileType.Description = typeKey; fileType.AllowCaching = true; var typeValue = binaryTypeSettings[typeKey]; if ( typeValue != null ) { var storageProvider = StorageProviders.FirstOrDefault( p => p.TypeName.RemoveWhitespace().EndsWith( typeValue.RemoveWhitespace() ) ); if ( storageProvider != null ) { // ensure the storage provider is active fileType.StorageEntityTypeId = storageProvider.EntityType.Id; lookupContext.BinaryFileTypes.Add( fileType ); lookupContext.SaveChanges(); FileTypes.Add( fileType ); } else { LogException( "Binary File Import", string.Format( "{0} must use the name of a configured storage provider.", typeKey ) ); } } else { LogException( "Binary File Import", string.Format( "{0} must specify the storage provider type.", typeKey ) ); } } } // load attributes on file types foreach ( var type in FileTypes ) { type.LoadAttributes( lookupContext ); } // get a list of all the imported people keys var personAliasList = new PersonAliasService( lookupContext ).Queryable().AsNoTracking().ToList(); ImportedPeople = personAliasList.Select( pa => new PersonKeys() { PersonAliasId = pa.Id, PersonId = pa.PersonId, IndividualId = pa.ForeignId, } ).ToList(); }