//////////////////////////////////////////////////////////////////////////////////// private void AssureDonnees() { if (m_bLoaded) { return; } IObjetServeur loader = ((CContexteDonnee)m_row.Table.DataSet).GetTableLoader(m_row.Table.TableName); CFiltreData filtre = CFiltreData.CreateFiltreAndSurRow(m_row.Table.PrimaryKey, m_row); ArrayList lstKeys = new ArrayList(); foreach (DataColumn col in m_row.Table.PrimaryKey) { lstKeys.Add(m_row[col]); } CResultAErreur result = loader.ReadBlob(m_strChamp, lstKeys.ToArray()); if (!result) { throw new CExceptionErreur(result.Erreur); } m_donnees = (byte[])result.Data; if (m_donnees != null) { m_donneesOriginales = (byte[])m_donnees.Clone(); } else { m_donneesOriginales = null; } m_bLoaded = true; }
//------------------------------------------------------------------------------------ private CResultAErreur IntegreModif( ref bool bHasData, DataTable table, IObjetServeur loader, CFiltreData filtreSynchro, int nIdSyncStart, int nIdSyncEnd) { CResultAErreur result = CResultAErreur.True; DataTable newTable = loader.Read(filtreSynchro); if (newTable.Rows.Count != 0) { bHasData = true; } foreach (DataRow row in newTable.Rows) { if (nIdSyncStart == -1) { row.AcceptChanges(); row.SetAdded(); } else { int?nIdSessionRow = row[CSc2iDataConst.c_champIdSynchro] as int?; if (nIdSessionRow == null && nIdSessionRow.Value >= nIdSyncStart) { row.AcceptChanges(); row.SetModified(); } } } IntegreTable(newTable, false); //Synchronisation des blobs if (loader.HasBlobs()) { string strPrim = table.PrimaryKey[0].ColumnName; foreach (DataColumn col in table.Columns) { if (col.DataType == typeof(CDonneeBinaireInRow)) { foreach (DataRow row in table.Rows) { result = loader.ReadBlob(col.ColumnName, new object[] { row[strPrim] }); if (result) { CDonneeBinaireInRow donnee = new CDonneeBinaireInRow(IdSession, row, col.ColumnName); donnee.Donnees = (byte[])result.Data; row[col.ColumnName] = donnee; } if (!result) { return(result); } } } } } //Gestion des ajouts et suppressions CListeObjetDonneeGenerique <CEntreeLogSynchronisation> lst = new CListeObjetDonneeGenerique <CEntreeLogSynchronisation>(this); if (nIdSyncStart == -1) { lst.Filtre = new CFiltreData(CEntreeLogSynchronisation.c_champTable + "=@1 and " + CSc2iDataConst.c_champIdSynchro + "<=@2", table.TableName, nIdSyncEnd); } else { lst.Filtre = new CFiltreData(CEntreeLogSynchronisation.c_champTable + "=@1 and " + CSc2iDataConst.c_champIdSynchro + "<=@2 and " + CSc2iDataConst.c_champIdSynchro + ">=@3", table.TableName, nIdSyncEnd, nIdSyncStart); } lst.Tri = CEntreeLogSynchronisation.c_champType; foreach (CEntreeLogSynchronisation log in lst) { if (log.TypeModif == CEntreeLogSynchronisation.TypeModifLogSynchro.tAdd) { DataRow row = table.Rows.Find(log.IdElement); if (row != null && row.RowState != DataRowState.Added) { row.AcceptChanges(); row.SetAdded(); } } if (log.TypeModif == CEntreeLogSynchronisation.TypeModifLogSynchro.tDelete) { DataRow row = table.Rows.Find(log.IdElement); if (row != null) { if (row.RowState == DataRowState.Added) { table.Rows.Remove(row); } else { row.Delete(); } } } } return(result); }