Example #1
0
        /// //////////////////////////////////////////
        public CResultAErreur SaveBlobs()
        {
            CResultAErreur result = CResultAErreur.True;

            foreach (DataTable table in Tables)
            {
                if (m_mappeurTablesToClass.IsSynchronisable(table.TableName))
                {
                    IObjetServeur loader = GetTableLoader(table.TableName);
                    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)
                                {
                                    if (row[col.ColumnName] != DBNull.Value)
                                    {
                                        CDonneeBinaireInRow db = (CDonneeBinaireInRow)row[col.ColumnName];
                                        result = loader.SaveBlob(col.ColumnName, new object[] { row[strPrim] }, db.Donnees, null, null);
                                        if (!result)
                                        {
                                            return(result);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #2
0
        //------------------------------------------------------------------------------------
        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);
        }