示例#1
0
        private void CreateNotesAndCards(string id_deck, Anki anki = null)
        {
            Anki currentAnki = anki ?? (this);

            foreach (var ankiItem in currentAnki._ankiItems)
            {
                Note note = new Note(currentAnki._infoPerMid, currentAnki._mediaInfo, ankiItem);

                SQLiteHelper.ExecuteSQLiteCommand(currentAnki._conn, note.Query);

                Card card = new Card(_cardsMetadatas, note, id_deck);

                SQLiteHelper.ExecuteSQLiteCommand(currentAnki._conn, card.Query);
            }
        }
示例#2
0
        private void CreateNotesAndCards(string deckId, Anki anki = null)
        {
            Anki currentAnki = anki ?? (this);

            foreach (var ankiItem in currentAnki._ankiItems)
            {
                Note note = new Note(currentAnki._infoPerMid, ankiItem, UniqueField);

                SQLiteHelper.ExecuteSQLiteCommand(currentAnki._conn, note.SqlQuery, note.SqlParameters);

                Card card = new Card(_cardsMetadatas, note, deckId);

                SQLiteHelper.ExecuteSQLiteCommand(currentAnki._conn, card.SqlQuery, card.SqlParameters);
            }
        }
示例#3
0
        private void ExecuteSqLiteCommands(Anki anki = null)
        {
            try
            {
                _conn = new SQLiteConnection(@"Data Source=" + _collectionFilePath + ";Version=3;");
                _conn.Open();

                var column  = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.ColumnTable.txt");
                var notes   = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.NotesTable.txt");
                var cards   = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.CardsTable.txt");
                var revLogs = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.RevLogTable.txt");
                var graves  = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.GravesTable.txt");
                var indexes = GeneralHelper.ReadResource("AnkiSharp.SqLiteCommands.Indexes.txt");

                SQLiteParameter[] parameters = { };
                SQLiteHelper.ExecuteSQLiteCommand(_conn, column, parameters);
                SQLiteHelper.ExecuteSQLiteCommand(_conn, notes, parameters);
                SQLiteHelper.ExecuteSQLiteCommand(_conn, cards, parameters);
                SQLiteHelper.ExecuteSQLiteCommand(_conn, revLogs, parameters);
                SQLiteHelper.ExecuteSQLiteCommand(_conn, graves, parameters);
                SQLiteHelper.ExecuteSQLiteCommand(_conn, indexes, parameters);

                var deckId = CreateCol();
                CreateNotesAndCards(deckId, anki);

                AddRevlogMetadata();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                _conn.Close();
                _conn.Dispose();
                SQLiteConnection.ClearAllPools();
            }
        }