Esempio n. 1
0
 public virtual int CompareTo(object o)
 {
     if (o == null || !(o is NeoDatis.Odb.Impl.Core.Transaction.Session))
     {
         return(-100);
     }
     NeoDatis.Odb.Core.Transaction.ISession session = (NeoDatis.Odb.Core.Transaction.ISession
                                                       )o;
     return(GetId().CompareTo(session.GetId()));
 }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     if (obj == null || !(obj is NeoDatis.Odb.Impl.Core.Transaction.Session))
     {
         return(false);
     }
     NeoDatis.Odb.Core.Transaction.ISession session = (NeoDatis.Odb.Core.Transaction.ISession
                                                       )obj;
     return(GetId().Equals(session.GetId()));
 }
Esempio n. 3
0
 /// <summary>Adds a write action to the transaction</summary>
 /// <param name="writeAction">The write action to be added</param>
 /// <param name="persistWriteAcion">To indicate if write action must be persisted</param>
 public virtual void AddWriteAction(NeoDatis.Odb.Core.Transaction.IWriteAction writeAction
                                    , bool persistWriteAcion)
 {
     if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
     {
         NeoDatis.Tool.DLogger.Info("Adding WA in Transaction of session " + session.GetId
                                        ());
     }
     if (writeAction.IsEmpty())
     {
         return;
     }
     CheckRollback();
     if (!hasBeenPersisted && persistWriteAcion)
     {
         Persist();
     }
     if (persistWriteAcion)
     {
         writeAction.Persist(fsi, numberOfWriteActions + 1);
     }
     // Only adds the writeaction to the list if the transaction keeps all in
     // memory
     if (hasAllWriteActionsInMemory)
     {
         writeActions.Add(writeAction);
     }
     numberOfWriteActions++;
     if (hasAllWriteActionsInMemory && numberOfWriteActions > NeoDatis.Odb.OdbConfiguration
         .GetMaxNumberOfWriteObjectPerTransaction())
     {
         hasAllWriteActionsInMemory = false;
         System.Collections.IEnumerator iterator = writeActions.GetEnumerator();
         NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction wa = null;
         while (iterator.MoveNext())
         {
             wa = (NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction)iterator.Current;
             wa.Clear();
         }
         writeActions.Clear();
         if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
         {
             NeoDatis.Tool.DLogger.Info("Number of objects has exceeded the max number " + numberOfWriteActions
                                        + "/" + NeoDatis.Odb.OdbConfiguration.GetMaxNumberOfWriteObjectPerTransaction()
                                        + ": switching to persistent transaction managment");
         }
     }
 }
        // TODO Nothing to do
        public virtual NeoDatis.Odb.Core.Transaction.ISession GetSession(string baseIdentification
                                                                         , bool throwExceptionIfDoesNotExist)
        {
            string threadName = NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName();

            System.Text.StringBuilder id = new System.Text.StringBuilder(threadName).Append(baseIdentification
                                                                                            );
            NeoDatis.Odb.Core.Transaction.ISession session = sessions[id.ToString()];
            if (session == null && throwExceptionIfDoesNotExist)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.SessionDoesNotExistForConnection
                                                           .AddParameter(threadName).AddParameter(baseIdentification).AddParameter(id));
            }
            if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
            {
                NeoDatis.Tool.DLogger.Debug("Getting session for base " + baseIdentification + " and thread "
                                            + threadName + " = " + id + " - sid=" + session.GetId());
            }
            return(session);
        }
        public virtual void AddSession(NeoDatis.Odb.Core.Transaction.ISession session)
        {
            string id = NeoDatis.Tool.Wrappers.OdbThread.GetCurrentThreadName() + session.GetBaseIdentification
                            ();

            sessions.Add(id, session);
            if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
            {
                NeoDatis.Tool.DLogger.Debug("Associating id = " + id + " to session " + session.GetId
                                                ());
            }
        }