//--------------------------------------------------- protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources) { DateTime dtChrono = DateTime.Now; CResultAErreur result = CResultAErreur.True; if (Table1 == null) { result.EmpileErreur(I.T("No source @1|20006", "1")); return(result); } if (Table2 == null) { result.EmpileErreur(I.T("No source @2|20006", "2")); return(result); } result = Table1.GetDatas(sources); if (!result || !(result.Data is DataTable)) { result.EmpileErreur(I.T("Error in table @1 datas|20007", Table1.NomFinal)); return(result); } DataTable t1 = result.Data as DataTable; result = Table2.GetDatas(sources); if (!result || !(result.Data is DataTable)) { result.EmpileErreur(I.T("Error in table @1 datas|20007", Table2.NomFinal)); return(result); } DataTable t2 = result.Data as DataTable; //Trouve toutes les lignes des la table 2 correspondant à la table 1 List <CMapRows> maps1To2 = new List <CMapRows>(); if (ParametresJointure.Count() == 0) { } else { CParametreJointure param0 = m_listeParametresJointure[0]; Dictionary <object, List <DataRow> > dicValeursToRow1 = null; //Première passe : on évalue toutes les expression sur tous les enregistrement de t1 et t2 List <DataRow> lst1 = new List <DataRow>(); foreach (DataRow row in t1.Rows) { lst1.Add(row); } result = CParametreJointure.GetDicValeurs(lst1, param0.FormuleTable1, ref dicValeursToRow1); if (!result) { return(result); } Dictionary <object, List <DataRow> > dicValeursToRow2 = null; List <DataRow> lst2 = new List <DataRow>(); foreach (DataRow row in t2.Rows) { lst2.Add(row); } result = CParametreJointure.GetDicValeurs(lst2, param0.FormuleTable2, ref dicValeursToRow2); maps1To2 = GetMatches(dicValeursToRow1, dicValeursToRow2, param0.Operateur); //Passe suivantes : on évalue pour chaque paire ce ceux qui matchent for (int n = 1; n < m_listeParametresJointure.Count; n++) { CParametreJointure parametre = m_listeParametresJointure[n]; List <CMapRows> lstMaps = new List <CMapRows>(); foreach (CMapRows maps in maps1To2) { dicValeursToRow1 = null; result = CParametreJointure.GetDicValeurs(maps.Rows1, parametre.FormuleTable1, ref dicValeursToRow1); if (!result) { return(result); } dicValeursToRow2 = null; result = CParametreJointure.GetDicValeurs(maps.Rows2, parametre.FormuleTable2, ref dicValeursToRow2); lstMaps.AddRange(GetMatches(dicValeursToRow1, dicValeursToRow2, parametre.Operateur)); } maps1To2 = lstMaps; } DataTable tableResult = new DataTable(NomFinal); Dictionary <IColumnDeEasyQuery, IColumnDeEasyQuery> colsFromTable1 = new Dictionary <IColumnDeEasyQuery, IColumnDeEasyQuery>(); Dictionary <IColumnDeEasyQuery, IColumnDeEasyQuery> colsFromTable2 = new Dictionary <IColumnDeEasyQuery, IColumnDeEasyQuery>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource colFromSource = col as CColumnEQFromSource; if (colFromSource != null) { IColumnDeEasyQuery colSource = Table1.Columns.FirstOrDefault(c => c.Id == colFromSource.IdColumnSource); if (colSource != null) { colsFromTable1[col] = colSource; IColumnDeEasyQuery colSource2 = Table2.Columns.FirstOrDefault(c => c.Id == colFromSource.IdColumnSource); if (colSource2 != null) { colsFromTable2[col] = colSource2; } } else { colSource = Table2.Columns.FirstOrDefault(c => c.Id == colFromSource.IdColumnSource); if (colSource != null) { colsFromTable2[col] = colSource; } } if (colSource != null && !tableResult.Columns.Contains(col.ColumnName)) { Type tp = col.DataType; if (tp.IsGenericType && tp.GetGenericTypeDefinition() == typeof(Nullable <>)) { tp = tp.GetGenericArguments()[0]; } DataColumn dtCol = new DataColumn(col.ColumnName, tp); dtCol.ExtendedProperties[CODEQBase.c_extPropColonneId] = col.Id; tableResult.Columns.Add(dtCol); } } } foreach (CMapRows map in maps1To2) { lst1 = map.Rows1; if (lst1.Count == 0) { lst1.Add(null); } lst2 = map.Rows2; if (lst2.Count == 0) { lst2.Add(null); } foreach (DataRow row1 in lst1) { foreach (DataRow row2 in lst2) { if (row1 != null || row2 != null) { DataRow row = tableResult.NewRow(); if (row1 != null) { foreach (KeyValuePair <IColumnDeEasyQuery, IColumnDeEasyQuery> kv in colsFromTable1) { try { row[kv.Key.ColumnName] = row1[kv.Value.ColumnName]; } catch { } } } if (row2 != null) { foreach (KeyValuePair <IColumnDeEasyQuery, IColumnDeEasyQuery> kv in colsFromTable2) { try { row[kv.Key.ColumnName] = row2[kv.Value.ColumnName]; } catch { } } } tableResult.Rows.Add(row); } } } } tableResult.AcceptChanges(); result.Data = tableResult; } TimeSpan sp = DateTime.Now - dtChrono; Console.WriteLine("Join " + NomFinal + " : " + sp.TotalMilliseconds.ToString()); return(result); }