/// <summary>
        /// Gets or creates a database session and immediately returns a session.
        /// </summary>
        /// <param name="pathname"></param>
        /// <returns></returns>
        public MultithreadedContentDatabaseSession GetDatabaseSession(string pathname, int pageSize)
        {
            //Try to load from the session list
            if (databaseSessions.TryGetValue(pathname, out MultithreadedContentDatabaseSession session))
            {
                return(session);
            }

            //Create
            session = new MultithreadedContentDatabaseSession(this);
            databaseSessions.TryAdd(pathname, session);

            //Begin loading
            OpenDatabaseCommand cmd = new OpenDatabaseCommand(session, pathname, pageSize);

            commandQueue.Enqueue(cmd);

            return(session);
        }
Ejemplo n.º 2
0
        public void ExecuteUseDatabaseCommand()
        {
            OpenDatabaseCommand command = new OpenDatabaseCommand(new NameExpression("testdb"), new ConstantExpression(OleDbConnectionString), new ConstantExpression(OleDbProviderFactoryName));
            Machine             machine = new Machine();

            command.Execute(machine, machine.Environment);

            object result = machine.Environment.GetValue(ValueEnvironment.CurrentDatabase);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Database));

            Database database = (Database)result;

            Assert.AreEqual(OleDbConnectionString, database.ConnectionString);
            Assert.IsInstanceOfType(database.ProviderFactory, typeof(System.Data.OleDb.OleDbFactory));

            object result2 = machine.Environment.GetValue("testdb");

            Assert.IsTrue(result == result2);
        }
Ejemplo n.º 3
0
        public void ExecuteUseWorkAreaCommand()
        {
            OpenDatabaseCommand dbcommand = new OpenDatabaseCommand(new NameExpression("testdb"), new ConstantExpression(OleDbConnectionString), new ConstantExpression(OleDbProviderFactoryName));
            Machine             machine   = new Machine();

            dbcommand.Execute(machine, machine.Environment);

            UseWorkAreaCommand command = new UseWorkAreaCommand(new NameExpression("testwa"), null);

            command.Execute(machine, machine.Environment);

            object result = machine.Environment.GetValue(ValueEnvironment.CurrentWorkArea);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(WorkArea));

            WorkArea workarea = (WorkArea)result;

            Assert.AreEqual("testwa", workarea.Name);

            object result2 = machine.Environment.GetValue("testwa");

            Assert.IsTrue(result == result2);
        }