public ViewWithNoTable(TableAnalysisResult tr, IWin32Window own) { _own = own; ParentTableResult = tr; }
private void Analyse(object sender, DoWorkEventArgs e) { string lastError; var dc = DataTools.Data(SqlCommands.SqlGetTable(), Program.AppSet.ConnectionString, out lastError); List <string> tableList = new List <string>(); //search in table list and attach corresponding view foreach (DataRow dcr in dc.Rows) { var attachedView = TabloidConfig.Config.Views.Where(c => string.Equals(c.NomTable, dcr[0].ToString(), StringComparison.InvariantCultureIgnoreCase)).ToList(); tableList.Add(dcr[0].ToString()); var result = new TableAnalysisResult { TableName = dcr[0].ToString(), Views = attachedView }; if (attachedView.Count == 0) { result.Results.Add(new TableWithNoView(result, this)); } _results.Add(result); } foreach (TabloidConfigView v in TabloidConfig.Config.Views) { var result = new TableAnalysisResult { TableName = null }; result.Views.Add(v); if (!tableList.Contains(v.NomTable, StringComparer.OrdinalIgnoreCase))//search view with no table { result.Results.Add(new ViewWithNoTable(result, this)); } var joinList = v.Jointures.GetJointures(VisibiliteTools.GetFullVisibilite(), true); if (joinList.Count > 0) { var dfk = DataTools.Data(SqlCommands.SqlGetForeignKey(v.NomTable, v.Schema), Program.AppSet.ConnectionString, out lastError); foreach (TabloidConfigJointure j in joinList) { if (j.Relation == "N:1" || string.IsNullOrEmpty(j.Relation)) { var sql = $"{dfk.Columns[0].ColumnName}='{j.ChampDeRef}' and {dfk.Columns[1].ColumnName}='{j.NomTable}' and {dfk.Columns[2].ColumnName}='{j.DbKey}'"; if (dfk.Select(sql).Count() == 0) { result.Results.Add(new JoinWithNoConstraint(j, v, this)); } } } } if (result.Results.Count > 0) { _results.Add(result); } } }