Esempio n. 1
0
        internal int DoAddCategory(String name, DbTransaction transaction)
        {
            // Insert into categories table
            String insertCommand = String.Format("INSERT INTO {0} ({1}) VALUES (@Id)", Schema.CATEGORIES_TABLE, Schema.ID_COLUMN);

            using (DbCommand command = DbUtils.CreateDbCommand(insertCommand, m_Connection, transaction))
            {
                command.AddParameterWithValue("@Id", DBNull.Value);
                int res = command.ExecuteNonQuery();
                if (res != 1)
                {
                    throw new TagsDbException("Insertion into Category table failed.");
                }
            }
            long newId = m_Connection.LastInsertRowId();

            // Insert name into translation table
            TagsTranslations.DoAddTranslation(m_Connection, transaction, Schema.CATEGORYNAMES_TABLE, Schema.CATEGORY_COLUMN, Schema.LANGUAGE_COLUMN, newId, m_LanguageId, name);

            return((int)newId);
        }
Esempio n. 2
0
        private void InsertDefaultValues(DbTransaction transaction)
        {
            // Languages
            TagsTranslations translations = new TagsTranslations(m_Connection);

            int enId = translations.DoAddLanguage("en", "English", transaction);
            int deId = translations.DoAddLanguage("de", "German", enId, transaction);
            int frId = translations.DoAddLanguage("fr", "French", enId, transaction);
            int esId = translations.DoAddLanguage("es", "Spanish", enId, transaction);

            translations.DoSetLanguageName(deId, enId, "Englisch", transaction);
            translations.DoSetLanguageName(deId, deId, "Deutsch", transaction);
            translations.DoSetLanguageName(deId, frId, "Französisch", transaction);
            translations.DoSetLanguageName(deId, esId, "Spanisch", transaction);

            translations.DoSetLanguageName(frId, enId, "Anglais", transaction);
            translations.DoSetLanguageName(frId, deId, "Allemand", transaction);
            translations.DoSetLanguageName(frId, frId, "Français", transaction);
            translations.DoSetLanguageName(frId, esId, "Espagnol", transaction);

            translations.DoSetLanguageName(esId, enId, "Inglés", transaction);
            translations.DoSetLanguageName(esId, deId, "Aléman", transaction);
            translations.DoSetLanguageName(esId, frId, "Francés", transaction);
            translations.DoSetLanguageName(esId, esId, "Castellano", transaction);

            // Categories
            LanguageWriting en = new LanguageWriting(enId, m_Connection);
            LanguageWriting de = new LanguageWriting(deId, m_Connection);
            LanguageWriting fr = new LanguageWriting(frId, m_Connection);
            LanguageWriting es = new LanguageWriting(esId, m_Connection);

            int atmId   = AddDefaultCategory("Mood", "Stimmung", "Ambiance", "Ambiente", en, de, fr, es, transaction);
            int sitId   = AddDefaultCategory("Situation", "Situation", "Situation", "Situación", en, de, fr, es, transaction);
            int placeId = AddDefaultCategory("Place", "Ort", "Lieu", "Lugar", en, de, fr, es, transaction);

            // Tags
            String[][][] tags = new String[][][]
            {
                new String[][]
                {
                    new String[] { "Suspense", "Spannung", "Suspense", "Suspense" },
                    new String[] { "Recovery", "Erholung", "Répos", "Recuperación" },
                    new String[] { "Mourning", "Trauer", "Deuil", "Duelo" }
                },
                new String[][]
                {
                    new String[] { "Fight", "Kampf", "Combat", "Combate" },
                    new String[] { "Ritual", "Ritual", "Rituel", "Ritual" },
                    new String[] { "Travel", "Reise", "Voyage", "Viaje" }
                },
                new String[][]
                {
                    new String[] { "Orient", "Orient", "Orient", "Oriente" },
                    new String[] { "Jungle", "Dschungel", "Jungle", "Jungla" },
                    new String[] { "Sea", "Meer", "Mer", "Mar" }
                }
            };

            int[] catIds = new int[] { atmId, sitId, placeId };
            for (int i = 0; i < catIds.Length; ++i)
            {
                String[][] catTags = tags[i];
                for (int j = 0; j < catTags.Length; ++j)
                {
                    String[] names = catTags[j];
                    AddDefaultTag(catIds[i], names[0], names[1], names[2], names[3], en, de, fr, es, transaction);
                }
            }
        }
Esempio n. 3
0
 private void DoRemoveTag(int tagId)
 {
     // Note: only removes the translation!
     TagsTranslations.DoRemoveTranslation(m_Connection, null, Schema.TAGNAMES_TABLE, Schema.TAG_COLUMN, Schema.LANGUAGE_COLUMN, tagId, m_LanguageId);
 }
Esempio n. 4
0
 private void DoRemoveCategory(int categoryId)
 {
     // Note: only removes the translation!
     TagsTranslations.DoRemoveTranslation(m_Connection, null, Schema.CATEGORYNAMES_TABLE, Schema.CATEGORY_COLUMN, Schema.LANGUAGE_COLUMN, categoryId, m_LanguageId);
 }
Esempio n. 5
0
 internal void DoSetTagName(int tagId, String name, DbTransaction transaction)
 {
     TagsTranslations.DoSetTranslation(m_Connection, Schema.TAGNAMES_TABLE, Schema.TAG_COLUMN, Schema.LANGUAGE_COLUMN, tagId, m_LanguageId, name, transaction);
 }
Esempio n. 6
0
 private void DoSetTagName(int tagId, String name)
 {
     TagsTranslations.DoSetTranslation(m_Connection, Schema.TAGNAMES_TABLE, Schema.TAG_COLUMN, Schema.LANGUAGE_COLUMN, tagId, m_LanguageId, name);
 }
Esempio n. 7
0
 internal void DoSetCategoryName(int categoryId, String name, DbTransaction transaction)
 {
     TagsTranslations.DoSetTranslation(m_Connection, Schema.CATEGORYNAMES_TABLE, Schema.CATEGORY_COLUMN, Schema.LANGUAGE_COLUMN,
                                       categoryId, m_LanguageId, name, transaction);
 }