Пример #1
0
        public DialogueDBManager(DialogueDBConnection con)
        {
            _connection = con;

            ///Get the Rows with maximum ID.
            ConversationEntry _maxConversationEntry = _connection.Query <ConversationEntry>("SELECT *, MAX(ID) FROM ConversationEntry")[0];
            ContentEntry      _maxContentEntry      = _connection.Query <ContentEntry>("SELECT *, MAX(ID) FROM ContentEntry")[0];
            ExecutionEntry    _maxExecutionEntry    = _connection.Query <ExecutionEntry>("SELECT *, MAX(ID) FROM ExecutionEntry")[0];
            ConditionEntry    _maxConditionEntry    = _connection.Query <ConditionEntry>("SELECT *, MAX(ID) FROM ConditionEntry")[0];

            ///And then set the IDs to the Manager. If a table is empty, then set the start ID.
            if (_maxConversationEntry.ID != 0)
            {
                NextConversationID = _maxConversationEntry.ID + 1;
            }
            else
            {
                NextConversationID = 1;
            }

            if (_maxContentEntry.ID != 0)
            {
                NextContentID = _maxContentEntry.ID + 10;
            }
            else
            {
                NextContentID = 1;
            }

            if (_maxExecutionEntry.ID != 0)
            {
                NextExecutionID = _maxExecutionEntry.ID + 10;
            }
            else
            {
                NextExecutionID = 2;
            }

            if (_maxConditionEntry.ID != 0)
            {
                NextConditionID = _maxConditionEntry.ID + 10;
            }
            else
            {
                NextConditionID = 3;
            }
        }
Пример #2
0
        public void InsertConditionEntry(string ycode, int sucID, int nextID)
        {
            ConditionEntry toInsert = new ConditionEntry(NextConditionID, ycode, sucID, nextID);

            try
            {
                _connection.Insert(toInsert);
            }
            catch (SQLiteException sex)
            {
                Debug.Log("Entry is not inserted. An error has occured. Check the constraints of the database scheme. "
                          + "The Result is: " + sex.Result
                          + "The Message is: " + sex.Message);
                throw;
            }
            NextConditionID += 10;
        }