private async Task <IEnumerable <ImportingJobDescriptor> > HarvestImportJobAsync(IFeatureInfo feature, bool isDemo) { var initManifests = new SeedManifestCollection(); var demoManifests = new SeedManifestCollection(); var startup = await _s2StartupService.GetOrDefaultByFeatureAsync(feature); if (startup == null) { return(new ImportingJobDescriptor[] { }); } startup.ConfigureSeeds(initManifests, demoManifests); var descriptors = isDemo ? demoManifests : initManifests; var allJobs = new List <ImportingJobDescriptor>(); foreach (var descriptor in descriptors) { var jobs = await this.HarvestManifestAsync(feature, descriptor.Path); allJobs.AddRange(jobs); } return(allJobs); }
public async Task <IEnumerable <IViewDefinition> > HarvestAsync(IFeatureInfo feature) { var featureStartup = await _s2StartupService.GetOrDefaultByFeatureAsync(feature); if (featureStartup == null) { return(new IViewDefinition[] { }); } var viewFiles = new ViewDefinitionsCollection(); featureStartup.ConfigureViews(viewFiles); var defs = new List <IViewDefinition>(); foreach (var vf in viewFiles) { //读取文件 var viewFilePath = Path.Combine("Areas", feature.Id, vf.Path); var viewFileInfo = _environment.ContentRootFileProvider.GetFileInfo(viewFilePath); if (!viewFileInfo.Exists) { throw new FileNotFoundException($"File not found: '{viewFilePath}'", viewFilePath); } this.Logger.LogInformation($"View definition file found: {viewFilePath}"); using (var vfs = viewFileInfo.CreateReadStream()) { var viewDefinitions = await _xaml.LoadAsync <S2ViewDefinitions>(vfs); foreach (var vd in viewDefinitions.Definitions) { if (string.IsNullOrEmpty(vd.Feature)) { vd.Feature = feature.Id; } } defs.AddRange(viewDefinitions.Definitions); } } return(defs); }