Ejemplo n.º 1
0
        public SQLite3DB Connect()
        {
            SQLite3DB db = new SQLite3DB(dbPath);

            db.EnableLoadExtension = true;
            db.Exec("PRAGMA temp_store = MEMORY;");
            db.Exec("PRAGMA encoding = \"UTF-8\"; ");
            migemoGeneratorDlg = migemoGenerator;
            Lutea.Core.LuteaHelper.RegisterSQLiteUserFunctions(db.GetHandle(), new Core.LuteaHelper.MigemoGenerator(migemoGeneratorDlg));
            return(db);
        }
Ejemplo n.º 2
0
 private void InitializeLibraryDB(SQLite3DB db, Column[] columns)
 {
     db.Exec(GetCreateLibraryDefinitionSchema());
     using (var stmt = db.Prepare("INSERT INTO library_definition ( column_name, localized_name, type, is_primary, mapped_tag_field, is_text_search_target, omit_on_import) VALUES(?,?,?,?,?,?,?);"))
     {
         foreach (var col in columns)
         {
             stmt.Reset();
             stmt.Bind(1, col.Name);
             stmt.Bind(2, col.LocalText);
             stmt.Bind(3, ((int)col.Type).ToString());
             stmt.Bind(4, col.PrimaryKey ? "1" : "0");
             stmt.Bind(5, col.MappedTagField == null ? "" : col.MappedTagField);
             stmt.Bind(6, col.IsTextSearchTarget ? "1" : "0");
             stmt.Bind(7, col.OmitOnImport ? "1" : "0");
             stmt.Evaluate(null);
         }
     }
     db.Exec(GetCreateSchema(columns));
     db.Exec(GetCreateIndexSchema(columns));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 現在の条件でプレイリストをソート
        /// </summary>
        private void CreateOrderedPlaylistTableInDB()
        {
            try
            {
                LibraryDB.Exec("DROP TABLE IF EXISTS playlist;");
            }
            catch (SQLite3DB.SQLite3Exception ee)
            {
                Logger.Log(ee);
            }

            if (AppCore.PlaylistSortColumn != null)
            {
                var orderPhrase = " ORDER BY "
                                  + (NumericColumnTypes.Contains(AppCore.Library.Columns[Controller.GetColumnIndexByName(AppCore.PlaylistSortColumn)].Type)
                        ? ("list." + AppCore.PlaylistSortColumn + "-0")
                        : ("list." + AppCore.PlaylistSortColumn + "||'' COLLATE NOCASE "))
                                  + (AppCore.PlaylistSortOrder == Controller.SortOrders.Asc
                        ? " ASC "
                        : " DESC ");

                for (int i = 0; i < RETRY_COUNT; i++)
                {
                    try
                    {
                        LibraryDB.Exec("CREATE TEMP TABLE playlist AS SELECT list.file_name, list.tagAlbum FROM list, unordered_playlist WHERE list.file_name == unordered_playlist.file_name " + orderPhrase + " ;");
                        break;
                    }
                    catch (SQLite3DB.SQLite3Exception) { }
                    Thread.Sleep(RETRY_DELAY);
                }
            }

            LuteaHelper.ClearRepeatCount(CurrentPlaylistRows);
            LibraryDB.Exec("SELECT __x_lutea_count_continuous(tagAlbum) FROM " + PlaylistTableName + " ;");
            TagAlbumContinuousCount = (int[])LuteaHelper.counter.Clone();
            DisposeFetchStmt();
        }
Ejemplo n.º 4
0
 private void SetupConnection()
 {
     LibraryDB = AppCore.Library.Connect();
     LibraryDB.Exec("CREATE TEMP VIEW allTags AS SELECT *, " + String.Join("||'\n'||", Controller.Columns.Where(_ => _.IsTextSearchTarget).Select(_ => _.Name)) + " AS text FROM list;");
 }