Пример #1
0
        //-------------------------------------------------------------------------------------------
        public List <CInfoSuppressionSynchronisation> GetSuppressions(int nIdSyncStart, int nIdSyncEnd)
        {
            CListeObjetDonneeGenerique <CEntreeLogSynchronisation> lst = new CListeObjetDonneeGenerique <CEntreeLogSynchronisation>(this);

            if (nIdSyncStart == -1)
            {
                lst.Filtre = new CFiltreData(
                    CSc2iDataConst.c_champIdSynchro + "<=@1 and " +
                    CEntreeLogSynchronisation.c_champType + "=@2",
                    nIdSyncEnd,
                    (int)CEntreeLogSynchronisation.TypeModifLogSynchro.tDelete);
            }
            else
            {
                lst.Filtre = new CFiltreData(
                    CSc2iDataConst.c_champIdSynchro + "<=@1 and " +
                    CSc2iDataConst.c_champIdSynchro + ">=@2 and " +
                    CEntreeLogSynchronisation.c_champType + "=@3",
                    nIdSyncEnd,
                    nIdSyncStart,
                    (int)CEntreeLogSynchronisation.TypeModifLogSynchro.tDelete);
            }
            lst.Tri = CEntreeLogSynchronisation.c_champId;
            List <CInfoSuppressionSynchronisation> lstSuppressions = new List <CInfoSuppressionSynchronisation>();

            foreach (CEntreeLogSynchronisation entree in lst)
            {
                CInfoSuppressionSynchronisation info = new CInfoSuppressionSynchronisation(entree.TableConcernee, entree.IdElement, entree.IdSyncSession);
                lstSuppressions.Add(info);
            }
            return(lstSuppressions);
        }
Пример #2
0
 /// ////////////////////////////////////////////////////////////
 public CListeObjetDonneesEnumerator(CListeObjetDonneeGenerique <TypeObjetsEnum> liste)
 {
     m_liste = liste;
 }
Пример #3
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);
        }
Пример #4
0
        protected CResultAErreur FillWithModifsFromVersion(
            int nIdSynchroDebut,
            int nIdSynchroFin,
            ref bool bHasData,
            CFiltresSynchronisation filtres,
            bool bOnlyTablesIndiqueesDansFiltresSynchro,
            bool bNePasLireLesDonnées)
        {
            m_nIdSynchro = nIdSynchroDebut;
            CResultAErreur result = CResultAErreur.True;

            Clear();

            //Crée la structure
            string[] strTables = m_mappeurTablesToClass.GetListeTables();
            if (bOnlyTablesIndiqueesDansFiltresSynchro)
            {
                strTables = filtres.TablesDefinies;
            }
            foreach (string strTable in strTables)
            {
                try
                {
                    GetTableSafe(strTable);
                }
                catch
                {
                    //La table n'existe pas, elle n'est probablement pas dans la structure secondaire
                }
            }

            //va chercher les informations dans la base pour chaque table
            ArrayList lst         = GetTablesOrderInsert();
            int       nTable      = 0;
            bool      bOldEnforce = EnforceConstraints;

            EnforceConstraints = false;
            List <CModifSynchronisation> lstModifs = new List <CModifSynchronisation>();

            foreach (DataTable table in lst)
            {
                if (m_mappeurTablesToClass.IsSynchronisable(table.TableName))
                {
                    IObjetServeur loader        = GetTableLoader(table.TableName);
                    CFiltreData   filtreSynchro = GetFiltreSynchro(IdSession, nIdSynchroDebut, nIdSynchroFin, filtres, table);
                    if (bNePasLireLesDonnées)
                    {
                        int nCount = loader.CountRecords(table.TableName, filtreSynchro);
                        if (nCount > 0)
                        {
                            CModifSynchronisation modif = new CModifSynchronisation(
                                table.TableName,
                                nCount,
                                filtreSynchro,
                                nIdSynchroDebut,
                                nIdSynchroFin);
                            lstModifs.Add(modif);
                        }
                    }
                    else
                    {
                        nTable++;
                        result = IntegreModif(
                            ref bHasData,
                            table,
                            loader,
                            filtreSynchro,
                            nIdSynchroDebut,
                            nIdSynchroFin);
                        if (!result)
                        {
                            return(result);
                        }
                    }
                }
            }
            if (!bNePasLireLesDonnées)
            {
                //Intègre la table des synclog
                CListeObjetDonneeGenerique <CEntreeLogSynchronisation> lstLogs = new CListeObjetDonneeGenerique <CEntreeLogSynchronisation>(this);
                if (nIdSynchroDebut >= 0)
                {
                    lstLogs.Filtre = new CFiltreData(CSc2iDataConst.c_champIdSynchro + ">=@1 and " +
                                                     CSc2iDataConst.c_champIdSynchro + "<=@2",
                                                     nIdSynchroDebut,
                                                     nIdSynchroFin);
                }
                else
                {
                    lstLogs.Filtre = new CFiltreData(CSc2iDataConst.c_champIdSynchro + ">=@1",
                                                     nIdSynchroFin);
                }
                lstLogs.AssureLectureFaite();
            }

            EnforceConstraints = bOldEnforce;


            Hashtable tableRowAdd     = new Hashtable();        //Liste des éléments ajoutés
            ArrayList listRowToDelete = new ArrayList();

            //Les éléments sont supprimés s'ils ont été ajoutés et supprimés ensuite

            /*//Charge les logs de données ajoutées et supprimées
             * CListeObjetsDonnees lstEntrees = new CListeObjetsDonnees ( this, typeof(CEntreeLogSynchronisation));
             * lstEntrees.Filtre = new CFiltreData ( CSc2iDataConst.c_champIdSynchro+">=@1 and "+
             *      CSc2iDataConst.c_champIdSynchro+"<=@2", nIdSynchroDebut, nIdSynchroFin);
             * if ( bOnlyTablesIndiqueesDansFiltresSynchro )
             * {
             * StringBuilder bl = new StringBuilder();
             * foreach ( string strTable in strTables )
             * bl.Append("'"+strTable+"',");
             * bl.Remove ( bl.Length-1, 1);
             * lstEntrees.Filtre = CFiltreData.GetAndFiltre ( lstEntrees.Filtre,
             * new CFiltreData ( CEntreeLogSynchronisation.c_champTable+" in ("+
             * bl.ToString()+")"));
             * }
             * foreach ( CEntreeLogSynchronisation entree in lstEntrees )
             * {
             *      if ( entree.TypeModif == CEntreeLogSynchronisation.TypeModifLogSynchro.tAdd )
             *      {
             *              DataTable table = GetTableSafe ( entree.TableConcernee );
             *              CObjetDonneeAIdNumerique obj = (CObjetDonneeAIdNumerique)GetNewObjetForTable ( table );
             *              obj.Id = entree.IdElement;
             *              tableRowAdd[entree.TableConcernee+"_"+entree.IdElement] = entree.Row;
             *              bHasData = true;
             *      }
             *      else
             *      {
             *              if ( tableRowAdd[entree.TableConcernee+"_"+entree.IdElement] != null )
             *              {
             *                      listRowToDelete.Add ( entree.Row );
             *                      listRowToDelete.Add ( tableRowAdd[entree.TableConcernee+"_"+entree.IdElement] );
             *                      bHasData = true;
             *              }
             *      }
             * }
             *
             * foreach ( DataRow row in listRowToDelete )
             * {
             *      row.Delete();
             * }*/

            if (bNePasLireLesDonnées)
            {
                result.Data = lstModifs;
            }
            return(result);
        }