/// ////////////////////////////////////////// ///<summary> ///Ajoute les nouveaux éléments à partir du domaine Secondaire ///</summary> public CResultAErreur AjouteNouveaux(CContexteDonneesSynchroSecondaire donneesSecondaires) { CResultAErreur result = CResultAErreur.True; ArrayList lst = donneesSecondaires.GetTablesOrderInsert(); DataTable tableEntreesLog = donneesSecondaires.GetTableSafe(CEntreeLogSynchronisation.c_nomTable); foreach (DataTable table in lst) { if (m_mappeurTablesToClass.IsSynchronisable(table.TableName)) { //int nIdMaxInSecondaire = (int)table.ExtendedProperties[CContexteDonneesSynchroSecondaire.c_extMaxIdInBase]; //int nIdMaxInMain = (int)table.ExtendedProperties[CContexteDonneesSynchroSecondaire.c_extMaxIdInBase]; int nNextId = 0; //Math.Max(nIdMaxInMain, nIdMaxInSecondaire)+1; DataTable tableDest = Tables[table.TableName]; DataView view = new DataView(tableEntreesLog); string strFiltre = CEntreeLogSynchronisation.c_champTable + "='" + table.TableName + "'"; view.RowFilter = strFiltre; foreach (DataRowView row in view) { CEntreeLogSynchronisation entree = new CEntreeLogSynchronisation(row.Row); if (entree.TypeModif == CEntreeLogSynchronisation.TypeModifLogSynchro.tAdd) { CObjetDonneeAIdNumerique obj = entree.GetObjet(); DataRow newRow = CopieToNew(obj.Row, tableDest, nNextId); nNextId++; m_mapOldRowToNewRow[obj.Row.Row] = newRow; m_tableAjouts[table.TableName + "_" + obj.Id] = ""; } } } } return(result); }
/// ////////////////////////////////////////// public CResultAErreur Delete(CContexteDonneesSynchroSecondaire donneesSecondaires) { CResultAErreur result = CResultAErreur.True; ArrayList lst = donneesSecondaires.GetTablesOrderDelete(); DataTable tableEntreesLog = donneesSecondaires.GetTableSafe(CEntreeLogSynchronisation.c_nomTable); foreach (DataTable table in lst) { if (m_mappeurTablesToClass.IsSynchronisable(table.TableName)) { DataTable tableDest = Tables[table.TableName]; DataView view = new DataView(tableEntreesLog); string strFiltre = CEntreeLogSynchronisation.c_champTable + "='" + table.TableName + "'"; view.RowFilter = strFiltre; string strCleMain = tableDest.PrimaryKey[0].ColumnName; foreach (DataRowView row in view) { CEntreeLogSynchronisation entree = new CEntreeLogSynchronisation(row.Row); if (entree.TypeModif == CEntreeLogSynchronisation.TypeModifLogSynchro.tDelete) { DataRow rowDest = tableDest.Rows.Find(entree.IdElement); if (rowDest != null) { rowDest.Delete(); } } } } } return(result); }