예제 #1
0
파일: DataStore.cs 프로젝트: lie112/ApsimX
        /// <summary>Open the database.</summary>
        public void Open()
        {
            if (FileName == null)
            {
                UpdateFileName();
            }

            if (useFirebird)
            {
                connection = new Firebird();
            }
            else
            {
                connection = new SQLite();
            }

            connection.OpenDatabase(FileName, readOnly: false);

            Exception caughtException = null;

            try
            {
                if (dbReader == null)
                {
                    dbReader = new DataStoreReader();
                }
                dbReader.SetConnection(connection);
            }
            catch (Exception e)
            {
                caughtException = e;
            }
            try
            {
                if (dbWriter == null)
                {
                    dbWriter = new DataStoreWriter();
                }
                dbWriter.SetConnection(connection);
            }
            catch (Exception e)
            {
                caughtException = e;
            }
            if (caughtException != null)
            {
                throw caughtException;
            }
        }