Example #1
0
        public static LocalDbAdapter GetDbDriver(Object caller)
        {
            LocalDbAdapter resultDbDriver;

            lock (_DbDriverListLock)
            {
                if (_listOfDbDrivers.Count == 0)
                {
                    resultDbDriver = new LocalDbAdapter();
                    _listOfDbDrivers.Add(resultDbDriver);
                }
                else
                {
                    if (_listOfDbDrivers.Count < _maxDbDriverInList)
                    {
                        resultDbDriver = new LocalDbAdapter();
                        _listOfDbDrivers.Add(resultDbDriver);
                    }
                    else
                    {
                        resultDbDriver = _listOfDbDrivers[0];
                        for (int i = 1; i < _listOfDbDrivers.Count; ++i)
                        {
                            if (_listOfDbDrivers[i].LinkedObjectCount < resultDbDriver.LinkedObjectCount)
                            {
                                resultDbDriver = _listOfDbDrivers[i];
                            }
                        }
                    }
                }
                resultDbDriver.link(caller);
                Console.WriteLine("Database list {0}", _listOfDbDrivers.Count);
                return(resultDbDriver);
            }
        }
Example #2
0
        public static LocalDbAdapter GetDbDriver(Object caller)
        {
            LocalDbAdapter resultDbDriver;

            lock (_DbDriverListLock)
            {
                if (_listOfDbDrivers.Count == 0)
                {
                    resultDbDriver = new LocalDbAdapter();
                    _listOfDbDrivers.Add(resultDbDriver);
                }
                else
                {
                    if (_listOfDbDrivers.Count < _maxDbDriverInList)
                    {
                        resultDbDriver = new LocalDbAdapter();
                        _listOfDbDrivers.Add(resultDbDriver);
                    }
                    else
                    {
                        resultDbDriver = _listOfDbDrivers[0];
                        for (int i = 1; i < _listOfDbDrivers.Count; ++i)
                        {
                            if (_listOfDbDrivers[i].LinkedObjectCount < resultDbDriver.LinkedObjectCount)
                                resultDbDriver = _listOfDbDrivers[i];
                        }
                    }
                }
                resultDbDriver.link(caller);
                Console.WriteLine("Database list {0}", _listOfDbDrivers.Count);
                return resultDbDriver;
            }
        }
 public OrderTransaction(Presets.OrderEvent _Listener, Presets.ErrorEvent _Error, String _userID)
 {
     addOrderLock = new Object();
     userID = _userID;
     _localDb = DbFactory.GetDbDriver(this);
     eventListener = _Listener;
     errorListsner = _Error;
 }