public void RefreshOrphans() { Orphans.Clear(); if (ProjectBase != null) { foreach (var item in ProjectBase) { if (BuildItemViewModel.IsOrphaned(item, ProjectBase)) { Orphans.Add(new BuildItemViewModel { BuildItem = item, Owner = ProjectBase }); } } if (ProjectBase.ContentProject != ProjectBase && ProjectBase.ContentProject != null) { foreach (var item in ProjectBase.ContentProject) { if (BuildItemViewModel.IsOrphaned(item, ProjectBase)) { Orphans.Add(new BuildItemViewModel { BuildItem = item, Owner = ProjectBase }); } } } } }
public void AddPerson(Orphan orphan) { Orphans.Add(orphan); foreach (Person p in Personel) { p.AddRelation(orphan); orphan.AddRelation(p); } foreach (Orphan o in Orphans) { o.AddRelation(orphan); orphan.AddRelation(o); } }
public async Task RenderAsync(CancellationToken cancellationToken = default) { var orphanedTables = Tables .Where(t => t.ParentKeys.Empty() && t.ChildKeys.Empty()) .ToList(); var mapper = new OrphansModelMapper(); var orphanedTableViewModels = orphanedTables .Select(t => { if (!RowCounts.TryGetValue(t.Name, out var rowCount)) { rowCount = 0; } return(mapper.Map(t, rowCount)); }) .ToList(); var templateParameter = new Orphans(orphanedTableViewModels); var renderedOrphans = await Formatter.RenderTemplateAsync(templateParameter, cancellationToken).ConfigureAwait(false); var databaseName = !IdentifierDefaults.Database.IsNullOrWhiteSpace() ? IdentifierDefaults.Database + " Database" : "Database"; var pageTitle = "Orphan Tables · " + databaseName; var orphansContainer = new Container(renderedOrphans, pageTitle, string.Empty); var renderedPage = await Formatter.RenderTemplateAsync(orphansContainer, cancellationToken).ConfigureAwait(false); if (!ExportDirectory.Exists) { ExportDirectory.Create(); } var outputPath = Path.Combine(ExportDirectory.FullName, "orphans.html"); using var writer = File.CreateText(outputPath); await writer.WriteAsync(renderedPage.AsMemory(), cancellationToken).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); }