Пример #1
0
        ////////////////////////////////////////////////////
        public override IDbCommand GetInsertCommand(DataTable table, IDbDataAdapter adapter, bool bDisableIdsAuto)
        {
            DataColumn[] cols       = table.PrimaryKey;
            string       strChampId = null;

            if (cols != null && cols.Length == 1)
            {
                if (cols[0].AutoIncrement)
                {
                    strChampId = cols[0].ColumnName;
                }
            }

            OracleCommandBuilder builder       = new OracleCommandBuilder((OracleDataAdapter)adapter);
            bool bAvecTriggerMajAuto           = true;
            COracleDatabaseConnexion conOracle = m_connexion as COracleDatabaseConnexion;

            if (conOracle != null)
            {
                if (strChampId != null)
                {
                    conOracle.GetNomSequenceColAuto(table.TableName, strChampId, ref bAvecTriggerMajAuto);
                }
            }
            if (strChampId != null && !bAvecTriggerMajAuto)
            {
                table.Columns[strChampId].AutoIncrement = false;
            }

            OracleCommand cmdInsert = builder.GetInsertCommand();

            if (strChampId != null && !bAvecTriggerMajAuto)
            {
                table.Columns[strChampId].AutoIncrement = true;
            }
            if (m_connexion.IsInTrans())
            {
                cmdInsert.Transaction = (OracleTransaction)m_connexion.Transaction;
            }
            if (strChampId != null)
            {
                C2iOracleDataAdapter oracleAdapter = C2iOracleDataAdapter.GetOracleDataAdapter(adapter);
                if (oracleAdapter != null && !bDisableIdsAuto)
                {
                    oracleAdapter.PreparerInsertionLigneAvecAutoID(table.TableName, strChampId);
                }

                cmdInsert.UpdatedRowSource = UpdateRowSource.Both;
            }

            return(cmdInsert);
        }
Пример #2
0
        public C2iOracleDataAdapter(OracleCommand commande, COracleDatabaseConnexion OracleDbConnexion)
        {
            m_adapter = new OracleDataAdapter(commande);
            m_encapsuleurConnexion = OracleDbConnexion;
            m_connexion            = commande.Connection;
            m_transaction          = commande.Transaction;

            if (OracleDbConnexion is COracleDatabaseConnexionSynchronisable)
            {
                m_bSynchro = true;
            }
            else
            {
                m_bSynchro = false;
            }


            m_adapter.RowUpdated += new OracleRowUpdatedEventHandler(m_adapter_RowUpdated);
        }
Пример #3
0
 /// <summary>
 /// </summary>
 public C2iOracleAdapterBuilder(string strNomTableInDb, COracleDatabaseConnexion connexion)
     : base(strNomTableInDb, connexion)
 {
 }
Пример #4
0
 ////////////////////////////////////////////////////////
 public CFormatteurFiltreDataToStringOracle(COracleDatabaseConnexion connexion)
 {
     m_connexion = connexion;
 }
        ////////////////////////////////////////////////////
        public override IDbCommand GetInsertCommand(CStructureTable structure, bool bDisableIdAuto, IDbDataAdapter adapter)
        {
            bool bGestionAutoId = true;
            COracleDatabaseConnexion conOracle = m_connexion as COracleDatabaseConnexion;

            if (conOracle != null && structure.ChampsId.Length == 1 && structure.ChampsId[0].IsAutoId)
            {
                conOracle.GetNomSequenceColAuto(structure.NomTableInDb, structure.ChampsId[0].NomChamp, ref bGestionAutoId);
            }
            //Stef 2804 : N'exclue pas les champs exclus de l'insertion !

            IDbCommand command = m_cacheRequetes.GetCache(structure.NomTable, ETypeRequete.Insert);

            if (command == null)
            {
                string strReq    = "insert into " + structure.NomTableInDb + "(";
                string strValues = "(";
                foreach (CInfoChampTable champ in structure.Champs)
                {
                    if ((!champ.IsAutoId || bDisableIdAuto || !bGestionAutoId))
                    {
                        if (champ.TypeDonnee != typeof(CDonneeBinaireInRow) && !champ.TypeDonnee.IsSubclassOf(typeof(CDonneeBinaireInRow)))
                        {
                            strReq    += champ.NomChamp + ",";
                            strValues += GetNomParametreFor(champ, DataRowVersion.Current) + ",";
                        }
                    }
                }
                strReq    = strReq.Substring(0, strReq.Length - 1) + ")";
                strValues = strValues.Substring(0, strValues.Length - 1) + ")";
                strReq   += " values " + strValues;

                command             = m_connexion.GetConnexion().CreateCommand();
                command.CommandText = strReq;
                //Ajoute les paramètres
                foreach (CInfoChampTable champ in structure.Champs)
                {
                    if ((!champ.IsAutoId || bDisableIdAuto || !bGestionAutoId))
                    {
                        if (champ.TypeDonnee != typeof(CDonneeBinaireInRow) && !champ.TypeDonnee.IsSubclassOf(typeof(CDonneeBinaireInRow)))
                        {
                            command.Parameters.Add(GetParametreFor(command, champ, DataRowVersion.Current, ParameterDirection.Input));
                        }
                    }
                }
                m_cacheRequetes.SetCache(structure.NomTable, ETypeRequete.Insert, command);
            }


            if (structure.HasChampIdAuto)
            {
                C2iOracleDataAdapter oracleAdapter = C2iOracleDataAdapter.GetOracleDataAdapter(adapter);
                if (oracleAdapter != null && !bDisableIdAuto)
                {
                    oracleAdapter.PreparerInsertionLigneAvecAutoID(structure.NomTableInDb, structure.ChampsId[0].NomChamp);
                }
            }
            command.Connection       = m_connexion.GetConnexion();
            command.CommandType      = CommandType.Text;
            command.Transaction      = m_connexion.Transaction;
            command.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;

            return(command);
        }
 public C2iOracleAdapterBuilderForType(Type tp, COracleDatabaseConnexion connexion)
     : base(tp, connexion)
 {
 }
Пример #7
0
 //------------------------------------------------------------------------------------------------
 public COracleDataBaseCreator(COracleDatabaseConnexion connexion)
 {
     m_connection = connexion;
     m_connection.CommandTimeOut = 5 * 1000 * 60;
     m_mappeur = new COracleTypeMapper();
 }